auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
protected void createViews() { appView.getView().setId(100); appView.getView().setLayoutParams(new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); setContentView(appView.getView()); if (preferences.contains("BackgroundColor")) { try { int backgroundColor = preferences.getInteger("BackgroundColor", Color.BLACK); appView.getView().setBackgroundColor(backgroundColor); }catch (NumberFormatException e){ System.out.println(e.getMessage()); } } appView.getView().requestFocusFromTouch(); }

Target:
protected void createViews() { appView.getView().setId(100); appView.getView().setLayoutParams(new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); setContentView(appView.getView()); if (preferences.contains("BackgroundColor")) { try { int backgroundColor = preferences.getInteger("BackgroundColor", Color.BLACK); appView.getView().setBackgroundColor(backgroundColor); } catch (NumberFormatException e){ e.printStackTrace(); } } appView.getView().requestFocusFromTouch(); }
Source:
public TmfVertex(TmfVertex node, final long ts) { this.fTimestamp = ts; this.fId = count++; fOutgoingVertical = node.fOutgoingVertical; fIncomingVertical = node.fIncomingVertical; fOutgoingHorizontal = node.fOutgoingHorizontal; fIncomingHorizontal = node.fIncomingHorizontal; }

Target:
public TmfVertex(TmfVertex node, final long ts) { fTimestamp = ts; synchronized (TmfVertex.class) { fId = count++; } fOutgoingVertical = node.fOutgoingVertical; fIncomingVertical = node.fIncomingVertical; fOutgoingHorizontal = node.fOutgoingHorizontal; fIncomingHorizontal = node.fIncomingHorizontal; }
Source:
public WebClient() { super(BrowserVersion.FIREFOX_38); setPageCreator(HudsonPageCreator.INSTANCE); clients.add(this); setAjaxController(new AjaxController() { private static final long serialVersionUID = -5844060943564822678L; public boolean processSynchron(HtmlPage page, WebRequest settings, boolean async) { return false; } }); setCssErrorHandler(new ErrorHandler() { final ErrorHandler defaultHandler = new DefaultCssErrorHandler(); public void warning(CSSParseException exception) throws CSSException { if (!ignore(exception)) defaultHandler.warning(exception); } public void error(CSSParseException exception) throws CSSException { if (!ignore(exception)) defaultHandler.error(exception); } public void fatalError(CSSParseException exception) throws CSSException { if (!ignore(exception)) defaultHandler.fatalError(exception); } private boolean ignore(CSSParseException e) { return e.getURI().contains("/yui/"); } }); getJavaScriptEngine().getContextFactory().addListener(new Listener() { public void contextCreated(Context cx) { if (cx.getDebugger() == null) cx.setDebugger(jsDebugger, null); } public void contextReleased(Context cx) { } }); setAlertHandler(new AlertHandler() { public void handleAlert(Page page, String message) { throw new AssertionError("Alert dialog poped up: "+message); } }); }

Target:
public WebClient() { super(BrowserVersion.FIREFOX_38); setPageCreator(HudsonPageCreator.INSTANCE); clients.add(this); setAjaxController(new AjaxController() { private static final long serialVersionUID = 6730107519583349963L; public boolean processSynchron(HtmlPage page, WebRequest settings, boolean async) { return false; } }); setCssErrorHandler(new ErrorHandler() { final ErrorHandler defaultHandler = new DefaultCssErrorHandler(); public void warning(CSSParseException exception) throws CSSException { if (!ignore(exception)) defaultHandler.warning(exception); } public void error(CSSParseException exception) throws CSSException { if (!ignore(exception)) defaultHandler.error(exception); } public void fatalError(CSSParseException exception) throws CSSException { if (!ignore(exception)) defaultHandler.fatalError(exception); } private boolean ignore(CSSParseException e) { return e.getURI().contains("/yui/"); } }); getJavaScriptEngine().getContextFactory().addListener(new Listener() { public void contextCreated(Context cx) { if (cx.getDebugger() == null) cx.setDebugger(jsDebugger, null); } public void contextReleased(Context cx) { } }); setAlertHandler(new AlertHandler() { public void handleAlert(Page page, String message) { throw new AssertionError("Alert dialog poped up: "+message); } }); }
Source:
public Repo<Master> call(long tid, Master master) throws Exception { VolumeManager fs = master.getFileSystem(); fs.mkdirs(new Path(tableInfo.dir)); if (tableInfo.initialSplitSize > 0) { SortedSet<Text> dirInfo = Utils .getSortedSetFromFile(master.getInputStream(tableInfo.splitDirsFile), false); createTabletDirectories(master.getFileSystem(), dirInfo); } return new PopulateMetadata(tableInfo); }

Target:
public Repo<Master> call(long tid, Master master) throws Exception { VolumeManager fs = master.getFileSystem(); fs.mkdirs(new Path(tableInfo.defaultTabletDir)); if (tableInfo.initialSplitSize > 0) { SortedSet<Text> dirInfo = Utils .getSortedSetFromFile(master.getInputStream(tableInfo.splitDirsFile), false); createTabletDirectories(master.getFileSystem(), dirInfo); } return new PopulateMetadata(tableInfo); }
Source:
public void testAuthentication() { ConfigurationBuilder clientBuilder = initServerAndClient(); clientBuilder.security().authentication().callbackHandler(new TestCallbackHandler("user", "realm", "password".toCharArray())); remoteCacheManager = new RemoteCacheManager(clientBuilder.build()); RemoteCache<String, String> defaultRemote = remoteCacheManager.getCache(); defaultRemote.put("a", "a"); Object o = defaultRemote.get("a"); assertEquals("a", defaultRemote.get("a")); }

Target:
public void testAuthentication() { ConfigurationBuilder clientBuilder = initServerAndClient(); clientBuilder.security().authentication().callbackHandler(new TestCallbackHandler("user", "realm", "password".toCharArray())); remoteCacheManager = new RemoteCacheManager(clientBuilder.build()); RemoteCache<String, String> defaultRemote = remoteCacheManager.getCache(); defaultRemote.put("a", "a"); assertEquals("a", defaultRemote.get("a")); }
Source:
public void edit() { if (getWindow() != null) { return; } EditDiskProfileModel model = new EditDiskProfileModel(this, getCompatibilityVersion(), (DiskProfile) getSelectedItem(), getEntity().getStoragePoolId()); setWindow(model); initProfileStorageDomains(model); }

