auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void triggerConfigure() { <START> String source = (String) sourceComboBox.getSelectedItem(); <END> if (source.equals(SOURCE_AGGREGATE)) { AggregateServerConnectionDialog dialog = AggregateServerConnectionDialog.empty(__ -> true); dialog.onConnect(this::triggerAggregateConnection); dialog.getForm().setVisible(true); } else if (source.equals(SOURCE_CUSTOM_DIR)) { WrappedFileChooser fc = new WrappedFileChooser(SourceSelectPanelForm.this, new ODKCollectFileChooser(SourceSelectPanelForm.this)); int retVal = fc.showDialog(); if (retVal == JFileChooser.APPROVE_OPTION) triggerCustomDirSource(Paths.get(fc.getSelectedFile().getAbsolutePath())); } }</code><technical_language>This null. Wrap Optional</technical_language>

Target:
private void triggerConfigure() { Optional .ofNullable((Source<?>) sourceComboBox.getSelectedItem()) .ifPresent(source -> { if (source.equals(Source.AGGREGATE)) Source.AGGREGATE.onSelect(container, this::triggerAggregateConnection); if (source.equals(Source.CUSTOM_DIR)) Source.CUSTOM_DIR.onSelect(container, this::triggerCustomDirSource); }); }
Source:
<code>public RegionBootstrap(BootstrapNotifier application, Region region) { if (application.getApplicationContext() == null) { throw new NullPointerException("The BootstrapNotifier instance is returning null from its getApplicationContext() method. Have you implemented this method?"); } beaconManager = BeaconManager.getInstanceForApplication(application.getApplicationContext()); <START> this.context = application.getApplicationContext(); <END> regions = new ArrayList<Region>(); regions.add(region); beaconConsumer = new InternalBeaconConsumer(); beaconManager.bind(beaconConsumer); LogManager.d(TAG, "Waiting for BeaconService connection"); }</code><technical_language>if consistently set this.context = application.getApplicationContext() in constructors (which this appears do), other places call this.context.getApplicationContext() changed this.context</technical_language>

Target:
public RegionBootstrap(BootstrapNotifier application, Region region) { if (application.getApplicationContext() == null) { throw new NullPointerException("The BootstrapNotifier instance is returning null from its getApplicationContext() method. Have you implemented this method?"); } this.context = application.getApplicationContext(); regions = new ArrayList<Region>(); regions.add(region); beaconManager = BeaconManager.getInstanceForApplication(context); beaconConsumer = new InternalBeaconConsumer(); beaconManager.bind(beaconConsumer); LogManager.d(TAG, "Waiting for BeaconService connection"); }
Source:
<code>protected void processUnique(T tuple) { if (orderedOutput && !decisions.isEmpty()) { recordDecision(tuple, Decision.UNIQUE); } else { uniqueEvents++; <START> emitOutput(tuple); <END> } }</code><technical_language>knit: emitUnique... similar places</technical_language>

Target:
protected void processUnique(T tuple) { if (preserveTupleOrder && !decisions.isEmpty()) { recordDecision(tuple, Decision.UNIQUE); } else { uniqueEvents++; emitUnique(tuple); } }
Source:
<code>public String get(Enum<?> key) { if(key == null) { <START> throw new IllegalArgumentException(); <END> } try { String enumName = key.getDeclaringClass().toString(); enumName = enumName.substring(enumName.lastIndexOf(".")+1,enumName.length()); String translatedEnum = enums.getString(enumName + "___" + key.toString()); return translatedEnum; } catch (MissingResourceException e) { logger.info("Missing Enum resource: " + e.getLocalizedMessage()); return key.name(); } }</code><technical_language>This problematic. createAndTranslate(..) returned constants.notAvailableLabel() for null object. while get(...) returned null. of usages relies this behaviour</technical_language>

Target:
public String get(Enum<?> key) { if(key == null) { return constants.notAvailableLabel(); } try { String enumName = key.getDeclaringClass().toString(); enumName = enumName.substring(enumName.lastIndexOf(".")+1,enumName.length()); String translatedEnum = enums.getString(enumName + "___" + key.toString()); return translatedEnum; } catch (MissingResourceException e) { logger.info("Missing Enum resource: " + e.getLocalizedMessage()); return key.name(); } }
Source:
<code><START> public Observable<Pair<Trip, Trip>> getHideAutoCompleteVisibilityClick() { <END> return _hideAutoCompleteVisibilityClicks; }</code><technical_language>change signature <Pair<Trip, Trip> a new dataclass like: data class AutoCompleteClickEvent<Type> ( val from: Type, val to: Type ) a bit clearer in this pair do</technical_language>

Target:
public Observable<AutoCompleteUpdateEvent<Trip>> getHideAutoCompleteVisibilityClick() { return _hideAutoCompleteVisibilityClicks; }
Source:
<code>public long getReplicationRemainingPercent() { ReplicationStatusKey key = ReplicationStatusKey.newBuilder().setKey( ReplicationStatusKey.Status.REPLICATION_COMPLETION).build(); CorfuRecord record = corfuStore.query(NAMESPACE).getRecord(REPLICATION_STATUS_TABLE, key); if (record == null) { <START> return 0; <END> } ReplicationStatusVal val = (ReplicationStatusVal)record.getPayload(); return val.getReplicationCompletion(); }</code><technical_language>add a log updated corfuStore is complete necessarily</technical_language>

Target:
public Map<String, ReplicationStatusVal> getReplicationRemainingPercent() { Map<String, ReplicationStatusVal> replicationStatusMap = new HashMap<>(); QueryResult<CorfuStoreEntry<ReplicationStatusKey, ReplicationStatusVal, ReplicationStatusVal>> entries = corfuStore.query(NAMESPACE).executeQuery(REPLICATION_STATUS_TABLE, (x) -> {return true;}); for(CorfuStoreEntry<ReplicationStatusKey, ReplicationStatusVal, ReplicationStatusVal>entry : entries.getResult()) { replicationStatusMap.put(entry.getKey().getClusterId(), entry.getPayload()); } return replicationStatusMap; }
Source:
<code>public boolean equals(Object aThat) { <START> if (this == aThat) <END> return true; if (!(aThat instanceof VariableIdentifier)) return false; VariableIdentifier that = (VariableIdentifier) aThat; return (this.getName().equals(that.getName()) && this.getNamespaceIdentifier().equals(that.getNamespaceIdentifier())); }</code><technical_language>Please curly braces put return true line if (this == aThat)</technical_language>

