auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public long cyclesToNanos(long cycles) { CTFTrace trace = fTrace; if (trace != null) { CTFClock clock = trace.getClock(); return trace.timestampCyclesToNanos(cycles - trace.getOffset()) + clock.getClockOffsetNs(); } return 0; }

Target:
public long cyclesToNanos(long cycles) { CTFTrace trace = fTrace; if (trace != null) { return trace.timestampCyclesToNanos(cycles - trace.getOffset()); } return 0; }
Source:
private void initializeShallowCommits() throws IOException { if (shallowCommitsInitialized) return; shallowCommitsInitialized = true; for (ObjectId id : reader.getShallowCommits()) { final RevCommit commit = lookupCommit(id); commit.parents = new RevCommit[0]; } }

Target:
void initializeShallowCommits() throws IOException { if (shallowCommitsInitialized) throw new IllegalStateException(JGitText.get().outputHasAlreadyBeenStarted); shallowCommitsInitialized = true; for (ObjectId id : reader.getShallowCommits()) lookupCommit(id).parents = RevCommit.NO_PARENTS; }
Source:
private void interruptAndWaitCleanupTime() { threadToKill.interrupt(); int iterationsToHitWaitingTimeLimit = CLEANUP_SECONDS_AFTER_FIRST_INTERRUPT * 100; for(int i = 0; threadToKill.isAlive() && i < iterationsToHitWaitingTimeLimit ; i++ ) { try { Thread.sleep(10); } catch (InterruptedException e) { } } }

Target:
private void interruptAndWaitCleanupTime() { threadToKill.interrupt(); int iterationsToHitWaitingTimeLimit = SECONDS_TO_WAIT_UNTIL_AGGRESSIVELY_INTERRUPT_TASK * THREAD_INTERRUPT_SLEEP_TO_SECONDS_MULTIPLIER; for (int i = 0; threadToKill.isAlive() && i < iterationsToHitWaitingTimeLimit; i++) { threadInterruptSleeper.sleep(); } }
Source:
DialogueFeignClient(Class<?> jaxrsInterface, Channel channel, ConjureRuntime runtime, String baseUrl) { this.channel = Preconditions.checkNotNull(channel, "Channel is required"); this.serviceName = jaxrsInterface.getSimpleName(); this.version = Optional.ofNullable(jaxrsInterface.getPackage().getImplementationVersion()) .orElse("0.0.0"); this.baseUrl = baseUrl; this.clients = runtime.clients(); }

Target:
DialogueFeignClient(Class<?> jaxrsInterface, Channel channel, ConjureRuntime runtime, String baseUrl) { this.channel = Preconditions.checkNotNull(channel, "Channel is required"); this.baseUrl = Preconditions.checkNotNull(baseUrl, "Base URL is required"); this.runtime = Preconditions.checkNotNull(runtime, "ConjureRuntime is required"); this.serviceName = Preconditions.checkNotNull(jaxrsInterface, "Service is required") .getSimpleName(); this.version = Optional.ofNullable(jaxrsInterface.getPackage().getImplementationVersion()) .orElse("0.0.0"); }
Source:
private float getCharcoalAmount(World world, BlockPos pos) { float charcoalAmount = 0F; for (EnumFacing facing : EnumFacing.VALUES) { charcoalAmount += getCharcoalFaceAmount(world, pos, facing); } float ret = charcoalAmount / 6; if (ret > 0F) { ret += 9F; } return ret; }

Target:
private float getCharcoalAmount(World world, BlockPos pos) { float charcoalAmount = 0F; for (EnumFacing facing : EnumFacing.VALUES) { charcoalAmount += getCharcoalFaceAmount(world, pos, facing); } return Math.min(charcoalAmount / 6, 15.0F); }
Source:
private int instrumentZip(final InputStream input, final OutputStream output, final String name) throws IOException { if (generators.getLast() instanceof OfflineInstrumentationCompanionAccessGenerator) { generators .addLast(new OfflineInstrumentationCompanionAccessGenerator()); } final ZipInputStream zipin = new ZipInputStream(input); final ZipOutputStream zipout = new ZipOutputStream(output); ZipEntry entry; int count = 0; while ((entry = zipin.getNextEntry()) != null) { final String entryName = entry.getName(); if (signatureRemover.removeEntry(entryName)) { continue; } zipout.putNextEntry(new ZipEntry(entryName)); if (!signatureRemover.filterEntry(entryName, zipin, zipout)) { count += instrumentAll(zipin, zipout, name + "@" + entryName); } zipout.closeEntry(); } if (generators.getLast() instanceof OfflineInstrumentationCompanionAccessGenerator) { OfflineInstrumentationCompanionAccessGenerator companionGenerator = (OfflineInstrumentationCompanionAccessGenerator) generators .getLast(); if (companionGenerator.getNumberOfInstrumentedClasses() != 0) { zipout.putNextEntry( new ZipEntry(companionGenerator.getClassName() + ".class")); zipout.write(companionGenerator.getClassDefinition()); zipout.closeEntry(); } generators.removeLast(); } zipout.finish(); return count; }

Target:
private int instrumentZip(final InputStream input, final OutputStream output, final String name) throws IOException { final ZipInputStream zipin = new ZipInputStream(input); final ZipOutputStream zipout = new ZipOutputStream(output); if (generators .getLast() instanceof OfflineInstrumentationCompanionAccessGenerator) { generators .addLast(new OfflineInstrumentationCompanionAccessGenerator( new IClassFileWriter() { public void write(final String name, final byte[] bytes) { try { zipout.putNextEntry(new ZipEntry(name)); zipout.write(bytes); zipout.closeEntry(); } catch (IOException e) { throw new RuntimeException(e); } } })); } ZipEntry entry; int count = 0; while ((entry = zipin.getNextEntry()) != null) { final String entryName = entry.getName(); if (signatureRemover.removeEntry(entryName)) { continue; } zipout.putNextEntry(new ZipEntry(entryName)); if (!signatureRemover.filterEntry(entryName, zipin, zipout)) { count += instrumentAll(zipin, zipout, name + "@" + entryName); } zipout.closeEntry(); } if (generators.getLast() instanceof OfflineInstrumentationCompanionAccessGenerator) { OfflineInstrumentationCompanionAccessGenerator companionGenerator = (OfflineInstrumentationCompanionAccessGenerator) generators .getLast(); companionGenerator.end(); generators.removeLast(); } zipout.finish(); return count; }
Source:
public User initializeUser(final Integer userId) { final User user = new User(); final Person person = new Person(); person.setId(2); person.setFirstName("Diego"); person.setMiddleName(""); person.setLastName("Cuenya"); person.setEmail("diego.cuenya@leafnode.io"); person.setTitle("-"); person.setContact("-"); person.setExtension("-"); person.setFax("-"); person.setInstituteId(0); person.setLanguage(0); person.setNotes("-"); person.setPositionName("-"); person.setPhone("-"); user.setPerson(person); user.setPersonid(person.getId()); user.setPerson(person); user.setName("Cuenyad"); user.setAccess(0); user.setInstalid(0); user.setType(0); return user; }