Target:
public void edit() { if (getWindow() != null) { return; } EditDiskProfileModel model = new EditDiskProfileModel(this, (DiskProfile) getSelectedItem(), getEntity().getStoragePoolId()); setWindow(model); initProfileStorageDomains(model); }
Source:
public void run(IAction action) { try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( RepositoryUi.ID_VIEW_REPOSITORIES); } catch (PartInitException e) { StatusHandler .log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Can not show Team Repository View", e)); e.printStackTrace(); } }

Target:
public void run(IAction action) { try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( RepositoryUi.ID_VIEW_REPOSITORIES); } catch (PartInitException e) { StatusHandler .log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Can not show Team Repository View", e)); } }
Source:
public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final GitHubPushCause other = (GitHubPushCause) obj; if ((this.pushedBy == null) ? (other.pushedBy != null) : !this.pushedBy.equals(other.pushedBy)) { return false; } return true; }

Target:
public boolean equals(Object obj) { if (!getClass().isInstance(obj)) { return false; } final GitHubPushCause other = (GitHubPushCause) obj; if ((this.pushedBy == null) ? (other.pushedBy != null) : !this.pushedBy.equals(other.pushedBy)) { return false; } return true; }
Source:
private byte[] subArray(byte[] byteArray, int beginIndex, int length) { byte[] subArray = new byte[length]; System.arraycopy(byteArray, beginIndex, subArray, 0, subArray.length); return subArray; }

Target:
private static byte[] subArray(byte[] byteArray, int beginIndex, int length) { byte[] subArray = new byte[length]; System.arraycopy(byteArray, beginIndex, subArray, 0, subArray.length); return subArray; }
Source:
private FluidStack fluidFromBlock(Block block) { if (block instanceof BlockStaticLiquid) { if (block == Blocks.WATER) { return new FluidStack(FluidRegistry.WATER, 1000); } else if (block == Blocks.LAVA) { return new FluidStack(FluidRegistry.LAVA, 1000); } } return null; }

Target:
private FluidStack fluidFromBlock(Block block) { if (block == Blocks.WATER) { return new FluidStack(FluidRegistry.WATER, 1000); } else if (block == Blocks.LAVA) { return new FluidStack(FluidRegistry.LAVA, 1000); } return null; }
Source:
protected Set<String> filterZones(Set<String> zones) { if(System.getProperty("test.live.region")==null){ return zones; } Set<String> zoneFilter = Sets.newHashSet(System.getProperty("test.live.region").split(",")); return Sets.intersection(zones, zoneFilter); }

Target:
protected Set<String> filterZones(Set<String> zones) { String zonesToList = System.getProperty("test.live.zones"); if(zonesToList == null) { return zones; } Set<String> zoneFilter = Sets.newHashSet(Splitter.on(',').split(zonesToList)); return Sets.intersection(zones, zoneFilter); }
Source:
public Void call() throws IOException { if (task == null) { throw new IOException("The callable " + this + " has been serialized somehow, but it is actually not serializable"); } try { return task.call(); } catch (Exception ex) { if (ex instanceof IOException) { throw (IOException)ex; } throw new IOException(ex); } }

Target:
public Void call() throws IOException { if (task == null) { throw new IOException("The callable " + this + " has been serialized somehow, but it is actually not serializable"); } try { return task.call(); } catch (IOException ex) { throw ex; } catch (Exception ex) { throw new IOException(ex); } }
Source:
public void singleFilePut() throws IOException, URISyntaxException, XmlProcessingException, SignatureException { final String bucketName = "java_integration_test"; final String book = "beowulf.txt"; final Ds3ClientHelpers helpers = Ds3ClientHelpers.wrap(client); try { helpers.ensureBucketExists(bucketName); final Path objFile = ResourceUtils.loadFileResource(Util.RESOURCE_BASE_NAME + book); final String digest = DigestUtils.sha256Hex(Files.newInputStream(objFile)); final Ds3Object obj = new Ds3Object(book, Files.size(objFile)); final Ds3ClientHelpers.Job putJob = helpers.startWriteJob(bucketName, Lists.newArrayList(obj)); putJob.transfer(new ResourceObjectPutter(Util.RESOURCE_BASE_NAME)); final Path tempDir = Files.createTempDirectory("ds3_test_"); final Ds3ClientHelpers.Job getJob = helpers.startReadAllJob(bucketName); getJob.transfer(new FileObjectGetter(tempDir)); final String secondDigest = DigestUtils.sha256Hex(Files.newInputStream(tempDir.resolve(book))); assertThat(secondDigest, is(equalTo(digest))); } finally { Util.deleteAllContents(client, bucketName); } }

Target:
public void singleFilePut() throws IOException, URISyntaxException, XmlProcessingException, SignatureException { final String bucketName = "java_integration_test"; final String book = "beowulf.txt"; final Ds3ClientHelpers helpers = Ds3ClientHelpers.wrap(client); try { helpers.ensureBucketExists(bucketName); final Path objPath = ResourceUtils.loadFileResource(Util.RESOURCE_BASE_NAME + book); final String digest = DigestUtils.sha256Hex(Files.newInputStream(objPath)); final Ds3Object obj = new Ds3Object(book, Files.size(objPath)); final Ds3ClientHelpers.Job putJob = helpers.startWriteJob(bucketName, Lists.newArrayList(obj)); putJob.transfer(new ResourceObjectPutter(Util.RESOURCE_BASE_NAME)); final Path tempDir = Files.createTempDirectory("ds3_test_"); final Ds3ClientHelpers.Job getJob = helpers.startReadAllJob(bucketName); getJob.transfer(new FileObjectGetter(tempDir)); final String secondDigest = DigestUtils.sha256Hex(Files.newInputStream(tempDir.resolve(book))); assertThat(secondDigest, is(equalTo(digest))); } finally { Util.deleteAllContents(client, bucketName); } }
Source:
public void build(TopologyBuilder bldr, Set<String> stageNames) { if (built) { throw new RuntimeException("Logic Error While building stage: " + getName()); } if (doBuild(bldr, stageNames)) { built = true; for (StreamletImpl<?> streamlet : children) { streamlet.build(bldr, stageNames); } } }

Target:
public void build(TopologyBuilder bldr, Set<String> stageNames) { if (built) { throw new RuntimeException("Logic Error While building " + getName()); } if (doBuild(bldr, stageNames)) { built = true; for (StreamletImpl<?> streamlet : children) { streamlet.build(bldr, stageNames); } } }
Source:
public StringDataValue getNullChar(StringDataValue previous, int collationType, int maxSize) throws StandardException { SQLChar ret = null; if (collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC) { ret = (SQLChar) getCharDataValue((String) null); } else { ret = new CollatorSQLChar(getCharacterCollator(collationType)); } ret.setSqlCharSize(maxSize); if (previous != null) previous.setToNull(); return ret; }

Target:
public StringDataValue getNullChar(StringDataValue previous, int collationType, int maxSize) throws StandardException { if (previous != null) { previous.setToNull(); return previous; } SQLChar ret = null; if (collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC) { ret = (SQLChar) getCharDataValue((String) null); } else { ret = new CollatorSQLChar(getCharacterCollator(collationType)); } ret.setSqlCharSize(maxSize); return ret; }
Source:
private boolean isjPMMLAvailableToClassLoader(ClassLoader classLoader) { try { classLoader.loadClass("org.kie.dmn.jpmml.DMNjPMMLInvocationEvaluator"); return true; } catch (ClassNotFoundException e) { } return false; }

Target:
private boolean isjPMMLAvailableToClassLoader(ClassLoader classLoader) { try { classLoader.loadClass("org.kie.dmn.jpmml.DMNjPMMLInvocationEvaluator"); return true; } catch (ClassNotFoundException e) { return false; } }
Source:
public Object execute(final ExecutionEvent aEvent) { try { IEditorInput activeEditorInput = HandlerUtil.getActiveEditorInput(aEvent); if (activeEditorInput instanceof GerritMultipleInput) { viewer = ((GerritMultipleInput) activeEditorInput).getUpperSection().getDiffTreeViewer(); TreeViewer treeViewer = viewer; IBaseLabelProvider labelProvider = treeViewer .getLabelProvider(CompareUpperSectionColumn.FILE_PATH.ordinal()); if (labelProvider instanceof FileInfoCompareCellLabelProvider) { FileInfoCompareCellLabelProvider infoProvider = (FileInfoCompareCellLabelProvider) labelProvider; infoProvider.setFileNameFirst(!infoProvider.getFileOrder()); treeViewer.refresh(); } } } finally { return Status.OK_STATUS; } }

Target:
public Object execute(final ExecutionEvent aEvent) { try { IEditorInput activeEditorInput = HandlerUtil.getActiveEditorInput(aEvent); if (activeEditorInput instanceof GerritMultipleInput) { TreeViewer treeViewer = ((GerritMultipleInput) activeEditorInput).getUpperSection().getDiffTreeViewer(); IBaseLabelProvider labelProvider = treeViewer .getLabelProvider(CompareUpperSectionColumn.FILE_PATH.ordinal()); if (labelProvider instanceof FileInfoCompareCellLabelProvider) { FileInfoCompareCellLabelProvider infoProvider = (FileInfoCompareCellLabelProvider) labelProvider; infoProvider.setFileNameFirst(!infoProvider.getFileOrder()); treeViewer.refresh(); } } } finally { return Status.OK_STATUS; } }
Source:
public void unrevoke(Content content) { if (!(content instanceof Item)) { throw new RuntimeException("content " + content.getCanonicalUri() + " not an item, cannot revoke"); } revocationStore.unrevoke(content.getCanonicalUri()); Item item = (Item) content; Map<String, ItemOnDemandHierarchy> onDemandHierarchies = onDemandHierarchyExpander.expandHierarchy(item); try { for (Entry<String, ItemOnDemandHierarchy> onDemandHierarchy : onDemandHierarchies.entrySet()) { Task task = createTaskFor(content, Action.DELETE, TVAElementType.ONDEMAND, onDemandHierarchy.getKey()); ItemOnDemandHierarchy hierarchy = onDemandHierarchy.getValue(); JAXBElement<TVAMainType> tvaMain = generator.generateOnDemandTVAFrom(hierarchy, onDemandHierarchy.getKey()); YouViewResult uploadResult = client.upload(tvaMain); processDeletionResult(task, item, uploadResult); } } catch (TvaGenerationException e) { throw Throwables.propagate(e); } }

Target:
public void unrevoke(Content content) { checkArgument(content instanceof Item, "content " + content.getCanonicalUri() + " not an item, cannot unrevoke"); revocationStore.unrevoke(content.getCanonicalUri()); Item item = (Item) content; Map<String, ItemOnDemandHierarchy> onDemandHierarchies = onDemandHierarchyExpander.expandHierarchy(item); try { for (Entry<String, ItemOnDemandHierarchy> onDemandHierarchy : onDemandHierarchies.entrySet()) { Task task = createTaskFor(content, Action.DELETE, TVAElementType.ONDEMAND, onDemandHierarchy.getKey()); ItemOnDemandHierarchy hierarchy = onDemandHierarchy.getValue(); JAXBElement<TVAMainType> tvaMain = generator.generateOnDemandTVAFrom(hierarchy, onDemandHierarchy.getKey()); YouViewResult uploadResult = client.upload(tvaMain); processDeletionResult(task, item, uploadResult); } } catch (TvaGenerationException e) { throw Throwables.propagate(e); } }
Source:
private String deletePrefixes(String ref, String... prefixes) { String result = ref; for (String prefix : prefixes) { if (result.startsWith(prefix)) { result = result.substring(prefix.length()); return result; } } return result; }

Target:
private String deletePrefixes(String ref, String... prefixes) { for (String prefix : prefixes) { if (ref.startsWith(prefix)) { return ref.substring(prefix.length()); } } return ref; }
Source:
public int[] downloadRemovedCohortMembershipData(String[] cohortUuids){ int[] result = new int[4]; try { long startDownloadCohortData = System.currentTimeMillis(); List<CohortData> cohortDataList = cohortController.downloadRemovedCohortData(cohortUuids); long endDownloadCohortData = System.currentTimeMillis(); Log.i(getClass().getSimpleName(), "Removed member cohort data download successful with " + cohortDataList.size() + " cohorts"); for (CohortData cohortData : cohortDataList) { cohortController.deleteCohortMembers(cohortData.getCohortMembers()); } long cohortMemberAndPatientReplaceTime = System.currentTimeMillis(); Log.i(getClass().getSimpleName(), "Cohort data deleted"); Log.d(getClass().getSimpleName(), "In Downloading cohort data: " + (endDownloadCohortData - startDownloadCohortData) / 1000 + " sec\n" + "In Deleting cohort members: " + (cohortMemberAndPatientReplaceTime - endDownloadCohortData) / 1000 + " sec"); result[0] = SUCCESS; result[1] = cohortDataList.size(); } catch (CohortController.CohortDownloadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading cohort data.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (CohortController.CohortDeleteException e) { Log.e(getClass().getSimpleName(), "Exception thrown while replacing cohort data.", e); result[0] = SyncStatusConstants.REPLACE_ERROR; } return result; }

Target:
public int[] downloadRemovedCohortMembershipData(String[] cohortUuids){ int[] result = new int[4]; try { List<CohortData> cohortDataList = cohortController.downloadRemovedCohortData(cohortUuids); for (CohortData cohortData : cohortDataList) { cohortController.deleteCohortMembers(cohortData.getCohortMembers()); } result[0] = SUCCESS; result[1] = cohortDataList.size(); } catch (CohortController.CohortDownloadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading cohort data.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (CohortController.CohortDeleteException e) { Log.e(getClass().getSimpleName(), "Exception thrown while replacing cohort data.", e); result[0] = SyncStatusConstants.REPLACE_ERROR; } return result; }
Source:
public static BufferedImage removeAlpha(final BufferedImage inImage) { BufferedImage outImage = inImage; if (inImage.getColorModel().hasAlpha()) { final Stopwatch watch = new Stopwatch(); int newType; switch (inImage.getType()) { case BufferedImage.TYPE_4BYTE_ABGR: newType = BufferedImage.TYPE_INT_BGR; break; default: newType = BufferedImage.TYPE_INT_RGB; break; } outImage = new BufferedImage(inImage.getWidth(), inImage.getHeight(), newType); Graphics2D g = outImage.createGraphics(); try { String bgColor=Configuration.getInstance().getString(FLATTEN_COLOR_CONFIG_KEY); if (bgColor!=null) { g.setBackground(Color.fromString(bgColor)); g.clearRect(0,0,inImage.getWidth(),inImage.getHeight()); } } catch (Exception e) g.drawImage(inImage, 0, 0, null); g.dispose(); logger.debug("removeAlpha(): converted BufferedImage type to " + "RGB in msec", inImage.getType(), watch.timeElapsed()); } return outImage; }

Target:
public static BufferedImage removeAlpha(final BufferedImage inImage) { BufferedImage outImage = inImage; if (inImage.getColorModel().hasAlpha()) { final Stopwatch watch = new Stopwatch(); int newType; switch (inImage.getType()) { case BufferedImage.TYPE_4BYTE_ABGR: newType = BufferedImage.TYPE_INT_BGR; break; default: newType = BufferedImage.TYPE_INT_RGB; break; } outImage = new BufferedImage(inImage.getWidth(), inImage.getHeight(), newType); Graphics2D g = outImage.createGraphics(); String bgColor=Configuration.getInstance().getString(Processor.BACKGROUND_COLOR_CONFIG_KEY); if (bgColor!=null) { g.setBackground(Color.fromString(bgColor)); g.clearRect(0,0,inImage.getWidth(),inImage.getHeight()); } g.drawImage(inImage, 0, 0, null); g.dispose(); logger.debug("removeAlpha(): converted BufferedImage type to " + "RGB in msec", inImage.getType(), watch.timeElapsed()); } return outImage; }
Source:
public void close() { super.close(); final Lock closeLock = receiveCloseLock.writeLock(); closeLock.lock(); try { } finally { closeLock.unlock(); } }

Target:
public void close() { super.close(); final Lock closeLock = receiveCloseLock.writeLock(); closeLock.lock(); closeLock.unlock(); }
Source:
public AuditLogType getAuditLogTypeValue() { return getSucceeded() ? (haMaintenanceFailed ? AuditLogType.HOST_UPGRADE_MANUAL_HA : AuditLogType.HOST_UPGRADE_FINISHED) : AuditLogType.HOST_UPGRADE_FAILED; }

Target:
public AuditLogType getAuditLogTypeValue() { if(getSucceeded()){ return haMaintenanceFailed ? AuditLogType.HOST_UPGRADE_FINISHED_MANUAL_HA : AuditLogType.HOST_UPGRADE_FINISHED; } return AuditLogType.HOST_UPGRADE_FAILED; }
Source:
public void run() { try { if (!pickledGraphite.isConnected()){ log.debug("trying to connect to graphite server"); pickledGraphite.connect(); } while (eventsQueue.size() > 0 && !exec.isShutdown()) { try { final GraphiteEvent graphiteEvent = eventsQueue.poll(DEFAULT_PUT_GET_TIMEOUT, TimeUnit.MILLISECONDS); if (graphiteEvent != null) { log.info("sent [%s] with value [%s] and time [%s]", graphiteEvent.getEventPath(), graphiteEvent.getValue(), graphiteEvent.getTimestamp()); pickledGraphite.send( graphiteEvent.getEventPath(), graphiteEvent.getValue(), graphiteEvent.getTimestamp() ); } } catch (InterruptedException e) { log.error(e, e.getMessage()); } catch (IOException e) { log.error(e, e.getMessage()); } } pickledGraphite.flush(); } catch (Exception e) { log.error(e, e.getMessage()); } }

Target:
public void run() { try { if (!pickledGraphite.isConnected()) { log.info("trying to connect to graphite server"); pickledGraphite.connect(); } while (eventsQueue.size() > 0 && !exec.isShutdown()) { try { final GraphiteEvent graphiteEvent = eventsQueue.poll(DEFAULT_PUT_GET_TIMEOUT, TimeUnit.MILLISECONDS); if (graphiteEvent != null) { log.debug( "sent [%s] with value [%s] and time [%s]", graphiteEvent.getEventPath(), graphiteEvent.getValue(), graphiteEvent.getTimestamp() ); pickledGraphite.send( graphiteEvent.getEventPath(), graphiteEvent.getValue(), graphiteEvent.getTimestamp() ); } } catch (InterruptedException | IOException e) { log.error(e, e.getMessage()); if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } } } pickledGraphite.flush(); } catch (Exception e) { log.error(e, e.getMessage()); if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } } }
Source:
MCCriteria(String crit) { this.criteria = crit; }

Target:
private MCCriteria(String crit) { criteria = crit; }
Source:
public void canRebalanceOnDistributedVolumeWithBricksDown() { GlusterVolumeEntity volumeEntity = getDistributedVolume(volumeId1, 5); volumeEntity.getBricks().get(3).setStatus(GlusterStatus.DOWN); ValidationResult validationResult = brickValidator.canRebalance(volumeEntity); assertFalse(validationResult.isValid()); volumeEntity.getBricks().get(4).setStatus(GlusterStatus.DOWN); assertFalse(validationResult.isValid()); volumeEntity.getBricks().get(3).setStatus(GlusterStatus.UP); assertFalse(validationResult.isValid()); }

Target:
public void canRebalanceOnDistributedVolumeWithBricksDown() { GlusterVolumeEntity volumeEntity = getDistributedVolume(volumeId1, 5); volumeEntity.getBricks().get(3).setStatus(GlusterStatus.DOWN); ValidationResult validationResult = brickValidator.canRebalance(volumeEntity); assertFalse(validationResult.isValid()); volumeEntity.getBricks().get(4).setStatus(GlusterStatus.DOWN); validationResult = brickValidator.canRebalance(volumeEntity); assertFalse(validationResult.isValid()); volumeEntity.getBricks().get(3).setStatus(GlusterStatus.UP); validationResult = brickValidator.canRebalance(volumeEntity); assertFalse(validationResult.isValid()); }
Source:
public OutputStream createFile(final Path path, final FileSystem.Statistics statistics, final boolean overwrite, final FsPermission permission, final FsPermission umask) throws AzureBlobFileSystemException { try (AbfsPerfInfo perfInfo = startTracking("createFile", "createPath")) { boolean isNamespaceEnabled = getIsNamespaceEnabled(); LOG.debug("createFile filesystem: path: overwrite: permission: umask: isNamespaceEnabled: {}", client.getFileSystem(), path, overwrite, permission.toString(), umask.toString(), isNamespaceEnabled); boolean appendBlob = false; if (isAppendBlobKey(path.toString())) { appendBlob = true; } client.createPath(AbfsHttpConstants.FORWARD_SLASH + getRelativePath(path), true, overwrite, isNamespaceEnabled ? getOctalNotation(permission) : null, isNamespaceEnabled ? getOctalNotation(umask) : null, appendBlob); return new AbfsOutputStream( client, statistics, AbfsHttpConstants.FORWARD_SLASH + getRelativePath(path), 0, abfsConfiguration.getWriteBufferSize(), abfsConfiguration.isFlushEnabled(), abfsConfiguration.isOutputStreamFlushDisabled(), abfsConfiguration.isAppendWithFlushEnabled(), appendBlob); } }

Target:
public OutputStream createFile(final Path path, final FileSystem.Statistics statistics, final boolean overwrite, final FsPermission permission, final FsPermission umask) throws AzureBlobFileSystemException { try (AbfsPerfInfo perfInfo = startTracking("createFile", "createPath")) { boolean isNamespaceEnabled = getIsNamespaceEnabled(); LOG.debug("createFile filesystem: path: overwrite: permission: umask: isNamespaceEnabled: {}", client.getFileSystem(), path, overwrite, permission.toString(), umask.toString(), isNamespaceEnabled); boolean isAppendBlob = false; if (isAppendBlobKey(path.toString())) { isAppendBlob = true; } final AbfsRestOperation op = client.createPath(AbfsHttpConstants.FORWARD_SLASH + getRelativePath(path), true, overwrite, isNamespaceEnabled ? getOctalNotation(permission) : null, isNamespaceEnabled ? getOctalNotation(umask) : null, isAppendBlob); perfInfo.registerResult(op.getResult()).registerSuccess(true); return new AbfsOutputStream( client, statistics, AbfsHttpConstants.FORWARD_SLASH + getRelativePath(path), 0, populateAbfsOutputStreamContext(isAppendBlob)); } }
Source:
private Registration getAndSetRegistration(final HttpServletRequest request) { String registrationOID = (String) request.getAttribute("registrationOID"); if (StringUtils.isEmpty(registrationOID)) { registrationOID = request.getParameter("registrationOID"); } final Registration registration = FenixFramework.getDomainObject(registrationOID); if (!getUserView(request).getPerson().getStudent().getAllRegistrations().contains(registration)) { return null; } request.setAttribute("registration", registration); request.setAttribute("registrationOID", registration.getExternalId().toString()); return registration; }

Target:
private Registration getAndSetRegistration(final HttpServletRequest request) { String registrationOID = (String) request.getAttribute("registrationOID"); if (StringUtils.isEmpty(registrationOID)) { registrationOID = request.getParameter("registrationOID"); } final Registration registration = FenixFramework.getDomainObject(registrationOID); if (!getUserView(request).getPerson().getStudent().getRegistrationStream().anyMatch(r -> r.equals(registration))) { return null; } request.setAttribute("registration", registration); request.setAttribute("registrationOID", registration.getExternalId().toString()); return registration; }
Source:
public void testPersistedJobGraphWhenDispatcherIsShutDown() throws Exception { final TestingJobGraphStore submittedJobGraphStore = TestingJobGraphStore.newBuilder().build(); submittedJobGraphStore.start(null); haServices.setJobGraphStore(submittedJobGraphStore); dispatcher = new TestingDispatcherBuilder() .setJobGraphWriter(submittedJobGraphStore) .build(); dispatcher.start(); jobMasterLeaderElectionService.isLeader(UUID.randomUUID()); final DispatcherGateway dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class); dispatcherGateway.submitJob(jobGraph, TIMEOUT).get(); CommonTestUtils.waitUntilJobManagerIsInitialized(() -> dispatcherGateway.requestJobStatus(jobGraph.getJobID(), TIMEOUT).get()); assertThat(dispatcher.getNumberJobs(TIMEOUT).get(), Matchers.is(1)); dispatcher.close(); assertThat(submittedJobGraphStore.contains(jobGraph.getJobID()), Matchers.is(true)); }