Target:
public boolean equals(Object aThat) { if (this == aThat) { return true; } if (!(aThat instanceof VariableIdentifier)) { return false; } VariableIdentifier that = (VariableIdentifier) aThat; return (this.getName().equals(that.getName()) && this .getNamespaceIdentifier().equals(that.getNamespaceIdentifier())); }
Source:
<code>public Subject getSubject() { <START> return () -> Optional.ofNullable( <END> SecurityContextHolder.getContext().getAuthentication()).map(Principal::getName).orElse(null); }</code><technical_language>Is return null in case request is authenticated</technical_language>

Target:
public Optional<Subject> getSubject() { return Optional.empty(); }
Source:
<code>public void inherit(SolverBenchmarkConfig inheritedConfig) { if (solverConfig == null) { solverConfig = inheritedConfig.getSolverConfig(); } else if (inheritedConfig.getSolverConfig() != null) { solverConfig.inherit(inheritedConfig.getSolverConfig()); } if (problemBenchmarksConfig == null) { problemBenchmarksConfig = inheritedConfig.getProblemBenchmarksConfig(); } else if (inheritedConfig.getProblemBenchmarksConfig() != null) { problemBenchmarksConfig.inherit(inheritedConfig.getProblemBenchmarksConfig()); } if (subSingleCount == null) { <START> subSingleCount = ObjectUtils.defaultIfNull(inheritedConfig.getSubSingleCount(), 1); <END> } }</code><technical_language>Reading Config object writing alter XML. This code do that. This is better: if (subSingleCount == null) { subSingleCount = inheritedConfig.getSubSingleCount(); } a ConfigUtils.method do for you. do defaulting in inherit() method, do in locally in build methods (so change global fields of a config class</technical_language>

Target:
public void inherit(SolverBenchmarkConfig inheritedConfig) { if (solverConfig == null) { solverConfig = inheritedConfig.getSolverConfig(); } else if (inheritedConfig.getSolverConfig() != null) { solverConfig.inherit(inheritedConfig.getSolverConfig()); } if (problemBenchmarksConfig == null) { problemBenchmarksConfig = inheritedConfig.getProblemBenchmarksConfig(); } else if (inheritedConfig.getProblemBenchmarksConfig() != null) { problemBenchmarksConfig.inherit(inheritedConfig.getProblemBenchmarksConfig()); } subSingleCount = ConfigUtils.inheritOverwritableProperty(subSingleCount, inheritedConfig.getSubSingleCount()); }
Source:
<code>public void beforeCompletion() { <START> switch (faiMode) { <END> case BEFORE_MARK_ROLLBACK: try { transaction.setRollbackOnly(); } catch (SystemException e) { } break; case BEFORE_THROW_EXCEPTION: throw new RuntimeException("induced!"); } }</code><technical_language>Spelling</technical_language>

Target:
public void beforeCompletion() { switch (failMode) { case BEFORE_MARK_ROLLBACK: try { transaction.setRollbackOnly(); } catch (SystemException e) { } break; case BEFORE_THROW_EXCEPTION: throw new RuntimeException("induced!"); } }
Source:
<code>public ArtifactData create(IOseeBranch branch, IArtifactType token, String guid, long uuid) throws OseeCoreException { Conditions.checkNotNull(branch, "branch"); Conditions.checkExpressionFailOnTrue(artifactCache.isAbstract(token), "Cannot create an instance of abstract type [%s]", token); String guidToSet = idFactory.getUniqueGuid(guid); Conditions.checkExpressionFailOnTrue(!GUID.isValid(guidToSet), "Invalid guid [%s] during artifact creation [type: %s]", guidToSet, token); VersionData version = objectFactory.createDefaultVersionData(); version.setBranchId(branch.getUuid()); ModificationType modType = RelationalConstants.DEFAULT_MODIFICATION_TYPE; <START> ArtifactData artifactData = <END> objectFactory.createArtifactData(version, new Long(uuid).intValue(), token, modType, guidToSet); return artifactData; }</code><technical_language>intent of this method uuid parameter generate a new</technical_language>

Target:
public ArtifactData create(IOseeBranch branch, IArtifactType token, String guid, long uuid) throws OseeCoreException { Conditions.checkNotNull(branch, "branch"); Conditions.checkExpressionFailOnTrue(artifactCache.isAbstract(token), "Cannot create an instance of abstract type [%s]", token); String guidToSet = idFactory.getUniqueGuid(guid); Conditions.checkExpressionFailOnTrue(!GUID.isValid(guidToSet), "Invalid guid [%s] during artifact creation [type: %s]", guidToSet, token); VersionData version = objectFactory.createDefaultVersionData(); version.setBranchId(branch.getUuid()); ModificationType modType = RelationalConstants.DEFAULT_MODIFICATION_TYPE; ArtifactData artifactData = objectFactory.createArtifactData(version, (int) uuid, token, modType, guidToSet); return artifactData; }
Source:
<code>public boolean execute() throws SQLException { executeQuery(); <START> return result != null; <END> }</code><technical_language>clear result is set</technical_language>

Target:
public boolean execute() throws SQLException { return executeQuery() != null; }
Source:
<code>private void openAdminMenu() { administrationDropdownMenu.click(); info("Clicked administration menu"); try { Thread.sleep(500); } catch (InterruptedException e) if (!isDropdownOpened()) { info("Couldn't open administration menu. Trying again."); <START> openMainMenu(); <END> } }</code><technical_language>this</technical_language>

Target:
private void openAdminMenu() { administrationDropdownMenu.click(); info("Clicked administration menu"); if (!mainPage.isDropdownMenuOpened()) { administrationDropdownMenu.click(); info("Clicked administration menu again"); if (!mainPage.isDropdownMenuOpened()) { throw new NoSuchElementException("Tried to open administration menu 2 times without any success"); } } }
Source:
<code>public void testStartCaptivePortalApp() throws Exception { if (!mPackageManager.hasSystemFeature(FEATURE_WIFI)) { Log.i(TAG, "testRegisterNetworkCallback cannot execute unless device supports WiFi"); return; } adoptShellPermissionIdentity(); final List<PackageInfo> apps = mPackageManager.getInstalledPackages(PackageManager.MATCH_ALL); final ArrayList<String> captiveportalApps = new ArrayList<>(); for (PackageInfo app : apps) { List<IntentFilter> filters = mPackageManager.getAllIntentFilters(app.packageName); for (IntentFilter filter : filters) { if (filter.hasAction("android.net.conn.CAPTIVE_PORTAL")) { captiveportalApps.add(app.packageName); } } } assertNotEquals(0, captiveportalApps.size()); captiveportalApps.forEach(name -> mActivityManager.killBackgroundProcesses(name)); assertFalse(isOneOfAppRunning(captiveportalApps)); final Network network = ensureWifiConnected(); final Bundle appExtras = new Bundle(); appExtras.putParcelable(ConnectivityManager.EXTRA_NETWORK, network); mCm.startCaptivePortalApp(network, appExtras); Thread.sleep(200); boolean isCaptivePortalAppRunning = false; for (int i = 0; i < 5; i++) { if (isOneOfAppRunning(captiveportalApps)) { <START> isCaptivePortalAppRunning = <END> true; break; } Thread.sleep(3000); } assertTrue(isCaptivePortalAppRunning); }</code><technical_language>If wifi network device is connected Internet access, captive portal app close immediately. this work if app closes, process is around? If fine. if isOneOfAppRunning starts returning false soon captive portal login activity is dismissed, test flaky. I guess this is fine if run times flaky</technical_language>

Target:
public void testStartCaptivePortalApp() throws Exception { if (!mPackageManager.hasSystemFeature(FEATURE_WIFI)) { Log.i(TAG, "testStartCaptivePortalApp cannot execute unless device supports WiFi"); return; } adoptShellPermissionIdentity(); final List<PackageInfo> apps = mPackageManager.getInstalledPackages(PackageManager.MATCH_ALL); final ArrayList<String> captiveportalApps = new ArrayList<>(); for (PackageInfo app : apps) { List<IntentFilter> filters = mPackageManager.getAllIntentFilters(app.packageName); for (IntentFilter filter : filters) { if (filter.hasAction("android.net.conn.CAPTIVE_PORTAL")) { captiveportalApps.add(app.packageName); } } } assertNotEquals(0, captiveportalApps.size()); captiveportalApps.forEach(name -> mActivityManager.killBackgroundProcesses(name)); assertFalse(isOneOfAppRunning(captiveportalApps)); final Network network = ensureWifiConnected(); final Bundle appExtras = new Bundle(); appExtras.putParcelable(ConnectivityManager.EXTRA_NETWORK, network); mCm.startCaptivePortalApp(network, appExtras); Thread.sleep(200); boolean isCaptivePortalAppRunning = false; for (int i = 0; i < 5; i++) { if (isOneOfAppRunning(captiveportalApps)) { isCaptivePortalAppRunning = true; break; } Thread.sleep(3000); } assertTrue(isCaptivePortalAppRunning); }
Source:
<code>public static List<SessionData> from(List<ScheduleSlot> slots, OffsetTime now) { List<SessionData> sessionData = slots.stream() .filter(slot -> null != slot.getTalk()) <START> .filter(slot -> !slot.getTalk().getTalkType().equals("Ignite Sessions")) <END> .filter(slot -> OffsetTime.parse(slot.getToTime() + "Z").isAfter(now.plusMinutes(10))) .collect(Collectors.groupingBy(slot -> slot.getRoomId())) .entrySet().stream() .map(entry -> entry.getValue().stream().findFirst()) .map(optional -> optional.orElse(null)) .map(SessionData::new) .sorted(SessionData.COMP) .collect(Collectors.toList()); Optional<String> min = sessionData.stream().map(sd -> sd.beginTime).min(Comparator.naturalOrder()); if (min.isPresent()) sessionData = sessionData.stream().filter(sd -> sd.beginTime.equals(min.get())).collect(Collectors.toList()); System.out.println("Possible Next Sessions (" + sessionData.size() + "):\n " + sessionData); return sessionData; }</code><technical_language>This is related issue. please remove</technical_language>

Target:
public static List<SessionData> from(List<ScheduleSlot> slots, OffsetTime now) { List<SessionData> sessionData = slots.stream() .filter(slot -> null != slot.getTalk()) .filter(slot -> OffsetTime.parse(slot.getToTime() + "Z").isAfter(now.plusMinutes(10))) .collect(Collectors.groupingBy(slot -> slot.getRoomId())) .entrySet().stream() .map(entry -> entry.getValue().stream().findFirst()) .map(optional -> optional.orElse(null)) .map(SessionData::new) .sorted(SessionData.COMP) .collect(Collectors.toList()); Optional<String> min = sessionData.stream().map(sd -> sd.beginTime).min(Comparator.naturalOrder()); if (min.isPresent()) sessionData = sessionData.stream().filter(sd -> sd.beginTime.equals(min.get())).collect(Collectors.toList()); System.out.println("Possible Next Sessions (" + sessionData.size() + "):\n " + sessionData); return sessionData; }
Source:
<code>private int scheduleCancelation(Runnable runnable, Long timeLimit) { assert timeLimit > 0L; if (status() != ActionStatus.RUNNING) { if (LRALogger.logger.isDebugEnabled()) { LRALogger.logger.debugf("Ignoring timer because the action status is `%e'", status()); } return Response.Status.PRECONDITION_FAILED.getStatusCode(); } if (finishTime != null) { <START> LocalDateTime ft = LocalDateTime.now().plusNanos(timeLimit * 1000000); <END> if (ft.isAfter(finishTime)) { if (LRALogger.logger.isDebugEnabled()) { LRALogger.logger.debugf( "Ignoring timer for LRA `%s' since there is already an earlier one", id); } return Response.Status.OK.getStatusCode(); } finishTime = ft; if (scheduledAbort != null) { scheduledAbort.cancel(false); } } else { finishTime = LocalDateTime.now(ZoneOffset.UTC).plusNanos(timeLimit * 1000000); } scheduledAbort = scheduler.schedule(runnable, timeLimit, TimeUnit.MILLISECONDS); return Response.Status.OK.getStatusCode(); }</code><technical_language>I missed this previously. This is missing ZoneOffset.UTC</technical_language>

Target:
private int scheduleCancelation(Runnable runnable, Long timeLimit) { assert timeLimit > 0L; if (status() != ActionStatus.RUNNING) { if (LRALogger.logger.isDebugEnabled()) { LRALogger.logger.debugf("Ignoring timer because the action status is `%e'", status()); } return Response.Status.PRECONDITION_FAILED.getStatusCode(); } if (finishTime != null) { LocalDateTime ft = LocalDateTime.now(ZoneOffset.UTC).plusNanos(timeLimit * 1000000); if (ft.isAfter(finishTime)) { if (LRALogger.logger.isDebugEnabled()) { LRALogger.logger.debugf( "Ignoring timer for LRA `%s' since there is already an earlier one", id); } return Response.Status.OK.getStatusCode(); } finishTime = ft; if (scheduledAbort != null) { scheduledAbort.cancel(false); } } else { finishTime = LocalDateTime.now(ZoneOffset.UTC).plusNanos(timeLimit * 1000000); } scheduledAbort = scheduler.schedule(runnable, timeLimit, TimeUnit.MILLISECONDS); return Response.Status.OK.getStatusCode(); }
Source:
<code><START> public void clickOnAddSchemaUrlButton() { <END> new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC) .until(visibilityOf(addSchemaUrlButton)) .click(); }</code><technical_language>please "waitAndClick" method "SeleniumWebDriverHelper"</technical_language>