Target:
public User initializeUser(final Integer userId) { final User user = new User(); final Person person = new Person(); person.setId(2); final String firstName = RandomStringUtils.randomAlphanumeric(20); person.setFirstName(firstName); person.setMiddleName(""); final String lastName = RandomStringUtils.randomAlphanumeric(50); person.setLastName(lastName); final String email = RandomStringUtils.randomAlphanumeric(24); person.setEmail("test" + email + "@leafnode.io"); person.setTitle("-"); person.setContact("-"); person.setExtension("-"); person.setFax("-"); person.setInstituteId(0); person.setLanguage(0); person.setNotes("-"); person.setPositionName("-"); person.setPhone("-"); user.setPerson(person); user.setPersonid(person.getId()); user.setPerson(person); final String username = RandomStringUtils.randomAlphanumeric(30); user.setName(username); user.setAccess(0); user.setInstalid(0); user.setType(0); return user; }
Source:
public void transform(StructuredRecord input, Emitter<StructuredRecord> emitter) { try { engine.eval(String.format("var %s = %s;", VARIABLE_NAME, GSON.toJson(input))); Emitter<Map> jsEmitter = new JSEmitter(emitter, schema == null ? input.getSchema() : schema, getContext().getFailureCollector()); engine.put(EMITTER_NAME, jsEmitter); invocable.invokeFunction(FUNCTION_NAME); } catch (Exception e) { throw new IllegalArgumentException("Could not transform input: " + e.getMessage(), e); } }

Target:
public void transform(StructuredRecord input, Emitter<StructuredRecord> emitter) { try { engine.eval(String.format("var %s = %s;", VARIABLE_NAME, GSON.toJson(input))); Emitter<Map> jsEmitter = new JSEmitter(emitter, schema == null ? input.getSchema() : schema); engine.put(EMITTER_NAME, jsEmitter); invocable.invokeFunction(FUNCTION_NAME); } catch (Exception e) { throw new IllegalArgumentException("Could not transform input: " + e.getMessage(), e); } }
Source:
protected String determineBranchName(@NotNull Map<String, String> env) throws GitCommitIdExecutionException { if (!BuildServerDataProvider.checkBuildEnvironmentForType(env).equals(BuildEnvironmentType.UNKNOWN)) { String branchName = BuildServerDataProvider.getBuildServerProvider(env,log).getBuildBranch(env,log); if (isNullOrEmpty(branchName)) { log.info("Detected that running on CI environment, but using repository branch, no GIT_BRANCH detected."); return getBranchName(); } return branchName; } else { return getBranchName(); } }

Target:
protected String determineBranchName(@NotNull Map<String, String> env) throws GitCommitIdExecutionException { BuildServerDataProvider buildServerDataProvider = BuildServerDataProvider.getBuildServerProvider(env,log); if (!(buildServerDataProvider instanceof UnknownBuildServerData)) { String branchName = buildServerDataProvider.getBuildBranch(); if (isNullOrEmpty(branchName)) { log.info("Detected that running on CI environment, but using repository branch, no GIT_BRANCH detected."); return getBranchName(); } return branchName; } else { return getBranchName(); } }
Source:
public void initialise() { addDesiredStateChange(new SetViewportToSizeOf(WRITEONLY_GBUFFER, displayResolutionDependentFBOs)); addDesiredStateChange(new BindFBO(WRITEONLY_GBUFFER, displayResolutionDependentFBOs)); update(); addDesiredStateChange(new EnableMaterial(DEFERRED_LIGHTING_MATERIAL.toString())); int textureSlot = 0; addDesiredStateChange(new SetInputTextureFromFBO( textureSlot++, READONLY_GBUFFER, SetInputTextureFromFBO.FboTexturesTypes.ColorTexture, displayResolutionDependentFBOs, DEFERRED_LIGHTING_MATERIAL, "texSceneOpaque")); addDesiredStateChange(new SetInputTextureFromFBO( textureSlot++, READONLY_GBUFFER, SetInputTextureFromFBO.FboTexturesTypes.DepthStencilTexture, displayResolutionDependentFBOs, DEFERRED_LIGHTING_MATERIAL, "texSceneOpaqueDepth")); addDesiredStateChange(new SetInputTextureFromFBO( textureSlot++, READONLY_GBUFFER, SetInputTextureFromFBO.FboTexturesTypes.NormalsTexture, displayResolutionDependentFBOs, DEFERRED_LIGHTING_MATERIAL, "texSceneOpaqueNormals")); addDesiredStateChange(new SetInputTextureFromFBO( textureSlot, READONLY_GBUFFER, SetInputTextureFromFBO.FboTexturesTypes.LightAccumulationTexture, displayResolutionDependentFBOs, DEFERRED_LIGHTING_MATERIAL, "texSceneOpaqueLightBuffer")); displayResolutionDependentFBOs.subscribe(this); }

Target:
public void initialise() { addDesiredStateChange(new BindFBO(WRITEONLY_GBUFFER, displayResolutionDependentFBOs)); update(); displayResolutionDependentFBOs.subscribe(this); addDesiredStateChange(new EnableMaterial(DEFERRED_LIGHTING_MATERIAL.toString())); int textureSlot = 0; addDesiredStateChange(new SetInputTextureFromFBO( textureSlot++, READONLY_GBUFFER, ColorTexture, displayResolutionDependentFBOs, DEFERRED_LIGHTING_MATERIAL, "texSceneOpaque")); addDesiredStateChange(new SetInputTextureFromFBO( textureSlot++, READONLY_GBUFFER, DepthStencilTexture, displayResolutionDependentFBOs, DEFERRED_LIGHTING_MATERIAL, "texSceneOpaqueDepth")); addDesiredStateChange(new SetInputTextureFromFBO( textureSlot++, READONLY_GBUFFER, NormalsTexture, displayResolutionDependentFBOs, DEFERRED_LIGHTING_MATERIAL, "texSceneOpaqueNormals")); addDesiredStateChange(new SetInputTextureFromFBO( textureSlot, READONLY_GBUFFER, LightAccumulationTexture, displayResolutionDependentFBOs, DEFERRED_LIGHTING_MATERIAL, "texSceneOpaqueLightBuffer")); }
Source:
public void batchDelete(Collection<Entitlement> entitlements) { for (Entitlement entitlement : entitlements) { this.deleteImpl(entitlement); entitlement.getCertificates().clear(); entitlement.getConsumer().getEntitlements().remove(entitlement); entitlement.getPool().getEntitlements().remove(entitlement); } }