Target:
public void testPersistedJobGraphWhenDispatcherIsShutDown() throws Exception { final TestingJobGraphStore submittedJobGraphStore = TestingJobGraphStore.newBuilder().build(); submittedJobGraphStore.start(null); haServices.setJobGraphStore(submittedJobGraphStore); dispatcher = new TestingDispatcherBuilder() .setJobGraphWriter(submittedJobGraphStore) .build(); dispatcher.start(); final DispatcherGateway dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class); dispatcherGateway.submitJob(jobGraph, TIMEOUT).get(); assertThat(dispatcher.getNumberJobs(TIMEOUT).get(), Matchers.is(1)); dispatcher.close(); assertThat(submittedJobGraphStore.contains(jobGraph.getJobID()), Matchers.is(true)); }
Source:
GoCounting (String boardString) { String[] lines = boardString.split("\n"); board = new int[lines[0].length()][lines.length]; for(int i = 0; i < lines.length; i++) { for(int j = 0; j < lines[i].length(); j++) { if(lines[i].charAt(j) == 'B') { board[j][i] = BLACK; } else if(lines[i].charAt(j) == 'W') { board[j][i] = WHITE; } else { board[j][i] = NONE; } } } }

Target:
GoCounting (String boardString) { String[] lines = boardString.split("\n"); board = new Player[lines[0].length()][lines.length]; for (int i = 0; i < lines.length; i++) { for (int j = 0; j < lines[i].length(); j++) { if (lines[i].charAt(j) == 'B') { board[j][i] = Player.BLACK; } else if (lines[i].charAt(j) == 'W') { board[j][i] = Player.WHITE; } else { board[j][i] = Player.NONE; } } } }
Source:
public void testLocallyRecursiveImport() { String type = "workflow"; File recursiveWDL = new File(ResourceHelpers.resourceFilePath("local-recursive-import/localrecursive.wdl")); String primaryDescriptorFilePath = "localrecursive.wdl"; SourceFile sourceFile = new SourceFile(); File recursiveimportWDL = new File(ResourceHelpers.resourceFilePath("local-recursive-import/first-import.wdl")); SourceFile importsourceFile = new SourceFile(); try { sourceFile.setContent(FileUtils.readFileToString(recursiveWDL, StandardCharsets.UTF_8)); sourceFile.setAbsolutePath("/localrecursive.wdl"); sourceFile.setPath("localrecursive.wdl"); sourceFile.setType(DescriptorLanguage.FileType.DOCKSTORE_WDL); importsourceFile.setContent(FileUtils.readFileToString(recursiveimportWDL, StandardCharsets.UTF_8)); importsourceFile.setAbsolutePath("/first-import.wdl"); importsourceFile.setPath("first-import.wdl"); importsourceFile.setType(DescriptorLanguage.FileType.DOCKSTORE_WDL); Set<SourceFile> sourceFileSet = new HashSet<>(); sourceFileSet.add(sourceFile); sourceFileSet.add(importsourceFile); WDLHandler wdlHandler = new WDLHandler(); VersionTypeValidation validation = wdlHandler.validateEntrySet(sourceFileSet, primaryDescriptorFilePath, type); Assert.assertFalse(validation.isValid()); Optional<Map.Entry<String, String>> validationEntryMap = validation.getMessage().entrySet().stream() .filter(msg -> StringUtils.contains(msg.getValue(), "Recursive local import detected")).findAny(); Assert.assertTrue(validationEntryMap.isPresent()); } catch (IOException e) { Assert.fail(); } }