Target:
public void clickOnAddSchemaUrlButton() { webDriverHelper.waitAndClick(addSchemaUrlButton); }
Source:
<code>private void ensureOpen() { <START> Preconditions.checkState(!closed, "This client was closed."); <END> }</code><technical_language>this check is isolated method, benefit depenency party utility. inline if statement. way, place depend Guava</technical_language>

Target:
private void ensureOpen() { if (closed) { throw new IllegalStateException("This client was closed."); } }
Source:
<code>public String getActualDowntime() { <START> return (actualDowntime == null) ? "(N/A)" : actualDowntime.toString() + "ms"; <END> }</code><technical_language>drop "toString()"</technical_language>

Target:
public String getActualDowntime() { return (actualDowntime == null) ? "(N/A)" : actualDowntime + "ms"; }
Source:
<code>private ICodeSystem getCodeSystem(final String shortName) { try { return requests.prepareGetCodeSystem() .setUniqueId(shortName) .build(BRANCH) .executeSync(bus); <START> } catch (CodeSystemNotFoundException e) { <END> return null; } }</code><technical_language>I suggest removing try-catch this method create another test case verify a non-existent code system throw a NotFoundException. other test cases expect codesystem null. This case get a nice NotFoundException exception a nice message instead of NPEs</technical_language>