Target:
public void batchDelete(Collection<Entitlement> entitlements) { for (Entitlement entitlement : entitlements) { this.deleteImpl(entitlement); entitlement.getCertificates().clear(); if (Hibernate.isInitialized(entitlement.getConsumer().getEntitlements())) { entitlement.getConsumer().getEntitlements().remove(entitlement); } if (Hibernate.isInitialized(entitlement.getPool().getEntitlements())) { entitlement.getPool().getEntitlements().remove(entitlement); } } }
Source:
public void loadAndGetReturnsNullForEmpty() { String data = empty.loadAndGet() .orElse(null); assertThat(data, equalTo(null)); }

Target:
public void loadAndGetReturnsNullForEmpty() { String data = empty.loadAndGet() .orElse("null!!"); assertThat(data, equalTo(null)); }
Source:
private static int indexOfTypeParameter(List<DetailAST> typeParams, String requiredTypeName) { final Iterator<DetailAST> typeParamsIt = typeParams.iterator(); int paramIndex = -1; int index = 0; while (typeParamsIt.hasNext()) { final DetailAST typeParam = typeParamsIt.next(); if (typeParam.findFirstToken(TokenTypes.IDENT).getText() .equals(requiredTypeName)) { paramIndex = index; break; } index++; } return paramIndex; }

Target:
private static int indexOfTypeParameter(List<DetailAST> typeParams, String requiredTypeName) { int paramIndex = -1; int index = 0; for (DetailAST typeParam : typeParams) { if (typeParam.findFirstToken(TokenTypes.IDENT).getText() .equals(requiredTypeName)) { paramIndex = index; break; } index++; } return paramIndex; }
Source:
public Event() { this.properties = new Properties(); this.data = new Properties(); this.properties.putValue(Keys.DATA, this.data); setCustomProperties(); this.properties.put(Keys.CONTEXT, getAppNameContext()); }

Target:
public Event() { this.properties = new Properties(); this.data = new Properties(); this.properties.putValue(Keys.DATA, this.data); setCustomProperties(); Properties cxtProps = new Properties(); cxtProps.putValue(Keys.APP, Values.APP_NAME); this.properties.put(Keys.CONTEXT, cxtProps); }
Source:
public void validateAddingNonExistingNetwork() { List<VdsNetworkInterface> vdsNics = new ArrayList<VdsNetworkInterface>(); VdsNetworkInterface nic1 = new VdsNetworkInterface(); nic1.setNetworkName("vmnet"); vdsNics.add(nic1); VdsNetworkInterface nic2 = new VdsNetworkInterface(); nic2.setNetworkName("mgmtnet"); vdsNics.add(nic2); List<network> clusterNetworks = new ArrayList<network>(); network net1 = new network(); net1.setname("vmnet"); network net2 = new network(); net2.setname("mgmtnet"); clusterNetworks.add(net1); clusterNetworks.add(net2); List<VdsNetworkInterface> nics = new ArrayList<VdsNetworkInterface>(); VdsNetworkInterface nicWithUknownNetowrk = new VdsNetworkInterface(); nicWithUknownNetowrk.setNetworkName("nonExisitigNetworkName"); nics.add(nicWithUknownNetowrk); initMocks(vdsNics, clusterNetworks); SetupNetworksParameters params = new SetupNetworksParameters(); params.setInterfaces(nics); SetupNetworksHelper validator = createHelper(params); assertTrue(validator.validate().contains(VdcBllMessages.NETWORK_NOT_EXISTS_IN_CURRENT_CLUSTER)); }

Target:
public void validateAddingNonExistingNetwork() { List<VdsNetworkInterface> vdsNics = new ArrayList<VdsNetworkInterface>(); VdsNetworkInterface nic1 = new VdsNetworkInterface(); nic1.setNetworkName("vmnet"); vdsNics.add(nic1); VdsNetworkInterface nic2 = new VdsNetworkInterface(); nic2.setNetworkName("mgmtnet"); vdsNics.add(nic2); List<network> clusterNetworks = new ArrayList<network>(); network net1 = new network(); net1.setname("vmnet"); network net2 = new network(); net2.setname("mgmtnet"); clusterNetworks.add(net1); clusterNetworks.add(net2); List<VdsNetworkInterface> nics = new ArrayList<VdsNetworkInterface>(); VdsNetworkInterface nicWithUknownNetowrk = new VdsNetworkInterface(); nicWithUknownNetowrk.setNetworkName("nonExisitigNetworkName"); nics.add(nicWithUknownNetowrk); initMocks(vdsNics, clusterNetworks); SetupNetworksParameters params = new SetupNetworksParameters(); params.setInterfaces(nics); SetupNetworksHelper validator = createHelper(params); assertTrue(validator.validate().contains(NETWORK_NOT_EXISTS_IN_CURRENT_CLUSTER)); }
Source:
void download() { DownloadBatchStatus.Status status = downloadBatchStatus.status(); if (status == PAUSED || status == DELETION) { return; } if(!downloadConnectionAllowedChecker.isAllowedToDownload()) { downloadBatchStatus.markAsError(Optional.of(new DownloadError(DownloadError.Error.NETWORK_ERROR_CANNOT_DOWNLOAD_FILE)), downloadsBatchPersistence); notifyCallback(downloadBatchStatus); DownloadsNetworkRecoveryCreator.getInstance().scheduleRecovery(); return; } downloadBatchStatus.markAsDownloading(downloadsBatchPersistence); notifyCallback(downloadBatchStatus); totalBatchSizeBytes = getTotalSize(downloadFiles); if (totalBatchSizeBytes <= ZERO_BYTES) { Optional<DownloadError> downloadError = Optional.of(new DownloadError(DownloadError.Error.NETWORK_ERROR_CANNOT_DOWNLOAD_FILE)); downloadBatchStatus.markAsError(downloadError, downloadsBatchPersistence); notifyCallback(downloadBatchStatus); return; } for (DownloadFile downloadFile : downloadFiles) { downloadFile.download(fileDownloadCallback); if (batchCannotContinue()) { break; } } if (networkError()) { DownloadsNetworkRecoveryCreator.getInstance().scheduleRecovery(); } callbackThrottle.stopUpdates(); }