Target:
public void testLocallyRecursiveImport() { String type = "workflow"; File recursiveWDL = new File(ResourceHelpers.resourceFilePath("local-recursive-import/localrecursive.wdl")); String primaryDescriptorFilePath = "localrecursive.wdl"; SourceFile sourceFile = new SourceFile(); File recursiveimportWDL = new File(ResourceHelpers.resourceFilePath("local-recursive-import/first-import.wdl")); SourceFile importsourceFile = new SourceFile(); try { sourceFile.setContent(FileUtils.readFileToString(recursiveWDL, StandardCharsets.UTF_8)); sourceFile.setAbsolutePath("/localrecursive.wdl"); sourceFile.setPath("localrecursive.wdl"); sourceFile.setType(DescriptorLanguage.FileType.DOCKSTORE_WDL); importsourceFile.setContent(FileUtils.readFileToString(recursiveimportWDL, StandardCharsets.UTF_8)); importsourceFile.setAbsolutePath("/first-import.wdl"); importsourceFile.setPath("first-import.wdl"); importsourceFile.setType(DescriptorLanguage.FileType.DOCKSTORE_WDL); Set<SourceFile> sourceFileSet = new HashSet<>(); sourceFileSet.add(sourceFile); sourceFileSet.add(importsourceFile); WDLHandler wdlHandler = new WDLHandler(); VersionTypeValidation validation = wdlHandler.validateEntrySet(sourceFileSet, primaryDescriptorFilePath, type); assertFalse(validation.isValid()); assertTrue(validation.getMessage().values().stream() .anyMatch(msg -> StringUtils.contains(msg, ERROR_PARSING_WORKFLOW_RECURSIVE_LOCAL_IMPORT))); } catch (IOException e) { Assert.fail(); } }
Source:
public void subscribeActual(Subscriber<? super R> s) { Publisher<? extends T>[] a = array; int n; if (a == null) { assert iterable != null; n = 0; a = new Publisher[8]; Iterator<? extends Publisher<? extends T>> it; try { it = ObjectHelper.requireNonNull(iterable.iterator(), "The iterator returned is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); return; } for (;;) { boolean b; try { b = it.hasNext(); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); return; } if (!b) { break; } Publisher<? extends T> p; try { p = ObjectHelper.requireNonNull(it.next(), "The publisher returned by the iterator is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); return; } if (n == a.length) { Publisher<? extends T>[] c = new Publisher[n + (n >> 2)]; System.arraycopy(a, 0, c, 0, n); a = c; } a[n++] = p; } } else { n = a.length; } if (n == 0) { EmptySubscription.complete(s); return; } if (n == 1) { new FlowableMap<T, R>((Publisher<T>)a[0], new Function<T, R>() { @Override public R apply(T t) throws Exception { return combiner.apply(new Object[] { t }); } }).subscribe(s); return; } CombineLatestCoordinator<T, R> coordinator = new CombineLatestCoordinator<T, R>(s, combiner, n, bufferSize, delayErrors); s.onSubscribe(coordinator); coordinator.subscribe(a, n); }