Target:
private ICodeSystem getCodeSystem(final String shortName) { return requests.prepareGetCodeSystem() .setUniqueId(shortName) .build(BRANCH) .executeSync(bus); }
Source:
<code>public int compareTo(@NonNull TextTrackScore other) { if (this.isWithinRendererCapabilities != other.isWithinRendererCapabilities) { return this.isWithinRendererCapabilities ? 1 : -1; } if ((this.preferredLanguageScore > 0 || (this.selectUndeterminedTextLanguage && this.trackHasNoLanguage)) == (other.preferredLanguageScore > 0 || (other.selectUndeterminedTextLanguage && other.trackHasNoLanguage))) { if (this.preferredLanguageScore > 0 || (this.selectUndeterminedTextLanguage && this.trackHasNoLanguage)) { if (this.isDefault != other.isDefault) { return this.isDefault ? 1 : -1; } if (this.isForced != other.isForced) { return !this.isForced ? 1 : -1; } return (this.preferredLanguageScore > other.preferredLanguageScore) ? 1 : -1; } else { if (this.isDefault != other.isDefault) { return this.isDefault ? 1 : -1; } if ((this.isForced && (this.selectedAudioLanguageScore > 0 || (this.trackHasNoLanguage && this.stringDefinesNoLang))) != (other.isForced && (other.selectedAudioLanguageScore > 0 || (other.trackHasNoLanguage && other.stringDefinesNoLang)))) { return (this.isForced && (this.selectedAudioLanguageScore > 0 || (this.trackHasNoLanguage && this.stringDefinesNoLang))) ? 1 : -1; } return -1; } } else { <START> return (this.preferredLanguageScore > 0 || (this.selectUndeterminedTextLanguage && this.trackHasNoLanguage)) ? 1 : -1; <END> } }</code><technical_language>move this "else" path avoid high level of indentation? invert condition "if (hasLanguageMatch != other.hasLanguageMatch" return immediately</technical_language>

Target:
public int compareTo(@NonNull TextTrackScore other) { if (this.isWithinRendererCapabilities != other.isWithinRendererCapabilities) { return this.isWithinRendererCapabilities ? 1 : -1; } if (this.hasLanguageMatch != other.hasLanguageMatch) { return this.hasLanguageMatch ? 1 : -1; } if (this.isDefault != other.isDefault) { return this.isDefault ? 1 : -1; } if (this.hasLanguageMatch) { if (this.isForced != other.isForced) { return !this.isForced ? 1 : -1; } return this.preferredLanguageScore - other.preferredLanguageScore; } else { if ((this.isForced && this.hasSelectedAudioLanguageMatch) != (other.isForced && other.hasSelectedAudioLanguageMatch)) { return (this.isForced && this.hasSelectedAudioLanguageMatch) ? 1 : -1; } return 0; } }
Source:
<code>private void waitForServerStartup() throws IOException { log.info("Checking server availability... (Timeout: " + serverStartCheckTimeout + " seconds)"); <START> int currentSeconds = 0; <END> boolean isTimeout = false; while (!isServerListening("localhost", applicationServerPort)) { if (currentSeconds >= 20) { isTimeout = true; break; } try { Thread.sleep(1000); } catch (InterruptedException ignored) { } currentSeconds++; } if (!isTimeout) { isSuccessServerStartup = true; log.info("Server started in " + currentSeconds + " seconds"); } else { isSuccessServerStartup = false; String message = "Server startup timeout."; log.error(message); throw new IOException(message); } }</code><technical_language>I need rename variable here.. currentSeconds refer to? I understand, this is set a ceiling maximum iterations wait for port available</technical_language>

Target:
private void waitForServerStartup() throws IOException { log.info("Checking server availability... (Timeout: " + serverStartCheckTimeout + " seconds)"); int startupCounter = 0; boolean isTimeout = false; while (!isServerListening("localhost", applicationServerPort)) { if (startupCounter >= 20) { isTimeout = true; break; } try { Thread.sleep(1000); } catch (InterruptedException ignored) { } startupCounter++; } if (!isTimeout) { isSuccessServerStartup = true; log.info("Server started."); } else { isSuccessServerStartup = false; String message = "Server startup timeout."; log.error(message); throw new IOException(message); } }
Source:
<code>public void hasNoStorageDomains() { when(spDao.get(any(Guid.class))).thenReturn(createDefaultStoragePool()); when(sdDao.getAllForStoragePool(any(Guid.class))).thenReturn <START> (Collections.EMPTY_LIST); <END> ValidateTestUtils.runAndAssertValidateSuccess(cmd); }</code><technical_language>Please generics-supporting Collections.emptyList()</technical_language>