Target:
void download() { DownloadBatchStatus.Status status = downloadBatchStatus.status(); if (status == PAUSED || status == DELETION) { return; } if (!connectionChecker.isAllowedToDownload()) { downloadBatchStatus.markAsError(Optional.of(new DownloadError(DownloadError.Error.NETWORK_ERROR_CANNOT_DOWNLOAD_FILE)), downloadsBatchPersistence); notifyCallback(downloadBatchStatus); DownloadsNetworkRecoveryCreator.getInstance().scheduleRecovery(); return; } downloadBatchStatus.markAsDownloading(downloadsBatchPersistence); notifyCallback(downloadBatchStatus); totalBatchSizeBytes = getTotalSize(downloadFiles); if (totalBatchSizeBytes <= ZERO_BYTES) { Optional<DownloadError> downloadError = Optional.of(new DownloadError(DownloadError.Error.NETWORK_ERROR_CANNOT_DOWNLOAD_FILE)); downloadBatchStatus.markAsError(downloadError, downloadsBatchPersistence); notifyCallback(downloadBatchStatus); return; } for (DownloadFile downloadFile : downloadFiles) { downloadFile.download(fileDownloadCallback); if (batchCannotContinue()) { break; } } if (networkError()) { DownloadsNetworkRecoveryCreator.getInstance().scheduleRecovery(); } callbackThrottle.stopUpdates(); }
Source:
public String getGatewayKeystoreDir() { return getGatewaySecurityDir() + "/keystores"; }

Target:
public String getGatewayKeystoreDir() { return getGatewayKeystorePath().toString(); }
Source:
public void testGetLastInputInfo() throws Exception { LASTINPUTINFO plii = new LASTINPUTINFO(); assertEquals(plii.size(), plii.cbSize); boolean flag = User32.INSTANCE.GetLastInputInfo(plii); assertTrue(flag); assertTrue(Kernel32.INSTANCE.GetTickCount() >= plii.dwTime); assertTrue(plii.dwTime > 0); }

Target:
public void testGetLastInputInfo() throws Exception { LASTINPUTINFO plii = new LASTINPUTINFO(); assertEquals(plii.size(), plii.cbSize); assertTrue(User32.INSTANCE.GetLastInputInfo(plii)); assertTrue(Kernel32.INSTANCE.GetTickCount() >= plii.dwTime); assertTrue(plii.dwTime > 0); }
Source:
public NetworkCommon(T parameters) { super(parameters); this.setStoragePoolId(getNetwork().getDataCenterId()); }

Target:
public NetworkCommon(T parameters) { super(parameters); }
Source:
public void taskCountUpdates() throws InterruptedException { Meter meter = getMeter(ThreadPoolMonitor.TASK_COUNT); Iterator<Measurement> measurements = meter.measure().iterator(); assertEquals(0.0, measurements.next().value(), 0.0); Cancellable command = new Cancellable(); threadPoolExecutor.execute(command); Thread.sleep(60); PolledMeter.update(registry); measurements = meter.measure().iterator(); assertEquals(1.0, measurements.next().value(), 0.0); command.canceled = true; }

Target:
public void taskCountUpdates() throws InterruptedException { final Counter counter = getCounter(ThreadPoolMonitor.TASK_COUNT); assertEquals(0, counter.count()); final CountDownLatch synchronizer = new CountDownLatch(1); final CountDownLatch terminator = new CountDownLatch(1); final TestRunnable command = new TestRunnable(synchronizer, terminator); latchedExecutor.execute(command); synchronizer.await(6, TimeUnit.SECONDS); PolledMeter.update(registry); assertEquals(1, counter.count(), 0.0); terminator.countDown(); }
Source:
private Duration getTemporalValidationTolerance(ConfigurationState configurationState, Map<String, String> properties) { if ( configurationState instanceof ConfigurationImpl ) { ConfigurationImpl hibernateSpecificConfig = (ConfigurationImpl) configurationState; if ( hibernateSpecificConfig.getTemporalValidationTolerance() != null ) { if ( !Duration.ZERO.equals( hibernateSpecificConfig.getTemporalValidationTolerance() ) ) { LOG.logTemporalValidationTolerance( hibernateSpecificConfig.getTemporalValidationTolerance() ); } return hibernateSpecificConfig.getTemporalValidationTolerance(); } } String temporalValidationToleranceProperty = properties.get( HibernateValidatorConfiguration.TEMPORAL_VALIDATION_TOLERANCE ); if ( temporalValidationToleranceProperty != null ) { try { Duration tolerance = Duration.ofMillis( Long.parseLong( temporalValidationToleranceProperty ) ).abs(); if ( !Duration.ZERO.equals( tolerance ) ) { LOG.logTemporalValidationTolerance( tolerance ); } return tolerance; } catch (Exception e) { throw LOG.getUnableToParseTemporalValidationToleranceException( temporalValidationToleranceProperty, e ); } } return Duration.ZERO; }

Target:
private Duration getTemporalValidationTolerance(ConfigurationState configurationState, Map<String, String> properties) { if ( configurationState instanceof ConfigurationImpl ) { ConfigurationImpl hibernateSpecificConfig = (ConfigurationImpl) configurationState; if ( hibernateSpecificConfig.getTemporalValidationTolerance() != null ) { LOG.logTemporalValidationTolerance( hibernateSpecificConfig.getTemporalValidationTolerance() ); return hibernateSpecificConfig.getTemporalValidationTolerance(); } } String temporalValidationToleranceProperty = properties.get( HibernateValidatorConfiguration.TEMPORAL_VALIDATION_TOLERANCE ); if ( temporalValidationToleranceProperty != null ) { try { Duration tolerance = Duration.ofMillis( Long.parseLong( temporalValidationToleranceProperty ) ).abs(); LOG.logTemporalValidationTolerance( tolerance ); return tolerance; } catch (Exception e) { throw LOG.getUnableToParseTemporalValidationToleranceException( temporalValidationToleranceProperty, e ); } } return Duration.ZERO; }
Source:
private void waiterInterruptRoutine() { LOG.debug("Interrupt-cycle interrupting %d waiters/holders: {%s}", Thread.currentThread().getId(), mSharedWaitersAndHolders.size(), mSharedWaitersAndHolders .stream().map((th) -> Long.toString(th.getId())).collect(Collectors.joining(","))); for (Thread th : mSharedWaitersAndHolders) { th.interrupt(); } }