Target:
public void subscribeActual(Subscriber<? super R> s) { Publisher<? extends T>[] a = array; int n; if (a == null) { n = 0; a = new Publisher[8]; Iterator<? extends Publisher<? extends T>> it; try { it = ObjectHelper.requireNonNull(iterable.iterator(), "The iterator returned is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); return; } for (;;) { boolean b; try { b = it.hasNext(); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); return; } if (!b) { break; } Publisher<? extends T> p; try { p = ObjectHelper.requireNonNull(it.next(), "The publisher returned by the iterator is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); return; } if (n == a.length) { Publisher<? extends T>[] c = new Publisher[n + (n >> 2)]; System.arraycopy(a, 0, c, 0, n); a = c; } a[n++] = p; } } else { n = a.length; } if (n == 0) { EmptySubscription.complete(s); return; } if (n == 1) { new FlowableMap<T, R>((Publisher<T>)a[0], new Function<T, R>() { @Override public R apply(T t) throws Exception { return combiner.apply(new Object[] { t }); } }).subscribe(s); return; } CombineLatestCoordinator<T, R> coordinator = new CombineLatestCoordinator<T, R>(s, combiner, n, bufferSize, delayErrors); s.onSubscribe(coordinator); coordinator.subscribe(a, n); }
Source:
public void configure(final Config conf) { this.timeout = ConfUtils.getInt(conf, "http.timeout", 10000); this.proxyHost = ConfUtils.getString(conf, "http.proxy.host", null); this.proxyPort = ConfUtils.getInt(conf, "http.proxy.port", 8080); this.useProxy = (proxyHost != null && proxyHost.length() > 0); this.maxContent = ConfUtils.getInt(conf, "http.content.limit", 64 * 1024); this.userAgent = getAgentString( ConfUtils.getString(conf, "http.agent.name"), ConfUtils.getString(conf, "http.agent.version"), ConfUtils.getString(conf, "http.agent.description"), ConfUtils.getString(conf, "http.agent.url"), ConfUtils.getString(conf, "http.agent.email")); this.responseTime = ConfUtils.getBoolean(conf, "http.store.responsetime", true); this.skipRobots = ConfUtils.getBoolean(conf, "http.skip.robots", false); robots = new HttpRobotRulesParser(conf); }