Target:
public void hasNoStorageDomains() { when(spDao.get(any(Guid.class))).thenReturn(createDefaultStoragePool()); when(sdDao.getAllForStoragePool(any(Guid.class))).thenReturn (Collections.emptyList()); ValidateTestUtils.runAndAssertValidateSuccess(cmd); }
Source:
<code>private RelNode changeTraitsUsingConverters( RelNode rel, RelTraitSet toTraits, boolean allowAbstractConverters) { final RelTraitSet fromTraits = rel.getTraitSet(); assert fromTraits.size() >= toTraits.size(); final boolean allowInfiniteCostConverters = CalciteSystemProperty.ALLOW_INFINITE_COST_CONVERTERS.value(); RelNode converted = rel; for (int i = 0; (converted != null) && (i < toTraits.size()); i++) { RelTrait fromTrait = converted.getTraitSet().getTrait(i); final RelTraitDef traitDef = fromTrait.getTraitDef(); RelTrait toTrait = toTraits.getTrait(i); if (toTrait == null) { continue; } assert traitDef == toTrait.getTraitDef(); if (fromTrait.equals(toTrait)) { continue; } rel = traitDef.convert( this, converted, toTrait, allowInfiniteCostConverters); if (rel != null) { assert rel.getTraitSet().getTrait(traitDef).satisfies(toTrait); <START> if (rel != null) { <END> register(rel, converted); } } if ((rel == null) && allowAbstractConverters) { RelTraitSet stepTraits = converted.getTraitSet().replace(toTrait); rel = getSubset(converted, stepTraits); } converted = rel; } if (converted != null) { assert converted.getTraitSet().satisfies(toTraits); } return converted; }</code><technical_language>need this check anymore</technical_language>

Target:
private RelNode changeTraitsUsingConverters( RelNode rel, RelTraitSet toTraits, boolean allowAbstractConverters) { final RelTraitSet fromTraits = rel.getTraitSet(); assert fromTraits.size() >= toTraits.size(); final boolean allowInfiniteCostConverters = CalciteSystemProperty.ALLOW_INFINITE_COST_CONVERTERS.value(); RelNode converted = rel; for (int i = 0; (converted != null) && (i < toTraits.size()); i++) { RelTrait fromTrait = converted.getTraitSet().getTrait(i); final RelTraitDef traitDef = fromTrait.getTraitDef(); RelTrait toTrait = toTraits.getTrait(i); if (toTrait == null) { continue; } assert traitDef == toTrait.getTraitDef(); if (fromTrait.equals(toTrait)) { continue; } rel = traitDef.convert( this, converted, toTrait, allowInfiniteCostConverters); if (rel != null) { assert rel.getTraitSet().getTrait(traitDef).satisfies(toTrait); register(rel, converted); } else if (allowAbstractConverters) { RelTraitSet stepTraits = converted.getTraitSet().replace(toTrait); rel = getSubset(converted, stepTraits); } converted = rel; } if (converted != null) { assert converted.getTraitSet().satisfies(toTraits); } return converted; }
Source:
<code>public void testGetIOConfigurationSuccess() throws Exception { ATCommandResponse mockedResponse = Mockito.mock(ATCommandResponse.class); Mockito.when(mockedResponse.getResponseStatus()).thenReturn(ATCommandStatus.OK); <START> Mockito.when(mockedResponse.getResponse()).thenReturn(new byte[]{5}); <END> Mockito.doReturn(mockedResponse).when(xbeeDevice).sendATCommand((ATCommand)Mockito.any()); IOMode ioMode = null; try { ioMode = xbeeDevice.getIOConfiguration(IOLine.DIO0_AD0); } catch (InvalidOperatingModeException e) { fail("This exception shouldn't be thrown now."); } catch (XBeeException e) { fail("This exception shouldn't be thrown now."); } assertEquals(IOMode.DIGITAL_OUT_HIGH, ioMode); }</code><technical_language>Replace 5 IOMode.DIGITAL_OUT_HIGH.getId()</technical_language>