Target:
private void waiterInterruptRoutine() { List<Thread> interruptedThreads = new ArrayList(mSharedWaitersAndHolders.size()); for (Thread th : mSharedWaitersAndHolders) { th.interrupt(); interruptedThreads.add(th); } LOG.info("Interrupt-cycle interrupted waiters/holders: {}", interruptedThreads.size(), interruptedThreads.stream().map((th) -> ThreadUtils.getThreadIdentifier(th)) .collect(Collectors.joining(","))); }
Source:
private ResponseEntity<Object> indexObjectAndChildren(String id, Boolean inplace) { Map<String, Object> result = new HashMap<>(); result.put("action", "reindex"); result.put("pid", id); PID objectPid = PIDs.get(id); if (inplace == null || inplace) { log.info("Reindexing " + id + ", inplace reindex mode"); } else { log.info("Reindexing " + id + ", clean reindex mode"); } try { indexingService.reindexObjectAndChildren(AgentPrincipals.createFromThread(), objectPid, inplace); } catch (Exception e) { result.put("error", e.getMessage()); Throwable t = e.getCause(); if (t instanceof AuthorizationException || t instanceof AccessRestrictionException) { return new ResponseEntity<>(result, HttpStatus.FORBIDDEN); } else { log.error("Failed to reindex repository due to {}", e); return new ResponseEntity<>(result, HttpStatus.INTERNAL_SERVER_ERROR); } } result.put("timestamp", System.currentTimeMillis()); return new ResponseEntity<>(result, HttpStatus.OK); }

Target:
private ResponseEntity<Object> indexObjectAndChildren(String id, Boolean inplace) { Map<String, Object> result = new HashMap<>(); result.put("action", "reindex"); result.put("pid", id); PID objectPid = PIDs.get(id); if (inplace == null || inplace) { log.info("Reindexing " + id + ", inplace reindex mode"); } else { log.info("Reindexing " + id + ", clean reindex mode"); } try { indexingService.reindexObjectAndChildren(AgentPrincipals.createFromThread(), objectPid, inplace); } catch (Exception e) { result.put("error", e.getMessage()); if (e instanceof AuthorizationException || e instanceof AccessRestrictionException) { return new ResponseEntity<>(result, HttpStatus.FORBIDDEN); } else { log.error("Failed to reindex object and its children", id, e); return new ResponseEntity<>(result, HttpStatus.INTERNAL_SERVER_ERROR); } } result.put("timestamp", System.currentTimeMillis()); return new ResponseEntity<>(result, HttpStatus.OK); }
Source:
public void test_ringBuffer() throws Exception { ReadWriteBuffer<Integer> buffer = new RingBuffer<>(2); assertThat(buffer.isEmpty(), equalTo(true)); assertThat(buffer.size(), equalTo(0)); assertThat(buffer.read(), equalTo(null)); assertThat(buffer.stream().count(), equalTo(0L)); buffer.put(1); buffer.put(2); assertThat(buffer.isEmpty(), equalTo(false)); assertThat(buffer.size(), equalTo(2)); buffer.put(3); assertThat(buffer.size(), equalTo(2)); assertThat(buffer.read(), equalTo(2)); assertThat(buffer.size(), equalTo(1)); assertThat(buffer.read(), equalTo(3)); assertThat(buffer.isEmpty(), equalTo(true)); assertThat(buffer.size(), equalTo(0)); assertThat(buffer.read(), equalTo(null)); }

Target:
public void test_ringBuffer() throws Exception { ReadWriteBuffer<Integer> buffer = new RingBuffer<>(2); assertThat(buffer.isEmpty(), equalTo(true)); assertThat(buffer.size(), equalTo(0)); assertThat(buffer.read(), equalTo(null)); assertThat(buffer.stream().count(), equalTo(0L)); buffer.put(1); buffer.put(2); assertThat(buffer.isEmpty(), equalTo(false)); assertThat(buffer.size(), equalTo(2)); buffer.put(3); assertThat(buffer.size(), equalTo(2)); assertThat(buffer.read(), equalTo(2)); assertThat(buffer.size(), equalTo(1)); assertThat(buffer.read(), equalTo(3)); assertThat(buffer.isEmpty(), equalTo(true)); assertThat(buffer.size(), equalTo(0)); assertThat(buffer.read(), equalTo(null)); buffer.put(1); buffer.put(2); assertThat(buffer.size(), equalTo(2)); List<Integer> collect = buffer.stream().collect(Collectors.toList()); assertThat(collect.get(0), equalTo(1)); assertThat(collect.get(1), equalTo(2)); assertThat(buffer.stream().count(), equalTo(0L)); }
Source:
public void testNullHeaderMateReferenceIndex() { SAMRecord sam = new SAMRecordSetBuilder().addFrag("test", 0, 1, false, false, "3S9M", null, 2); final SAMFileHeader header = sam.getHeader(); sam.setHeader(null); sam.setMateReferenceIndex(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX); Assert.assertTrue(sam.getMateReferenceIndex().equals(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX)); Assert.assertTrue(sam.getMateReferenceName().equals(SAMRecord.NO_ALIGNMENT_REFERENCE_NAME)); sam = new SAMRecordSetBuilder().addFrag("test", 0, 1, false, false, "3S9M", null, 2); sam.setHeader(null); sam.setMateReferenceName(SAMRecord.NO_ALIGNMENT_REFERENCE_NAME); Assert.assertTrue(sam.getMateReferenceIndex() == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX); sam = new SAMRecord(null); Assert.assertTrue(sam.getMateReferenceIndex() == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX); sam = new SAMRecord(null); final String unresolvableRefName = "unresolvable"; sam.setMateReferenceName(unresolvableRefName); sam.setHeader(header); Assert.assertTrue(sam.getMateReferenceIndex() == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX); }