Target:
public void configure(final Config conf) { this.maxContent = ConfUtils.getInt(conf, "http.content.limit", 64 * 1024); String userAgent = getAgentString( ConfUtils.getString(conf, "http.agent.name"), ConfUtils.getString(conf, "http.agent.version"), ConfUtils.getString(conf, "http.agent.description"), ConfUtils.getString(conf, "http.agent.url"), ConfUtils.getString(conf, "http.agent.email")); this.responseTime = ConfUtils.getBoolean(conf, "http.store.responsetime", true); this.skipRobots = ConfUtils.getBoolean(conf, "http.skip.robots", false); robots = new HttpRobotRulesParser(conf); builder = HttpClients.custom().setUserAgent(userAgent) .setConnectionManager(CONNECTION_MANAGER); String proxyHost = ConfUtils.getString(conf, "http.proxy.host", null); int proxyPort = ConfUtils.getInt(conf, "http.proxy.port", 8080); boolean useProxy = (proxyHost != null && proxyHost.length() > 0); if (useProxy) { HttpHost proxy = new HttpHost(proxyHost, proxyPort); DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner( proxy); builder.setRoutePlanner(routePlanner); } int timeout = ConfUtils.getInt(conf, "http.timeout", 10000); requestConfig = RequestConfig.custom().setSocketTimeout(timeout) .setConnectTimeout(timeout).build(); }
Source:
protected String getAuthorizationBaseUrl() { return PROTOCOL + hostName + AUTHORIZE_URL; }