Target:
public void testGetIOConfigurationSuccess() throws Exception { ATCommandResponse mockedResponse = Mockito.mock(ATCommandResponse.class); Mockito.when(mockedResponse.getResponseStatus()).thenReturn(ATCommandStatus.OK); Mockito.when(mockedResponse.getResponse()).thenReturn(new byte[]{(byte)IOMode.DIGITAL_OUT_HIGH.getID()}); Mockito.doReturn(mockedResponse).when(xbeeDevice).sendATCommand((ATCommand)Mockito.any()); IOMode ioMode = xbeeDevice.getIOConfiguration(IOLine.DIO0_AD0); assertEquals(IOMode.DIGITAL_OUT_HIGH, ioMode); }
Source:
<code>private String getJSON(List<Contentlet> cons, HttpServletRequest request, HttpServletResponse response, String render, User user) throws IOException, DotDataException{ JSONObject json = new JSONObject(); JSONArray jsonCons = new JSONArray(); for(Contentlet c : cons){ try { JSONObject jo = contentletToJSON(c, request, response, render, user); <START> if (c.getStructure().getStructureType() == Structure.STRUCTURE_TYPE_HTMLPAGE){ <END> jo.put(HTMLPageAssetAPI.URL_FIELD, this.contentHelper.getUrl(c)); } jsonCons.put(jo); } catch (Exception e) { Logger.warn(this.getClass(), "unable JSON contentlet " + c.getIdentifier()); Logger.debug(this.getClass(), "unable to find contentlet", e); } } try { json.put("contentlets", jsonCons); } catch (JSONException e) { Logger.warn(this.getClass(), "unable to create JSONObject"); Logger.debug(this.getClass(), "unable to create JSONObject", e); } return json.toString(); }</code><technical_language>here: if (BaseContentType.HTMLPAGE.equals(c.getContentType().baseType())) {</technical_language>

Target:
private String getJSON(List<Contentlet> cons, HttpServletRequest request, HttpServletResponse response, String render, User user) throws IOException, DotDataException{ JSONObject json = new JSONObject(); JSONArray jsonCons = new JSONArray(); for(Contentlet c : cons){ try { JSONObject jo = contentletToJSON(c, request, response, render, user); if (BaseContentType.HTMLPAGE.equals(c.getContentType().baseType())){ jo.put(HTMLPageAssetAPI.URL_FIELD, this.contentHelper.getUrl(c)); } jsonCons.put(jo); } catch (Exception e) { Logger.warn(this.getClass(), "unable JSON contentlet " + c.getIdentifier()); Logger.debug(this.getClass(), "unable to find contentlet", e); } } try { json.put("contentlets", jsonCons); } catch (JSONException e) { Logger.warn(this.getClass(), "unable to create JSONObject"); Logger.debug(this.getClass(), "unable to create JSONObject", e); } return json.toString(); }
Source:
<code>protected ToStringBuilder appendAttributes(ToStringBuilder tsb) { return super.appendAttributes(tsb) .append("imageId", getImageId()) <START> .append("force", isAllowActive()); <END> }</code><technical_language>wondering, force means here</technical_language>

Target:
protected ToStringBuilder appendAttributes(ToStringBuilder tsb) { return super.appendAttributes(tsb) .append("imageId", getImageId()) .append("allowActive", isAllowActive()); }
Source:
<code>private void populateIncludeFields() { includeFields = new String[2][]; <START> String[] portFields = includeFieldStr.split(";"); <END> for (int i = 0; i < portFields.length; i++) { includeFields[i] = portFields[i].split(","); } }</code><technical_language>Do want check portFields is of size 2</technical_language>

Target:
private void populateIncludeFields() { String[] portFields = includeFieldStr.split(";"); assert (portFields.length == 2); leftStore.setIncludeFields(portFields[0].split(",")); rightStore.setIncludeFields(portFields[1].split(",")); }
Source:
<code><START> private void verifyUapBtf(long btfId, String slotName, String bottomSlotName, AdsFandomObject fandomPage) { <END> fandomPage.verifySlot(slotName); Assertion.assertEquals(btfId, fandomPage.getLineItemId(AdsFandomContent.INCONTENT_BOXAD)); fandomPage.verifySlot(bottomSlotName); Assertion.assertEquals(btfId, fandomPage.getLineItemId(AdsFandomContent.BOTTOM_LEADERBOARD)); Assertion.assertNull(fandomPage.getSlot(AdsFandomContent.BOTTOM_BOXAD)); }</code><technical_language>![MAJOR](<LINK_0> 'Severity: MAJOR') Remove this unused private "verifyUapBtf" method. [![rule](<LINK_1>](http://sonar-s4/coding_rules#rule_key=squid%3AUnusedPrivateMethod)</technical_language>

Target:
private void verifyUapBtf(long btfId, String slotName, String bottomSlotName, AdsFandomObject fandomPage) { fandomPage.verifySlot(slotName); Assertion.assertEquals(btfId, fandomPage.getLineItemId(slotName)); fandomPage.verifySlot(bottomSlotName); Assertion.assertEquals(btfId, fandomPage.getLineItemId(bottomSlotName)); }
Source:
<code>public boolean isExcludeFirstHeading() { <START> return this.isExcludeFirstHeading; <END> }</code><technical_language>I talked field for starting "is" sense, start "get"</technical_language>

Target:
public boolean isExcludeFirstHeading() { return this.excludeFirstHeading; }
Source:
<code>private void processResults(final Response response, final Map<String, PyPiLink> results) throws Exception { checkNotNull(response); checkNotNull(results); Payload payload = checkNotNull(response.getPayload()); try (InputStream in = payload.openInputStream()) { List<PyPiLink> links = PyPiIndexUtils.extractLinksFromIndex(in); <START> for (PyPiLink link: links) { <END> String file = link.getFile(); if (!results.containsKey(file)) { results.put(file, link); } } } }</code><technical_language>Trivial: broken formating. **for (PyPiLink link: links)**</technical_language>

Target:
private void processResults(final Response response, final Map<String, PyPiLink> results) throws IOException { checkNotNull(response); checkNotNull(results); Payload payload = checkNotNull(response.getPayload()); try (InputStream in = payload.openInputStream()) { List<PyPiLink> links = PyPiIndexUtils.extractLinksFromIndex(in); for (PyPiLink link : links) { String file = link.getFile(); if (!results.containsKey(file)) { results.put(file, link); } } } }
Source:
<code>public void enqueue(final ByteBuffer b[]) { assert(b != null); for (ByteBuffer buf : b) { assert(!buf.isDirect()); if (buf.remaining() == 0) { throw new IllegalArgumentException("Attempted to queue a zero length buffer"); } } synchronized (this) { if (m_isShutdown) { return; } updateLastPendingWriteTimeAndQueueBackpressure(); for (final ByteBuffer buf : b) { if (m_isSSLConfigured) { <START> Iterator<DeferredSerialization> dsIter = new SSLDeferredSerializationIterator(m_sslEngine, new Serializer() { <END> @Override public ByteBuffer serialize() { return buf; } }); while (dsIter.hasNext()) { m_queuedWrites.offer(dsIter.next()); } } else { m_queuedWrites.offer(new DeferredSerialization() { @Override public ByteBuffer serialize(ByteBuffer outbuf) { if (outbuf.remaining() >= buf.remaining()) { outbuf.put(buf); return null; } else { ByteBuffer allocated = ByteBuffer.allocate(buf.remaining()); allocated.put(buf); allocated.flip(); return allocated; } } @Override public void cancel() @Override public int getSerializedSize() { return buf.remaining(); } }); } } m_port.setInterests( SelectionKey.OP_WRITE, 0); } }</code><technical_language>this merged ? I case of ssl itarator point one</technical_language>

Target:
public void enqueue(final ByteBuffer b[]) { assert(b != null); for (ByteBuffer buf : b) { assert(!buf.isDirect()); if (buf.remaining() == 0) { throw new IllegalArgumentException("Attempted to queue a zero length buffer"); } } synchronized (this) { if (m_isShutdown) { return; } updateLastPendingWriteTimeAndQueueBackpressure(); m_queuedWrites.offer(new DeferredSerialization() { @Override public void serialize(ByteBuffer outbuf) { for (ByteBuffer buf : b) { outbuf.put(buf); } } @Override public void cancel() @Override public int getSerializedSize() { int sum = 0; for (ByteBuffer buf : b) { buf.position(0); sum += buf.remaining(); } return sum; } }); m_port.setInterests( SelectionKey.OP_WRITE, 0); } }
Source:
<code>private void dispatch() { Event ev; if (inDispatch) { return; } try { inDispatch = true; while ((ev = collector.peek()) != null) { for (EventHandler h : handlers) { if (log.isTraceEnabled()) { log.trace("Handling " + ev + " towards " + h); } <START> if (AuditLogger.isAnyLoggingEnabled()) { <END> AuditLogger.setRemoteAddress(h.getRemoteAddress()); } try { Events.dispatch(ev, h); } catch (ActiveMQSecurityException e) { log.warn(e.getMessage(), e); ErrorCondition error = new ErrorCondition(); error.setCondition(AmqpError.UNAUTHORIZED_ACCESS); error.setDescription(e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage()); connection.setCondition(error); connection.close(); } catch (Exception e) { log.warn(e.getMessage(), e); ErrorCondition error = new ErrorCondition(); error.setCondition(AmqpError.INTERNAL_ERROR); error.setDescription("Unrecoverable error: " + (e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage())); connection.setCondition(error); connection.close(); } } collector.pop(); } } finally { inDispatch = false; } flushBytes(); }</code><technical_language>Do need do this for event? need this once.. I do this beggining of method, loop starts</technical_language>

Target:
private void dispatch() { Event ev; if (inDispatch) { return; } try { inDispatch = true; if (AuditLogger.isAnyLoggingEnabled()) { for (EventHandler h : handlers) { AuditLogger.setRemoteAddress(h.getRemoteAddress()); } } while ((ev = collector.peek()) != null) { for (EventHandler h : handlers) { if (log.isTraceEnabled()) { log.trace("Handling " + ev + " towards " + h); } try { Events.dispatch(ev, h); } catch (ActiveMQSecurityException e) { log.warn(e.getMessage(), e); ErrorCondition error = new ErrorCondition(); error.setCondition(AmqpError.UNAUTHORIZED_ACCESS); error.setDescription(e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage()); connection.setCondition(error); connection.close(); } catch (Exception e) { log.warn(e.getMessage(), e); ErrorCondition error = new ErrorCondition(); error.setCondition(AmqpError.INTERNAL_ERROR); error.setDescription("Unrecoverable error: " + (e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage())); connection.setCondition(error); connection.close(); } } collector.pop(); } } finally { inDispatch = false; } flushBytes(); }
Source:
<code>public void setPatientId(String patientIdentifierIso) { if (StringUtils.isNotBlank(patientIdentifierIso)) { String[] identifierValue = patientIdentifierIso.split("&"); CoreHelpUtils.updateDocumentBy(withDocument, wsService.getPatientBy(identifierValue[0].replace("^^^", ""), identifierValue[1])); } else { <START> throw new RuntimeException("PatientIdentifier should not be empty."); <END> } }</code><technical_language>Need throw a customized exception</technical_language>

Target:
public void setPatientId(String patientIdentifierIso) { if (StringUtils.isNotBlank(patientIdentifierIso)) { String[] identifierValue = patientIdentifierIso.split("&"); CoreHelpUtils.updateDocumentBy(withDocument, wsService.getPatientBy(identifierValue[0].replace("^^^", ""), identifierValue[1])); } else { throw new ValidationException("PatientIdentifier should not be empty."); } }
Source:
<code><START> public void readRelationships(HttpServletRequest request, HttpServletResponse response, <END> @PathVariable("doi") String doi) throws IOException { new Transceiver() { @Override protected RelationshipSetView getData() throws IOException { ArticleIdentifier id = ArticleIdentifier.create(DoiEscaping.unescape(doi)); return relationshipSetViewFactory.getSetView(id); } @Override protected Calendar getLastModifiedDate() throws IOException { return null; } }.respond(request, response, entityGson); }</code><technical_language>this method a Transciever respond, named 'serve', 'read'</technical_language>

Target:
public void readRelationships(HttpServletRequest request, HttpServletResponse response, @PathVariable("doi") String doi) throws IOException { ArticleIdentifier id = ArticleIdentifier.create(DoiEscaping.unescape(doi)); Transceiver.serveUntimestampedView(() -> relationshipSetViewFactory.getSetView(id)) .respond(request, response, entityGson); }
Source:
<code>public void testLoadJAASConfigOnce() { File loginConfigFile = createTestKrb5LoginConfigFile(); Configuration conf1 = null; Configuration conf2 = null; try { System.setProperty(GatewayConfig.KRB5_LOGIN_CONFIG, loginConfigFile.getAbsolutePath()); conf1 = AuthUtils.getKerberosJAASConfiguration(); conf2 = AuthUtils.getKerberosJAASConfiguration(); } catch (Throwable e) { e.printStackTrace(); <START> fail(e.getMessage()); <END> } finally { System.clearProperty(GatewayConfig.KRB5_LOGIN_CONFIG); } assertNotNull(conf1); assertNotNull(conf2); assertSame(conf1, conf2); }</code><technical_language>able fail(e) prints stacktrace</technical_language>

Target:
public void testLoadJAASConfigOnce() { File loginConfigFile = createTestKrb5LoginConfigFile(); Configuration conf1 = null; Configuration conf2 = null; try { System.setProperty(GatewayConfig.KRB5_LOGIN_CONFIG, loginConfigFile.getAbsolutePath()); conf1 = AuthUtils.getKerberosJAASConfiguration(); conf2 = AuthUtils.getKerberosJAASConfiguration(); } catch (Throwable e) { fail(e.getMessage()); } finally { System.clearProperty(GatewayConfig.KRB5_LOGIN_CONFIG); } assertNotNull(conf1); assertNotNull(conf2); assertSame(conf1, conf2); }
Source:
<code>public void su_destroy_process_sigkill_after_graceful_timeout() throws Exception { LinuxProcessBuilder processBuilder = new LinuxProcessBuilder(new OSUser(username, password), null, <START> proactiveHome); <END> Process process = processBuilder .command("trap \"echo trapped signal\" SIGTERM; echo $$; while true; do sleep 1; done") .start(); process.destroy(); int exitCode = process.waitFor(); System.out.println("[SU_DESTROYPROCESS] process terminated with exit code " + exitCode); assertEquals(0, exitCode); }</code><technical_language>set proactive.process.builder.cleanup.time.seconds=2 avoid waiting for a long period in test</technical_language>

Target:
public void su_destroy_process_sigkill_after_graceful_timeout() throws Exception { LinuxProcessBuilder processBuilder = new LinuxProcessBuilder(new OSUser(username, password), null, proactiveHome); System.setProperty("proactive.process.builder.cleanup.time.seconds", "1"); Process process = processBuilder .command("trap \"echo trapped signal\" SIGTERM; echo $$; while true; do sleep 1; done") .start(); process.destroy(); int exitCode = process.waitFor(); System.out.println("[SU_DESTROYPROCESS] process terminated with exit code " + exitCode); assertEquals(0, exitCode); System.clearProperty("proactive.process.builder.cleanup.time.seconds"); }
Source:
<code>public void run() { log.debug("Subscribing consumer to {}", topic); consumer.subscribe(Collections.singleton(topic)); log.debug("Seeking to beginning"); consumer.seekToBeginning(consumer.assignment()); POLL_LOOP: while (running.get()) { log.trace("Polling"); ConsumerRecords<String, String> consumerRecords = consumer.poll(POLL_DURATION_MS); if (consumerRecords.isEmpty()) { log.trace("0 messages fetched on poll"); if (cacheReadyLatch.getCount() > 0) { log.debug("Cache warmed up"); cacheReadyLatch.countDown(); } } for (ConsumerRecord<String, String> consumerRecord: consumerRecords) { CacheAction action; try { action = CacheAction.valueOf(consumerRecord.value()); } catch (IllegalArgumentException iax) { log.error("Unexpected action value:\"{}\" received on [topic:{}, partition:{}, offset:{}]. Shutting down.", consumerRecord.key(), consumerRecord.topic(), consumerRecord.partition(), consumerRecord.offset()); setRunning(false); continue POLL_LOOP; } String messageId = consumerRecord.key(); if (action == CacheAction.add) { log.debug("Adding to cache messageId:{}", messageId); cache.put(messageId, messageId); } else if (action == CacheAction.remove) { log.debug("Removing from cache messageId:{}", messageId); cache.remove(messageId); } else if (action == CacheAction.clear) { cache.clear(); } else { <START> log.error("No idea how to a record. Shutting down.", action); <END> setRunning(false); continue POLL_LOOP; } } } log.debug("TopicPoller finished - triggering shutdown latch"); shutdownLatch.countDown(); }</code><technical_language>a WARN</technical_language>

Target:
public void run() { log.debug("Subscribing consumer to {}", topic); consumer.subscribe(Collections.singleton(topic)); log.debug("Seeking to beginning"); consumer.seekToBeginning(consumer.assignment()); POLL_LOOP: while (running.get()) { log.trace("Polling"); ConsumerRecords<String, String> consumerRecords = consumer.poll(pollDurationMs); if (consumerRecords.isEmpty()) { log.trace("0 messages fetched on poll"); if (cacheReadyLatch.getCount() > 0) { log.debug("Cache warmed up"); cacheReadyLatch.countDown(); } } for (ConsumerRecord<String, String> consumerRecord: consumerRecords) { CacheAction action; try { action = CacheAction.valueOf(consumerRecord.value()); } catch (IllegalArgumentException iax) { log.error("Unexpected action value:\"{}\" received on [topic:{}, partition:{}, offset:{}]. Shutting down.", consumerRecord.key(), consumerRecord.topic(), consumerRecord.partition(), consumerRecord.offset()); setRunning(false); continue POLL_LOOP; } String messageId = consumerRecord.key(); if (action == CacheAction.add) { log.debug("Adding to cache messageId:{}", messageId); cache.put(messageId, messageId); } else if (action == CacheAction.remove) { log.debug("Removing from cache messageId:{}", messageId); cache.remove(messageId); } else if (action == CacheAction.clear) { cache.clear(); } else { log.warn("No idea how to a record. Shutting down.", action); setRunning(false); continue POLL_LOOP; } } } log.debug("TopicPoller finished - triggering shutdown latch"); shutdownLatch.countDown(); }
Source:
<code><START> public ChronoPeriod until(final ChronoLocalDate endDateExclusive) { <END> InternationalFixedDate end = InternationalFixedDate.from(endDateExclusive); int years = Math.toIntExact(yearsUntil(end)); InternationalFixedDate sameYearEnd = (InternationalFixedDate) end.plusYears(years); int months = (int) monthsUntil(sameYearEnd); int days = (int) daysUntil(sameYearEnd.plusMonths(months)); return getChronology().period(years, months, days); }</code><technical_language>until(...) piggyback monthsUntil(...) for year/month fields (see Discordian)</technical_language>

Target:
public ChronoPeriod until(final ChronoLocalDate endDateExclusive) { InternationalFixedDate end = InternationalFixedDate.from(endDateExclusive); int years = Math.toIntExact(yearsUntil(end)); InternationalFixedDate sameYearEnd = plusYears(years); int months = (int) sameYearEnd.monthsUntil(end); int days = (int) sameYearEnd.plusMonths(months).daysUntil(end); if (days == DAYS_IN_MONTH) { days = 0; months += 1; } if (days == -DAYS_IN_MONTH) { days = 0; months -= 1; } return getChronology().period(years, months, days); }
Source:
<code>public void testExchange() { BigInteger primeA = BigInteger.valueOf(23); BigInteger primeB = BigInteger.valueOf(5); BigInteger alicePrivateKey = diffieHellman.privateKey(primeA); BigInteger bobPrivateKey = diffieHellman.privateKey(primeB); BigInteger publicKeyA = diffieHellman.publicKey(primeA, primeB, alicePrivateKey); BigInteger publicKeyB = diffieHellman.publicKey(primeA, primeB, bobPrivateKey); <START> BigInteger secretA = diffieHellman.secret(primeA, publicKeyB, alicePrivateKey); <END> BigInteger secretB = diffieHellman.secret(primeA, publicKeyA, bobPrivateKey); assertEquals(secretA, secretB); }</code><technical_language>renamed PrivateKeys reflect canonical data, is worth PublicKeys</technical_language>

Target:
public void testExchange() { BigInteger primeA = BigInteger.valueOf(23); BigInteger primeB = BigInteger.valueOf(5); BigInteger alicePrivateKey = diffieHellman.privateKey(primeA); BigInteger bobPrivateKey = diffieHellman.privateKey(primeB); BigInteger alicePublicKey = diffieHellman.publicKey(primeA, primeB, alicePrivateKey); BigInteger bobPublicKey = diffieHellman.publicKey(primeA, primeB, bobPrivateKey); BigInteger secretA = diffieHellman.secret(primeA, bobPublicKey, alicePrivateKey); BigInteger secretB = diffieHellman.secret(primeA, alicePublicKey, bobPrivateKey); assertEquals(secretA, secretB); }