Target:
public void testNullHeaderMateReferenceIndex() { SAMRecord sam = createTestRecordHelper(); final SAMFileHeader samHeader = sam.getHeader(); sam.setMateReferenceName("chr1"); int originalMateRefIndex = sam.getMateReferenceIndex(); Assert.assertTrue(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX != originalMateRefIndex); sam.setHeader(null); Assert.assertTrue(null == sam.mMateReferenceIndex); sam.setHeader(samHeader); Assert.assertTrue(sam.getMateReferenceIndex().equals(originalMateRefIndex)); sam.setHeader(null); sam.setMateReferenceIndex(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX); Assert.assertTrue(sam.getMateReferenceIndex().equals(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX)); Assert.assertTrue(sam.getMateReferenceName().equals(SAMRecord.NO_ALIGNMENT_REFERENCE_NAME)); sam = new SAMRecord(null); Assert.assertTrue(null == sam.mMateReferenceIndex); Assert.assertTrue(sam.getMateReferenceIndex() == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX); final String unresolvableRefName = "unresolvable"; sam.setMateReferenceName(unresolvableRefName); sam.setHeader(samHeader); Assert.assertTrue(null == sam.mMateReferenceIndex); Assert.assertTrue(sam.getMateReferenceIndex() == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX); }
Source:
void postCommandsInBulk() { final Command first = newCommand(); final Command second = newCommand(); final List<Command> commands = newArrayList(first, second); commandBus.unregister(createProjectHandler); commandBus.register(createProjectHandler); final CommandBus spy = spy(commandBus); spy.post(commands, StreamObservers.memoizingObserver()); @SuppressWarnings("unchecked") final ArgumentCaptor<Iterable<Command>> storingCaptor = forClass(Iterable.class); verify(spy).store(storingCaptor.capture()); final Iterable<Command> storingArgs = storingCaptor.getValue(); assertSize(commands.size(), storingArgs); assertContainsAll(storingArgs, first, second); final ArgumentCaptor<CommandEnvelope> postingCaptor = forClass(CommandEnvelope.class); verify(spy, times(2)).doPost(postingCaptor.capture()); final List<CommandEnvelope> postingArgs = postingCaptor.getAllValues(); assertSize(commands.size(), postingArgs); assertEquals(commands.get(0), postingArgs.get(0).getCommand()); assertEquals(commands.get(1), postingArgs.get(1).getCommand()); commandBus.unregister(createProjectHandler); }

Target:
void postCommandsInBulk() { final Command first = newCommand(); final Command second = newCommand(); final List<Command> commands = newArrayList(first, second); commandBus.unregister(createProjectHandler); commandBus.register(createProjectHandler); final CommandBus spy = spy(commandBus); spy.post(commands, memoizingObserver()); @SuppressWarnings("unchecked") final ArgumentCaptor<Iterable<Command>> storingCaptor = forClass(Iterable.class); verify(spy).store(storingCaptor.capture()); final Iterable<Command> storingArgs = storingCaptor.getValue(); assertSize(commands.size(), storingArgs); assertContainsAll(storingArgs, first, second); final ArgumentCaptor<CommandEnvelope> postingCaptor = forClass(CommandEnvelope.class); verify(spy, times(2)).doPost(postingCaptor.capture()); final List<CommandEnvelope> postingArgs = postingCaptor.getAllValues(); assertSize(commands.size(), postingArgs); assertEquals(commands.get(0), postingArgs.get(0).getCommand()); assertEquals(commands.get(1), postingArgs.get(1).getCommand()); commandBus.unregister(createProjectHandler); }
Source:
private long sendEligibleCalls(long now) { long pollTimeout = Long.MAX_VALUE; for (Iterator<Map.Entry<Node, List<Call>>> iter = callsToSend.entrySet().iterator(); iter.hasNext(); ) { Map.Entry<Node, List<Call>> entry = iter.next(); List<Call> calls = entry.getValue(); if (calls.isEmpty()) { iter.remove(); continue; } Node node = entry.getKey(); if (!client.ready(node, now)) { long nodeTimeout = client.pollDelayMs(node, now); pollTimeout = Math.min(pollTimeout, nodeTimeout); log.trace("Client is not ready to send to {}. Must delay ms", node, nodeTimeout); AuthenticationException authenticationException = client.authenticationException(node); if (authenticationException != null) { Call call = calls.remove(0); call.fail(now, authenticationException); } continue; } Call call = calls.remove(0); int timeoutMs = calcTimeoutMsRemainingAsInt(now, call.deadlineMs); AbstractRequest.Builder<?> requestBuilder; try { requestBuilder = call.createRequest(timeoutMs); } catch (Throwable throwable) { call.fail(now, new KafkaException(String.format( "Internal error sending %s to %s.", call.callName, node))); continue; } ClientRequest clientRequest = client.newClientRequest(node.idString(), requestBuilder, now, true); log.trace("Sending to {}. correlationId={}", requestBuilder, node, clientRequest.correlationId()); client.send(clientRequest, now); getOrCreateListValue(callsInFlight, node.idString()).add(call); correlationIdToCalls.put(clientRequest.correlationId(), call); } return pollTimeout; }

Target:
private long sendEligibleCalls(long now) { long pollTimeout = Long.MAX_VALUE; for (Iterator<Map.Entry<Node, List<Call>>> iter = callsToSend.entrySet().iterator(); iter.hasNext(); ) { Map.Entry<Node, List<Call>> entry = iter.next(); List<Call> calls = entry.getValue(); if (calls.isEmpty()) { iter.remove(); continue; } Node node = entry.getKey(); if (!client.ready(node, now)) { long nodeTimeout = client.pollDelayMs(node, now); pollTimeout = Math.min(pollTimeout, nodeTimeout); log.trace("Client is not ready to send to {}. Must delay ms", node, nodeTimeout); continue; } Call call = calls.remove(0); int timeoutMs = calcTimeoutMsRemainingAsInt(now, call.deadlineMs); AbstractRequest.Builder<?> requestBuilder; try { requestBuilder = call.createRequest(timeoutMs); } catch (Throwable throwable) { call.fail(now, new KafkaException(String.format( "Internal error sending %s to %s.", call.callName, node))); continue; } ClientRequest clientRequest = client.newClientRequest(node.idString(), requestBuilder, now, true); log.trace("Sending to {}. correlationId={}", requestBuilder, node, clientRequest.correlationId()); client.send(clientRequest, now); getOrCreateListValue(callsInFlight, node.idString()).add(call); correlationIdToCalls.put(clientRequest.correlationId(), call); } return pollTimeout; }
Source:
private void checkAndMaybeComplete() { if (progressTracker.isDone()) { if (progressTracker.hasSucceeded()) { operationException.set(null); } operationCompleted = true; } if (operationCompleted) { Exception e = operationException.get(); if (operationResult == null && e == null) { e = new RouterException("Operation failed, but exception was not set", RouterErrorCode.UnexpectedInternalError); routerMetrics.operationFailureWithUnsetExceptionCount.inc(); } if (e != null) { boolean encrypted = operationResult != null && operationResult.getBlobResult != null && operationResult.getBlobResult.getBlobInfo() != null && operationResult.getBlobResult.getBlobInfo() .getBlobProperties() .isEncrypted(); operationResult = null; routerMetrics.onGetBlobError(e, options, encrypted); } long operationLatencyMs = time.milliseconds() - submissionTimeMs; routerMetrics.getBlobInfoOperationLatencyMs.update(operationLatencyMs); if (operationResult != null && operationResult.getBlobResult != null && operationResult.getBlobResult.getBlobInfo() != null && operationResult.getBlobResult.getBlobInfo() .getBlobProperties() .isEncrypted()) { routerMetrics.getEncryptedBlobInfoOperationLatencyMs.update(operationLatencyMs); } NonBlockingRouter.completeOperation(null, getOperationCallback, operationResult, e); } }