Target:
protected String getAuthorizationBaseUrl() { return authorizationBaseUrl; }
Source:
private void traverseClass(Node n, Node parent) { Preconditions.checkState(n.getChildCount() == 3, n); Preconditions.checkState(n.isClass()); final Node className = n.getFirstChild(); boolean isClassExpression = (parent != null) && NodeUtil.isClassExpression(n); if (!isClassExpression) { traverseBranch(className, n); } curNode = n; pushScope(n); if (isClassExpression) { traverseBranch(className, n); } final Node extendsClause = className.getNext(); final Node body = extendsClause.getNext(); traverseBranch(extendsClause, n); traverseBranch(body, n); popScope(); }

Target:
private void traverseClass(Node n, Node parent) { Preconditions.checkState(n.getChildCount() == 3, n); Preconditions.checkState(n.isClass()); final Node className = n.getFirstChild(); boolean isClassExpression = NodeUtil.isClassExpression(n); if (!isClassExpression) { traverseBranch(className, n); } curNode = n; pushScope(n); if (isClassExpression) { traverseBranch(className, n); } final Node extendsClause = className.getNext(); final Node body = extendsClause.getNext(); traverseBranch(extendsClause, n); traverseBranch(body, n); popScope(); }
Source:
protected void addChallenge(Challenge challenge) { if (challenge == null) { throw new IllegalArgumentException("challenge not valid"); } if (challenges == null) { challenges = new ArrayList<>(); } challenges.add(challenge); }

Target:
protected void addChallenge(Challenge challenge) { if (challenges == null) { challenges = new ArrayList<>(); } challenges.add(challenge); }
Source:
public void process(Element elm, JID actorJID, IQ reqIQ, Element rsm) throws Exception { response = IQ.createResultIQ(reqIQ); request = reqIQ; actor = actorJID; node = request.getChildElement().element("affiliations").attributeValue(XMLConstants.NODE_ATTR); if (!Configuration.getInstance().isLocalJID(request.getFrom())) { response.getElement().addAttribute(XMLConstants.REMOTE_SERVER_DISCOVER_ATTR, Boolean.FALSE.toString()); } String namespace = JabberPubsub.NAMESPACE_URI; if (node == null) { namespace = JabberPubsub.NS_PUBSUB_OWNER; } Element pubsub = response.setChildElement(XMLConstants.PUBSUB_ELEM, namespace); Element affiliations = pubsub.addElement(XMLConstants.AFFILIATIONS_ELEM); if (actor == null) { actor = request.getFrom(); } boolean isProcessedLocally = true; if (node == null) { isProcessedLocally = getUserMemberships(affiliations); } else { isProcessedLocally = getNodeAffiliations(affiliations); } if (!isProcessedLocally) { return; } outQueue.put(response); }

Target:
public void process(Element elm, JID actorJID, IQ reqIQ, Element rsm) throws Exception { response = IQ.createResultIQ(reqIQ); request = reqIQ; actor = actorJID; node = request.getChildElement().element("affiliations").attributeValue(XMLConstants.NODE_ATTR); if (!Configuration.getInstance().isLocalJID(request.getFrom())) { response.getElement().addAttribute(XMLConstants.REMOTE_SERVER_DISCOVER_ATTR, Boolean.FALSE.toString()); } String namespace = JabberPubsub.NAMESPACE_URI; if (node == null) { namespace = JabberPubsub.NS_PUBSUB_OWNER; } Element pubsub = response.setChildElement(XMLConstants.PUBSUB_ELEM, namespace); Element affiliations = pubsub.addElement(XMLConstants.AFFILIATIONS_ELEM); if (actor == null) { actor = request.getFrom(); } boolean isProcessedLocally = (node == null) ? getUserMemberships(affiliations) : getNodeAffiliations(affiliations); if (!isProcessedLocally) { return; } outQueue.put(response); }
Source:
public int compare(Slice slice1, Slice slice2) { int thisMarker = 0; int thatMarker = 0; String s1 = slice1.getSequence(); String s2 = slice2.getSequence(); int s1Length = s1.length(); int s2Length = s2.length(); while (thisMarker < s1Length && thatMarker < s2Length) { String thisChunk = getChunk(s1, s1Length, thisMarker); thisMarker += thisChunk.length(); String thatChunk = getChunk(s2, s2Length, thatMarker); thatMarker += thatChunk.length(); int result = 0; if (isDigit(thisChunk.charAt(0)) && isDigit(thatChunk.charAt(0))) { int thisChunkLength = thisChunk.length(); result = thisChunkLength - thatChunk.length(); if (result == 0) { for (int i = 0; i < thisChunkLength; i++) { result = thisChunk.charAt(i) - thatChunk.charAt(i); if (result != 0) { return result; } } } } else { result = thisChunk.compareTo(thatChunk); } if (result != 0) return result; } return s1Length - s2Length; }