Target:
private void checkAndMaybeComplete() { if (progressTracker.isDone()) { if (progressTracker.hasSucceeded()) { operationException.set(null); } operationCompleted = true; } if (operationCompleted) { Exception e = operationException.get(); if (operationResult == null && e == null) { e = new RouterException("Operation failed, but exception was not set", RouterErrorCode.UnexpectedInternalError); routerMetrics.operationFailureWithUnsetExceptionCount.inc(); } if (e != null) { operationResult = null; routerMetrics.onGetBlobError(e, options, blobId.isEncrypted()); } long operationLatencyMs = time.milliseconds() - submissionTimeMs; if (blobId.isEncrypted()) { routerMetrics.getEncryptedBlobInfoOperationLatencyMs.update(operationLatencyMs); } else { routerMetrics.getBlobInfoOperationLatencyMs.update(operationLatencyMs); } NonBlockingRouter.completeOperation(null, getOperationCallback, operationResult, e); } }
Source:
protected IWorkingSet[][] splitSets() { IWorkingSet[] allSets = getWindow().getWorkbench().getWorkingSetManager().getWorkingSets(); Map<String, List<IWorkingSet>> map = new HashMap<>(); WorkingSetRegistry registry = WorkbenchPlugin.getDefault().getWorkingSetRegistry(); for (IWorkingSet allSet : allSets) { String setType = allSet.getId(); if (WorkbenchActivityHelper.filterItem(registry.getWorkingSetDescriptor(setType))) { continue; } List<IWorkingSet> setsOfType = map.get(setType); if (setsOfType == null) { setsOfType = new ArrayList<>(); map.put(setType, setsOfType); } setsOfType.add(allSet); } IWorkingSet[][] typedSets = new IWorkingSet[map.keySet().size()][]; int i = 0; for (String string : map.keySet()) { List<IWorkingSet> setsOfType = map.get(string); typedSets[i] = new IWorkingSet[setsOfType.size()]; setsOfType.toArray(typedSets[i++]); } return typedSets; }

Target:
protected IWorkingSet[][] splitSets() { IWorkingSet[] allSets = getWindow().getWorkbench().getWorkingSetManager().getWorkingSets(); Map<String, List<IWorkingSet>> map = new HashMap<>(); WorkingSetRegistry registry = WorkbenchPlugin.getDefault().getWorkingSetRegistry(); for (IWorkingSet allSet : allSets) { String setType = allSet.getId(); if (WorkbenchActivityHelper.filterItem(registry.getWorkingSetDescriptor(setType))) { continue; } List<IWorkingSet> setsOfType = map.get(setType); if (setsOfType == null) { setsOfType = new ArrayList<>(); map.put(setType, setsOfType); } setsOfType.add(allSet); } IWorkingSet[][] typedSets = new IWorkingSet[map.keySet().size()][]; int i = 0; for (String setType : map.keySet()) { List<IWorkingSet> setsOfType = map.get(setType); typedSets[i] = new IWorkingSet[setsOfType.size()]; setsOfType.toArray(typedSets[i++]); } return typedSets; }
Source:
public DocumentModel toFields(DocumentModel inDoc, HashMap<String, String> inMapping, boolean inSave, CoreSession inSession) { run(); HashMap<String, String> values = toHashMap(); for (String inXPath : inMapping.keySet()) { String value = values.get(inMapping.get(inXPath)); inDoc.setPropertyValue(inXPath, value); } if (inSave) { inDoc = inSession.saveDocument(inDoc); } return inDoc; }

Target:
public DocumentModel toFields(DocumentModel inDoc, HashMap<String, String> inMapping, boolean inSave, CoreSession inSession) { run(); Map<String, String> values = toHashMap(); for (String inXPath : inMapping.keySet()) { String value = values.get(inMapping.get(inXPath)); inDoc.setPropertyValue(inXPath, value); } if (inSave) { inDoc = inSession.saveDocument(inDoc); } return inDoc; }
Source:
public String getScript(@Nonnull Location l) { String script = BlockStorage.getLocationInfo(l, "script"); return script != null ? script : DEFAULT_SCRIPT; }

Target:
public String getScript(@Nonnull Location l) { Validate.notNull(l, "Location for android not specified"); String script = BlockStorage.getLocationInfo(l, "script"); return script != null ? script : DEFAULT_SCRIPT; }
Source:
public Spec drain() { try { return new Spec.Simple( new JdkRequest(UriBuilder.fromUri(this.home).build()) .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML) .header(HttpHeaders.AUTHORIZATION, this.token) .method(Request.GET) .fetch() .as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .as(XmlResponse.class) .xml() .xpath("/page/rule/drain/text()") .get(0) ); } catch (IOException ex) { throw new IllegalStateException(ex); } }

Target:
public Spec drain() { try { return new Spec.Simple( new JdkRequest(this.home) .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML) .header(HttpHeaders.AUTHORIZATION, this.token) .fetch() .as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .as(XmlResponse.class) .xml() .xpath("/page/rule/drain/text()") .get(0) ); } catch (IOException ex) { throw new IllegalStateException(ex); } }
Source:
public LogReplicationRuntimeState processEvent(LogReplicationRuntimeEvent event) throws IllegalTransitionException { switch (event.getType()) { case REMOTE_LEADER_FOUND: ((NegotiatingState)fsm.getStates().get(LogReplicationRuntimeStateType.NEGOTIATING)).setLeaderEndpoint(event.getEndpoint()); return fsm.getStates().get(LogReplicationRuntimeStateType.NEGOTIATING); case ON_CONNECTION_DOWN: String endpointDown = event.getEndpoint(); fsm.updateDisconnectedEndpoints(endpointDown); if (fsm.getConnectedEndpoints().size() == 0) { return fsm.getStates().get(LogReplicationRuntimeStateType.WAITING_FOR_CONNECTIVITY); } return this; case REMOTE_LEADER_LOSS: this.worker.submit(this::verifyLeadership); return this; case REMOTE_LEADER_NOT_FOUND: return this; case ON_CONNECTION_UP: fsm.updateConnectedEndpoints(event.getEndpoint()); return this; case LOCAL_LEADER_LOSS: return fsm.getStates().get(LogReplicationRuntimeStateType.STOPPED); default: { log.warn("Unexpected communication event when in init state.", event.getType()); throw new IllegalTransitionException(event.getType(), getType()); } } }

Target:
public LogReplicationRuntimeState processEvent(LogReplicationRuntimeEvent event) throws IllegalTransitionException { switch (event.getType()) { case REMOTE_LEADER_FOUND: ((NegotiatingState)fsm.getStates().get(LogReplicationRuntimeStateType.NEGOTIATING)).setLeaderEndpoint(event.getEndpoint()); return fsm.getStates().get(LogReplicationRuntimeStateType.NEGOTIATING); case ON_CONNECTION_DOWN: String endpointDown = event.getEndpoint(); fsm.updateDisconnectedEndpoints(endpointDown); if (fsm.getConnectedEndpoints().size() == 0) { return fsm.getStates().get(LogReplicationRuntimeStateType.WAITING_FOR_CONNECTIVITY); } return this; case REMOTE_LEADER_LOSS: case REMOTE_LEADER_NOT_FOUND: return this; case ON_CONNECTION_UP: fsm.updateConnectedEndpoints(event.getEndpoint()); return this; case LOCAL_LEADER_LOSS: return fsm.getStates().get(LogReplicationRuntimeStateType.STOPPED); default: { log.warn("Unexpected communication event when in init state.", event.getType()); throw new IllegalTransitionException(event.getType(), getType()); } } }
Source:
public List<Capability> getCapabilities() { throw new UnsupportedOperationException("Must first be build"); }

Target:
public List<Capability> getCapabilities() { return new ArrayList<>(capabilities.values()); }
Source:
private void showAlertMenu(final View alertView, final int alertPosition) { PopupMenu alertMenu = new PopupMenu(this, alertView); alertMenu.getMenuInflater().inflate(R.menu.menu_alerts, alertMenu.getMenu()); alertMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.menu_resolve: removeAlert(alertPosition); return true; case R.id.menu_acknowledge: removeAlert(alertPosition); return true; default: return false; } } }); alertMenu.show(); }

Target:
private void showAlertMenu(final View alertView, final int alertPosition) { PopupMenu alertMenu = new PopupMenu(this, alertView); alertMenu.getMenuInflater().inflate(R.menu.menu_alerts, alertMenu.getMenu()); alertMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.menu_resolve: Timber.d("Alert %d was not deleted intentionally.", alertPosition); return true; case R.id.menu_acknowledge: Timber.d("Alert %d was not removed intentionally.", alertPosition); return true; default: return false; } } }); alertMenu.show(); }
Source:
public void testIoException() throws Exception { when(mockedMapper.readValue(any(String.class), eq(User.class))).thenThrow(IOException.class); Assertions.assertThrows(RuntimeException.class, () -> { UsersDao.fromJson(mockedMapper, mapper.writeValueAsString(testUser)); }); }

Target:
public void testIoException() throws Exception { when(mockedMapper.readValue(any(String.class), eq(User.class))).thenThrow(IOException.class); assertThrows(RuntimeException.class, () -> { UsersDao.fromJson(mockedMapper, mapper.writeValueAsString(testUser)); }); }
Source:
public JsonObject json() throws IOException { final JsonObject obj = new JsonNode( this.storage.xml().nodes(this.xpath()).get(0) ).json(); JsonObjectBuilder builder = Json.createObjectBuilder() .add("id", this.num) .add( "url", String.format( "<LINK_0>", this.coords, this.num ) ) .add("commit_id", JsonValue.NULL) .add("event", obj.getString("event")) .add( "actor", Json.createObjectBuilder() .add("login", obj.getString("login")) .build() ) .add("created_at", obj.getString("created_at")); final String label = "label"; if (obj.containsKey(label)) { builder = builder.add( label, Json.createObjectBuilder() .add("name", obj.getString(label)) .build() ); } return builder.build(); }

Target:
public JsonObject json() throws IOException { final JsonObject obj = new JsonNode( this.storage.xml().nodes(this.xpath()).get(0) ).json(); JsonObjectBuilder builder = Json.createObjectBuilder() .add("id", this.num) .add( "url", String.format( "<LINK_0>", this.coords, this.num ) ) .add("commit_id", JsonValue.NULL) .add(MkEvent.EVENT, obj.getString(MkEvent.EVENT)) .add( "actor", Json.createObjectBuilder() .add(MkEvent.LOGIN, obj.getString(MkEvent.LOGIN)) .build() ) .add(MkEvent.CREATED_AT, obj.getString(MkEvent.CREATED_AT)); final String label = "label"; if (obj.containsKey(label)) { builder = builder.add( label, Json.createObjectBuilder() .add("name", obj.getString(label)) .build() ); } return builder.build(); }
Source:
private void usingIsEmpty() { Optional<Object> op = Optional.emtpy(); if (!op.isEmpty()) { op.get(); } }

Target:
private void usingIsEmpty() { Optional<Object> op = Optional.empty(); if (!op.isEmpty()) { op.get(); } }
Source:
public SSLHandshaker(SocketChannel sc, SSLEngine engine) { m_sc = sc; m_sslEngine = engine; SSLSession dummySession = engine.getSession(); m_localClearData = ByteBuffer.allocate(dummySession.getApplicationBufferSize() + 50); m_localEncData = ByteBuffer.allocate(dummySession.getPacketBufferSize()); m_netClearData = ByteBuffer.allocate(dummySession.getApplicationBufferSize() + 50); m_netEncData = ByteBuffer.allocate(dummySession.getPacketBufferSize()); dummySession.invalidate(); }

Target:
public SSLHandshaker(SocketChannel sc, SSLEngine engine) { m_sc = sc; m_sslEngine = engine; SSLSession dummySession = engine.getSession(); m_clear = ByteBuffer.allocate(dummySession.getApplicationBufferSize() + 50); m_encrypted = ByteBuffer.allocate(dummySession.getPacketBufferSize()); dummySession.invalidate(); }