Target:
public int compare(Slice slice1, Slice slice2) { int thisMarker = 0; int thatMarker = 0; String s1 = slice1.getSequence(); String s2 = slice2.getSequence(); int s1Length = s1.length(); int s2Length = s2.length(); while ((thisMarker < s1Length) && (thatMarker < s2Length)) { String thisChunk = getChunk(s1, s1Length, thisMarker); thisMarker += thisChunk.length(); String thatChunk = getChunk(s2, s2Length, thatMarker); thatMarker += thatChunk.length(); int result = 0; if (isDigit(thisChunk.charAt(0)) && isDigit(thatChunk.charAt(0))) { int thisChunkLength = thisChunk.length(); result = thisChunkLength - thatChunk.length(); if (result == 0) { for (int i = 0; i < thisChunkLength; i++) { result = thisChunk.charAt(i) - thatChunk.charAt(i); if (result != 0) { return result; } } } } else { result = thisChunk.compareTo(thatChunk); } if (result != 0) { return result; } } return s1Length - s2Length; }
Source:
public SshKeyInfo apply(SshKey rsrc) { SshKeyInfo info = new SshKeyInfo(); AccountSshKey sshKey = rsrc.getSshKey(); info.id = sshKey.getKey().get(); info.sshPublicKey = sshKey.getSshPublicKey(); info.encodedKey = sshKey.getEncodedKey(); info.algorithm = sshKey.getAlgorithm(); info.comment = Strings.emptyToNull(sshKey.getComment()); info.valid = sshKey.isValid(); return info; }

Target:
public SshKeyInfo apply(SshKey rsrc) { return new SshKeyInfo(rsrc.getSshKey()); }
Source:
protected FormGroup getFormGroup(RenderMode renderMode) { FormRenderingContext nestedContext = renderingContext.getCopyFor(field.getNestedForm(), null); if (field.getReadOnly()) { nestedContext.setRenderMode(RenderMode.READ_ONLY_MODE); } subFormWidget.render(nestedContext); AbstractNestedFormFormGroup formGroup; if(Container.COLLAPSIBLE.equals(field.getContainer())) { formGroup = formGroupsInstance.select(CollapseFormGroup.class).get(); } else { formGroup = formGroupsInstance.select(FieldSetFormGroup.class).get(); } formGroup.render(subFormWidget, field); return formGroup; }

Target:
protected FormGroup getFormGroup(RenderMode renderMode) { FormRenderingContext nestedContext = renderingContext.getCopyFor(field.getNestedForm(), null); if (field.getReadOnly()) { nestedContext.setRenderMode(RenderMode.READ_ONLY_MODE); } subFormWidget.render(nestedContext); AbstractNestedFormFormGroup formGroup; if (Container.COLLAPSIBLE.equals(field.getContainer())) { formGroup = formGroupsInstance.select(CollapsibleFormGroup.class).get(); } else { formGroup = formGroupsInstance.select(FieldSetFormGroup.class).get(); } formGroup.render(subFormWidget, field); return formGroup; }
Source:
public void testHeaders1() throws Exception { BitcoinSerializer bs = new BitcoinSerializer(MainNetParams.get()); String headersMessageBytesHex = "f9beb4d9686561" + "646572730000000000520000005d4fab8101010000006fe28c0ab6f1b372c1a6a246ae6" + "3f74f931e8365e15a089c68d6190000000000982051fd1e4ba744bbbe680e1fee14677b" + "a1a3c3540bf7b1cdb606e857233e0e61bc6649ffff001d01e3629900"; byte[] headersMessageBytes = HEX.decode(headersMessageBytesHex); HeadersMessage hm = (HeadersMessage) bs.deserialize(ByteBuffer.wrap(HEX.decode(headersMessageBytesHex))); Block block = hm.getBlockHeaders().get(0); String hash = block.getHashAsString(); assertEquals(hash, "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048"); assertNull(block.transactions); assertEquals(Utils.HEX.encode(block.getMerkleRoot().getBytes()), "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098"); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bs.serialize(hm, byteArrayOutputStream); byte[] serializedBytes = byteArrayOutputStream.toByteArray(); String serializedBytesHex = new String(HEX.encode(serializedBytes)); assertEquals(headersMessageBytes.length, serializedBytes.length); assertEquals(true, Arrays.equals(headersMessageBytes, serializedBytes)); }

Target:
public void testHeaders1() throws Exception { BitcoinSerializer bs = new BitcoinSerializer(MainNetParams.get()); String headersMessageBytesHex = "f9beb4d9686561" + "646572730000000000520000005d4fab8101010000006fe28c0ab6f1b372c1a6a246ae6" + "3f74f931e8365e15a089c68d6190000000000982051fd1e4ba744bbbe680e1fee14677b" + "a1a3c3540bf7b1cdb606e857233e0e61bc6649ffff001d01e3629900"; byte[] headersMessageBytes = HEX.decode(headersMessageBytesHex); HeadersMessage hm = (HeadersMessage) bs.deserialize(ByteBuffer.wrap(headersMessageBytes)); Block block = hm.getBlockHeaders().get(0); String hash = block.getHashAsString(); assertEquals(hash, "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048"); assertNull(block.transactions); assertEquals(Utils.HEX.encode(block.getMerkleRoot().getBytes()), "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098"); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bs.serialize(hm, byteArrayOutputStream); byte[] serializedBytes = byteArrayOutputStream.toByteArray(); String serializedBytesHex = new String(HEX.encode(serializedBytes)); assertEquals(headersMessageBytes.length, serializedBytes.length); assertEquals(true, Arrays.equals(headersMessageBytes, serializedBytes)); }