auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected void setOrdinal(int ordinal, boolean forced) { <START> if (forced) { <END> this.ordinal = ordinal; } }</code><technical_language>This weird. If caller enough pass forced not, able call method forced is false</technical_language>

Target:
protected void setOrdinal(int ordinal, boolean forced) { if (forced) { this.ordinal = ordinal; } else { setOrdinal(ordinal); } }
Source:
<code>public Response add(GlusterBricks bricks) { for (GlusterBrick brick : bricks.getGlusterBricks()) { validateParameters(brick, "serverId", "brickDir"); } List<GlusterBrickEntity> brickEntities = mapBricks(asGuid(getVolumeId()), bricks); int replicaCount = bricks.isSetNewReplicaCount() ? bricks.getNewReplicaCount() : 0; int stripeCount = bricks.isSetNewStripeCount() ? bricks.getNewStripeCount() : 0; <START> return performCreationMultiple(VdcActionType.AddBricksToGlusterVolume, <END> new GlusterVolumeBricksActionParameters(asGuid(getVolumeId()), brickEntities, replicaCount, stripeCount), new QueryIdResolver(VdcQueryType.GetGlusterBrickById, IdQueryParameters.class)); }</code><technical_language>performCreation()?, i special in performCreationMultiple(), note performCreation() blocking caps</technical_language>

Target:
public Response add(GlusterBricks bricks) { for (GlusterBrick brick : bricks.getGlusterBricks()) { validateParameters(brick, "serverId", "brickDir"); } List<GlusterBrickEntity> brickEntities = mapBricks(asGuid(getVolumeId()), bricks); int replicaCount = bricks.isSetReplicaCount() ? bricks.getReplicaCount() : 0; int stripeCount = bricks.isSetStripeCount() ? bricks.getStripeCount() : 0; return performCreationMultiple(VdcActionType.AddBricksToGlusterVolume, new GlusterVolumeBricksActionParameters(asGuid(getVolumeId()), brickEntities, replicaCount, stripeCount), new QueryIdResolver(VdcQueryType.GetGlusterBrickById, IdQueryParameters.class)); }
Source:
<code>public void leaderCanProcessMultiClientLeaderTimeRequest() { TestableTimelockServer leader = cluster.currentLeaderFor(client.namespace()); MultiClientConjureTimelockService multiClientConjureTimelockService = leader.multiClientService(); Set<String> expectedNamespaces = ImmutableSet.of("alpha", "beta"); List<NamespacedLeaderTime> leaderTimes = multiClientConjureTimelockService.leaderTimes(AUTH_HEADER, expectedNamespaces); Set<String> namespaces = leaderTimes.stream().map(NamespacedLeaderTime::getNamespace).collect(Collectors.toSet()); assertThat(namespaces).hasSameElementsAs(expectedNamespaces); Set<LeadershipId> leadershipIds = leaderTimes.stream() .map(NamespacedLeaderTime::getLeaderTime) .map(LeaderTime::id) .collect(Collectors.toSet()); <START> assertThat(leadershipIds).hasSameSizeAs(expectedNamespaces); <END> }</code><technical_language>a bit overkill: if run regular conjuretimelockservice.getLeaderTime get answer right</technical_language>

Target:
public void leaderCanProcessMultiClientLeaderTimeRequest() { TestableTimelockServer leader = cluster.currentLeaderFor(client.namespace()); MultiClientConjureTimelockService multiClientConjureTimelockService = leader.multiClientService(); Set<String> expectedNamespaces = ImmutableSet.of("alpha", "beta"); List<NamespacedLeaderTime> leaderTimes = multiClientConjureTimelockService.leaderTimes(AUTH_HEADER, expectedNamespaces); Set<String> namespaces = leaderTimes.stream().map(NamespacedLeaderTime::getNamespace).collect(Collectors.toSet()); assertThat(namespaces).hasSameElementsAs(expectedNamespaces); Set<UUID> leadershipIds = leaderTimes.stream() .map(NamespacedLeaderTime::getLeaderTime) .map(LeaderTime::id) .map(LeadershipId::id) .collect(Collectors.toSet()); assertThat(leadershipIds).hasSameSizeAs(expectedNamespaces); }
Source:
<code>public static <T> BinaryOperator<T> ensureOnlyOne() { return (a, b) -> { <START> throw new IllegalArgumentException(Messages.format("Duplicates found: and {}", a, b)); <END> }; }</code><technical_language>message is a bit misleading. a b duplicates. "Multiple values found:"</technical_language>

Target:
public static <T> BinaryOperator<T> ensureOnlyOne() { return (a, b) -> { throw new IllegalArgumentException(Messages.format( "Multiple values found where only one was expected: and {}", a, b)); }; }
Source:
<code>private void waitUntilCheck(Predicate<JsonRpcClient> check, <START> String formatBefore, String <END> formatAfter) throws InterruptedException { if (logger.isDebugEnabled()) { logger.debug(formatBefore, client.getHostname()); } int retries = 50; while (check.test(this.client)) { if (retries == 0) { throw new VDSNetworkException("Unable to reconnect to " + client.getHostname() + " after policy reset"); } retries--; TimeUnit.MILLISECONDS.sleep(200); } if (logger.isDebugEnabled()) { logger.debug(formatAfter, client.getHostname()); } }</code><technical_language>a nitpicking: if pass format message variables expecting others fill correctly. For this usecase sufficient pass logBefore log after, this method add suffix informing hostname. Format of message maintained of method, while varying before/after description passed in. formatBefore inform reader, this is pattern produce logging message. fix mentioned above</technical_language>

Target:
private void waitUntilCheck(Predicate<JsonRpcClient> check, String formatBefore, String formatAfter) throws InterruptedException { String hostname = client.getHostname(); if (logger.isDebugEnabled()) { logger.debug(formatBefore, hostname); } int retries = 50; while (check.test(this.client)) { if (retries == 0) { throw new VDSNetworkException("Unable to reconnect to " + hostname + " after policy reset"); } retries--; TimeUnit.MILLISECONDS.sleep(200); } if (logger.isDebugEnabled()) { logger.debug(formatAfter, hostname); } }
Source:
<code>protected State collectInput() { String filePatterns = listPresetFilePatterns_.getValue( listPresetFilePatterns_.getSelectedIndex()); if (filePatterns == "custom") filePatterns = txtFilePattern_.getText(); ArrayList<String> list = new ArrayList<String>(); for (String pattern : filePatterns.split(",")) { String trimmedPattern = pattern.trim(); if (trimmedPattern.length() > 0) list.add(trimmedPattern); } String excludeFilePatterns = listPresetExcludeFilePatterns_.getValue( listPresetExcludeFilePatterns_.getSelectedIndex()); <START> if (excludeFilePatterns == "custom") <END> excludeFilePatterns = txtExcludeFilePattern_.getText(); ArrayList<String> excludeList = new ArrayList<String>(); for (String pattern : excludeFilePatterns.split(",")) { String trimmedPattern = pattern.trim(); if (trimmedPattern.length() > 0) excludeList.add(trimmedPattern); } return State.createState(txtSearchPattern_.getText(), getEffectivePath().getPath(), checkboxRegex_.getValue(), checkboxCaseSensitive_.getValue(), JsUtil.toJsArrayString(list), JsUtil.toJsArrayString(excludeList)); }</code><technical_language>Nit: for complicated reasons, prefer StringUtil.equals (GWT changed string comparison works releases!)</technical_language>

Target:
protected State collectInput() { String includeFilePatterns = listPresetFilePatterns_.getValue( listPresetFilePatterns_.getSelectedIndex()); if (includeFilePatterns == "custom") includeFilePatterns = txtFilePattern_.getText(); ArrayList<String> list = new ArrayList<String>(); for (String pattern : includeFilePatterns.split(",")) { String trimmedPattern = pattern.trim(); if (trimmedPattern.length() > 0) list.add(trimmedPattern); } String excludeFilePatterns = listPresetExcludeFilePatterns_.getValue( listPresetExcludeFilePatterns_.getSelectedIndex()); if (StringUtil.equals(excludeFilePatterns, "custom")) excludeFilePatterns = txtExcludeFilePattern_.getText(); ArrayList<String> excludeList = new ArrayList<String>(); for (String pattern : excludeFilePatterns.split(",")) { String trimmedPattern = pattern.trim(); if (trimmedPattern.length() > 0) excludeList.add(trimmedPattern); } return State.createState(txtSearchPattern_.getText(), getEffectivePath().getPath(), checkboxRegex_.getValue(), checkboxCaseSensitive_.getValue(), JsUtil.toJsArrayString(list), JsUtil.toJsArrayString(excludeList)); }
Source:
<code>public static void refreshSizeEstimates(String keyspace, String table) throws Exception { long deadline = System.nanoTime() + REFRESH_SIZE_ESTIMATES_TIMEOUT.roundTo(NANOSECONDS); while (System.nanoTime() < deadline) { flushTable(keyspace, table); refreshSizeEstimates(); List<SizeEstimate> sizeEstimates = getSession().getSizeEstimates(keyspace, table); if (!sizeEstimates.isEmpty()) { log.info("Size estimates for the table %s.%s have been refreshed successfully: %s", keyspace, table, sizeEstimates); return; } log.info("Size estimates haven't been refreshed as expected. Retrying ..."); } <START> throw new TimeoutException(format("Size estimates refresh for the table %s.%s has been timed out after %s", keyspace, table, REFRESH_SIZE_ESTIMATES_TIMEOUT)); <END> }</code><technical_language>s/has timed out/has timed out (or "timed out")</technical_language>

Target:
public static void refreshSizeEstimates(String keyspace, String table) throws Exception { long deadline = System.nanoTime() + REFRESH_SIZE_ESTIMATES_TIMEOUT.roundTo(NANOSECONDS); while (System.nanoTime() < deadline) { flushTable(keyspace, table); refreshSizeEstimates(); List<SizeEstimate> sizeEstimates = getSession().getSizeEstimates(keyspace, table); if (!sizeEstimates.isEmpty()) { log.info("Size estimates for the table %s.%s have been refreshed successfully: %s", keyspace, table, sizeEstimates); return; } log.info("Size estimates haven't been refreshed as expected. Retrying ..."); } throw new TimeoutException(format("Attempting to refresh size estimates for table %s.%s has timed out after %s", keyspace, table, REFRESH_SIZE_ESTIMATES_TIMEOUT)); }
Source:
<code>public void mergeRequests(long ts, Request baseRequest, Request mergedRequest) { int mergedQuark = removeWaitingRequest(ts, mergedRequest.getSector()); Long baseSector = baseRequest.getSector(); baseRequest.mergeRequest(mergedRequest); int baseQuark = updateWaitingRequest(ts, baseRequest, baseSector); if (mergedQuark != ITmfStateSystem.INVALID_ATTRIBUTE) { try { int issuedFromQuark = fSs.getQuarkRelativeAndAdd(mergedQuark, Attributes.MERGED_IN); <START> fSs.modifyAttribute(ts, fSs.getAttributeName(baseQuark), issuedFromQuark); <END> } catch (StateValueTypeException e) { Activator.getDefault().logError("Error adding the merged request information", e); } } updateQueuesLength(ts); }</code><technical_language>Integer.parseInt</technical_language>

Target:
public void mergeRequests(long ts, Request baseRequest, Request mergedRequest) { int mergedQuark = removeWaitingRequest(ts, mergedRequest.getSector()); Long baseSector = baseRequest.getSector(); baseRequest.mergeRequest(mergedRequest); int baseQuark = updateWaitingRequest(ts, baseRequest, baseSector); if (mergedQuark != ITmfStateSystem.INVALID_ATTRIBUTE) { try { int issuedFromQuark = fSs.getQuarkRelativeAndAdd(mergedQuark, Attributes.MERGED_IN); fSs.modifyAttribute(ts, Integer.parseInt(fSs.getAttributeName(baseQuark)), issuedFromQuark); } catch (StateValueTypeException e) { Activator.getDefault().logError("Error adding the merged request information", e); } } updateQueuesLength(ts); }
Source:
<code>public static UseCase createUseCase(final Class<?> testClass) { String description = ""; String name = UseCaseDummyConfiguration.getUseCaseName(testClass, MultipleBuildsRule.getCurrentBuildRun()); if(name == null) { name = getNameFromClass(testClass); <START> } <END> DocuDescription docuDescription = testClass.getAnnotation(DocuDescription.class); if (docuDescription != null) { description = docuDescription.description(); } UseCase useCase = new UseCase(); useCase.setName(name); useCase.setDescription(description); useCase.addDetail("Webtest Class", testClass.getName()); addLabelsIfPresentOnTestClass(testClass, useCase); return useCase; }</code><technical_language>@danielsuter This done more elegantly. improve for you</technical_language>

Target:
public static UseCase createUseCase(final Class<?> testClass) { String description = ""; String name = getNameFromClass(testClass); DocuDescription docuDescription = testClass.getAnnotation(DocuDescription.class); if (docuDescription != null) { description = docuDescription.description(); } UseCase useCase = new UseCase(); useCase.setName(name); useCase.setDescription(description); useCase.addDetail("Webtest Class", testClass.getName()); addLabelsIfPresentOnTestClass(testClass, useCase); return useCase; }
Source:
<code>public void testParsePersonIdent_legalCases() { final Date when = new Date(1234567890000l); final TimeZone tz = TimeZone.getTimeZone("GMT-7"); assertPersonIdent("Me <me@example.com> 1234567890 -0700", 0, new PersonIdent("Me", "me@example.com", when, tz)); assertPersonIdent(" Me <me@example.com> 1234567890 -0700", 0, new PersonIdent(" Me", "me@example.com", when, tz)); assertPersonIdent("A U Thor <author@example.com> 1234567890 -0700", 0, new PersonIdent("A U Thor", "author@example.com", when, tz)); assertPersonIdent("A U Thor<author@example.com> 1234567890 -0700", 0, new PersonIdent("A U Thor", "author@example.com", when, tz)); assertPersonIdent("A U Thor<author@example.com>1234567890 -0700", 0, new PersonIdent("A U Thor", "author@example.com", when, tz)); assertPersonIdent(" A U Thor < author@example.com > 1234567890 -0700", 0, new PersonIdent(" A U Thor ", " author@example.com ", when, tz)); assertPersonIdent("A U Thor<author@example.com>1234567890 -0700", 0, new PersonIdent("A U Thor", "author@example.com", when, tz)); assertPersonIdent( <START> "A U Thor <author@example.com>, C O. Miter <comiter@example.com> 1234567890 -0700", <END> 0, new PersonIdent("A U Thor", "author@example.com", when, tz)); }</code><technical_language>I call this a legal case. move a new testParsePersonIdent_fuzzyCases()</technical_language>

Target:
public void testParsePersonIdent_legalCases() { final Date when = new Date(1234567890000l); final TimeZone tz = TimeZone.getTimeZone("GMT-7"); assertPersonIdent("Me <me@example.com> 1234567890 -0700", new PersonIdent("Me", "me@example.com", when, tz)); assertPersonIdent(" Me <me@example.com> 1234567890 -0700", new PersonIdent(" Me", "me@example.com", when, tz)); assertPersonIdent("A U Thor <author@example.com> 1234567890 -0700", new PersonIdent("A U Thor", "author@example.com", when, tz)); assertPersonIdent("A U Thor<author@example.com> 1234567890 -0700", new PersonIdent("A U Thor", "author@example.com", when, tz)); assertPersonIdent("A U Thor<author@example.com>1234567890 -0700", new PersonIdent("A U Thor", "author@example.com", when, tz)); assertPersonIdent( " A U Thor < author@example.com > 1234567890 -0700", new PersonIdent(" A U Thor ", " author@example.com ", when, tz)); assertPersonIdent("A U Thor<author@example.com>1234567890 -0700", new PersonIdent("A U Thor", "author@example.com", when, tz)); }
Source:
<code><START> public boolean equals(final Object o) <END> { if (this == o) { return true; } if (o == null || !getClass().equals(o.getClass())) { return false; } final DoublesSketchAggregatorFactory that = (DoublesSketchAggregatorFactory) o; if (!fieldName.equals(that.fieldName)) { return false; } if (k != that.k) { return false; } return true; }</code><technical_language>name checked</technical_language>

Target:
public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || !getClass().equals(o.getClass())) { return false; } final DoublesSketchAggregatorFactory that = (DoublesSketchAggregatorFactory) o; if (!name.equals(that.name)) { return false; } if (!fieldName.equals(that.fieldName)) { return false; } if (k != that.k) { return false; } return true; }
Source:
<code>public ZipIndexFileSource(DataInputSource dataInputSource) { this.dataInputSource = requireNonNull(dataInputSource, "dataInputSource is null"); <START> this.zipData = readCentralDirectory(); <END> }</code><technical_language>put this stack</technical_language>

Target:
public ZipIndexFileSource(DataInputSource dataInputSource) { this.dataInputSource = requireNonNull(dataInputSource, "dataInputSource is null"); zipData = readCentralDirectory(); }
Source:
<code>public abstract Ref getRef(String name) throws IOException; public Ref exactRef(String name) throws IOException { Ref ref = getRef(name); <START> if (ref == null || !name.equals(ref.getName())) { <END> return null; } return ref; }</code><technical_language>this ineffective? implementing a method explicitly expects a fully qualified ref name deal iterating SEARCH_PATH. implementation is done calling expensive method this iterating SEARCH_PATH throw results if input ref name a qualified one. internal getRef() method learn a explicitly SEARCH_PATH</technical_language>

Target:
public abstract Ref getRef(String name) throws IOException; public Ref exactRef(String name) throws IOException { int slash = name.lastIndexOf('/'); String prefix = name.substring(0, slash + 1); String rest = name.substring(slash + 1); Ref result = getRefs(prefix).get(rest); if (result != null || slash != -1) { return result; } for (Ref ref : getAdditionalRefs()) { if (name.equals(ref.getName())) { return ref; } } return null; }
Source:
<code>private static byte[] shortToByteArray(final short value) { <START> ByteBuffer buffer = ByteBuffer.allocate(2).order(ByteOrder.LITTLE_ENDIAN); <END> return buffer.putShort(value).array(); }</code><technical_language>final</technical_language>

Target:
private static byte[] shortToByteArray(final short value) { final ByteBuffer buffer = ByteBuffer.allocate(2).order(ByteOrder.LITTLE_ENDIAN); return buffer.putShort(value).array(); }
Source:
<code>public String remoteName() { <START> SocketAddress addr = remoteAddress(); <END> if(addr != null) return addr.host(); return null; }</code><technical_language>remove this</technical_language>

Target:
public String remoteName() { java.net.SocketAddress addr = chctx.channel().remoteAddress(); if (addr instanceof InetSocketAddress) { return ((InetSocketAddress)addr).getHostString(); } return null; }
Source:
<code>MappingJacksonValue getAllSeats(@RequestParam(value = "admin", required = false) boolean admin, @AuthenticationPrincipal User user) { MappingJacksonValue result = new MappingJacksonValue(seatService.getAllSeats()); if (!admin || !user.getAuthorities().contains(Role.ROLE_ADMIN)) { <START> System.out.println("Setting Public View..."); <END> result.setSerializationView(View.Public.class); } return result; }</code><technical_language>Leftover debug statement</technical_language>

Target:
MappingJacksonValue getAllSeats(@RequestParam(value = "admin", required = false) boolean admin, @AuthenticationPrincipal User user) { MappingJacksonValue result = new MappingJacksonValue(seatService.getAllSeats()); if (!admin || !user.getAuthorities().contains(Role.ROLE_ADMIN)) { result.setSerializationView(View.Public.class); } return result; }
Source:
<code>public static String getCssValueFromTheme(Display display, String value) { BundleContext context = FrameworkUtil.getBundle(E4ThemeColor.class).getBundleContext(); try { Object reference = MethodUtils.invokeMethod(context, "getServiceReference", "org.eclipse.e4.ui.css.swt.theme.IThemeManager"); if (reference != null) { Object iThemeManager = MethodUtils.invokeMethod(context, "getService", reference); if (iThemeManager != null) { Object themeEngine = MethodUtils.invokeMethod(iThemeManager, "getEngineForDisplay", <START> Display.getDefault()); <END> Shell shell = display.getActiveShell(); if (themeEngine != null && shell != null) { Object shellStyle = MethodUtils.invokeMethod(themeEngine, "getStyle", shell); if (shellStyle != null && shellStyle instanceof CSSStyleDeclaration) { CSSValue cssValue = ((CSSStyleDeclaration) shellStyle).getPropertyCSSValue(value); if (cssValue != null) { return cssValue.getCssText(); } } } } } } catch (NoSuchMethodException nsme) { return null; } catch (InvocationTargetException ite) { return null; } catch (IllegalAccessException iae) { return null; } return null; }</code><technical_language>passed in display here</technical_language>

Target:
public static String getCssValueFromTheme(Display display, String value) { BundleContext context = FrameworkUtil.getBundle(E4ThemeColor.class).getBundleContext(); try { Object reference = MethodUtils.invokeMethod(context, "getServiceReference", "org.eclipse.e4.ui.css.swt.theme.IThemeManager"); if (reference != null) { Object iThemeManager = MethodUtils.invokeMethod(context, "getService", reference); if (iThemeManager != null) { Object themeEngine = MethodUtils.invokeMethod(iThemeManager, "getEngineForDisplay", display); Shell shell = display.getActiveShell(); if (themeEngine != null && shell != null) { Object shellStyle = MethodUtils.invokeMethod(themeEngine, "getStyle", shell); if (shellStyle instanceof CSSStyleDeclaration) { CSSValue cssValue = ((CSSStyleDeclaration) shellStyle).getPropertyCSSValue(value); if (cssValue != null) { return cssValue.getCssText(); } } } } } } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { if (!loggedError) { StatusHandler.log(new Status(IStatus.ERROR, CommonsUiConstants.ID_PLUGIN, e.getMessage(), e)); loggedError = true; } return null; } return null; }
Source:
<code>public ActionResult execute() { String idOfCourseToRestore = getRequestParamValue(Const.ParamsNames.COURSE_ID); Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, idOfCourseToRestore); String nameOfSessionToRestore = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME); <START> Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, nameOfSessionToRestore); <END> gateKeeper.verifyAccessible(logic.getInstructorForGoogleId(idOfCourseToRestore, account.googleId), logic.getFeedbackSession(nameOfSessionToRestore, idOfCourseToRestore), false, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION); try { logic.deleteFeedbackSession(nameOfSessionToRestore, idOfCourseToRestore); statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_SESSION_DELETED, StatusMessageColor.SUCCESS)); statusToAdmin = "Feedback Session <span class=\"bold\">[" + nameOfSessionToRestore + "]</span> " + "from Course: <span class=\"bold\">[" + idOfCourseToRestore + " permanently deleted."; } catch (Exception e) { setStatusForException(e); } return createRedirectResult(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE); }</code><technical_language>careful change names of variables (e.g. idOfCourseToDelete) if copy-and-pasting another file</technical_language>

Target:
public ActionResult execute() { String idOfCourseToDelete = getRequestParamValue(Const.ParamsNames.COURSE_ID); Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, idOfCourseToDelete); String nameOfSessionToDelete = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME); Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, nameOfSessionToDelete); gateKeeper.verifyAccessible(logic.getInstructorForGoogleId(idOfCourseToDelete, account.googleId), logic.getFeedbackSession(nameOfSessionToDelete, idOfCourseToDelete), false, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION); try { logic.deleteFeedbackSession(nameOfSessionToDelete, idOfCourseToDelete); statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_SESSION_DELETED, StatusMessageColor.SUCCESS)); statusToAdmin = "Feedback Session <span class=\"bold\">[" + nameOfSessionToDelete + "]</span> " + "from Course: <span class=\"bold\">[" + idOfCourseToDelete + " permanently deleted."; } catch (Exception e) { setStatusForException(e); } return createRedirectResult(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE); }
Source:
<code>protected void validateResult() throws Exception { assertTrue(isConflicting()); assertTrue(fileExists("model.di")); assertTrue(fileExists("model.notation")); assertTrue(fileExists("model.uml")); Set<String> conflicting = repository.status().getConflicting(); <START> conflicting.contains("model.uml"); <END> }</code><technical_language>assertion I ;) assertTrue(conflicting.contains(...)); alos useful check model.di model.notation in conflicting state in git repo</technical_language>

Target:
protected void validateResult() throws Exception { assertTrue(isConflicting()); assertTrue(fileExists("model.di")); assertTrue(fileExists("model.notation")); assertTrue(fileExists("model.uml")); Set<String> conflicting = repository.status().getConflicting(); assertEquals(conflicting.size(), 1); assertTrue(conflicting.contains("Project1/model.uml")); }
Source:
<code>private void loadData() { client.friendsNews() .compose(bindToLifecycle()) <START> .observeOn(AndroidSchedulers.mainThread()) <END> .subscribe(feeds -> { this.feeds = feeds; trySetAdapter(); }); client.profile() .compose(bindToLifecycle()) .observeOn(AndroidSchedulers.mainThread()) .map(this::extractFriendsAvatar) .subscribe(friendsAvatar -> { this.friendsAvatar = friendsAvatar; trySetAdapter(); }); }</code><technical_language>redundant</technical_language>

Target:
private void loadData() { MyShowsClient client = MyShowsClientImpl.getInstance(); client.friendsNews() .compose(bindToLifecycle()) .subscribe(feeds -> { this.feeds = feeds; trySetAdapter(); }); client.profile() .compose(bindToLifecycle()) .map(this::extractFriendsAvatar) .subscribe(friendsAvatar -> { this.friendsAvatar = friendsAvatar; trySetAdapter(); }); }
Source:
<code>protected boolean canDoAction() { if (isImagesAlreadyOnTarget()) { if (ovfEntityData == null && !getParameters().isImportAsNewEntity()) { return false; } setStorageDomainId(ovfEntityData.getStorageDomainId()); if (!validate(new StorageDomainValidator(getStorageDomain()).isDomainExistAndActive())) { return false; } if (!getStorageDomain().getStorageDomainType().isDataDomain()) { addCanDoActionMessage("$domainId " + getParameters().getStorageDomainId()); addCanDoActionMessage("$domainType " + getStorageDomain().getStorageDomainType()); addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DOMAIN_TYPE_UNSUPPORTED); <START> return false; <END> } } return super.canDoAction(); }</code><technical_language>replace #56-#59 a call failCanDoAction</technical_language>

Target:
protected boolean canDoAction() { if (isImagesAlreadyOnTarget()) { if (ovfEntityData == null && !getParameters().isImportAsNewEntity()) { return false; } setStorageDomainId(ovfEntityData.getStorageDomainId()); if (!validate(new StorageDomainValidator(getStorageDomain()).isDomainExistAndActive())) { return false; } if (!getStorageDomain().getStorageDomainType().isDataDomain()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DOMAIN_TYPE_UNSUPPORTED, String.format("$domainId %1$s", getParameters().getStorageDomainId()), String.format("$domainType %1$s", getStorageDomain().getStorageDomainType())); } } return super.canDoAction(); }
Source:
<code>private void buildTxClause(StringBuilder sb, String txsAlias) { sb.append(txsAlias); if (OptionsUtil.isHistorical(getOptions())) { <START> sb.append(".mod_type IN ("); <END> sb.append(String.valueOf(ModificationType.NEW.getValue())); sb.append(", "); sb.append(String.valueOf(ModificationType.DELETED.getValue())); sb.append(", "); sb.append(String.valueOf(ModificationType.ARTIFACT_DELETED.getValue())); sb.append(", "); sb.append(String.valueOf(ModificationType.MODIFIED.getValue())); sb.append(")"); } else { sb.append(".tx_current = "); sb.append(String.valueOf(TxChange.CURRENT.getValue())); } }</code><technical_language>I questions mod types others</technical_language>

Target:
private void buildTxClause(StringBuilder sb, String txsAlias) { sb.append(txsAlias); if (!OptionsUtil.isHistorical(getOptions())) { sb.append(".tx_current = "); sb.append(String.valueOf(TxChange.CURRENT.getValue())); } }
Source:
<code>protected void doTearDown() throws Exception { <START> super.doTearDown(); <END> if (project.exists()) { project.delete(true, null); } }</code><technical_language>super.tearDown executed after, this test code</technical_language>

Target:
protected void doTearDown() throws Exception { if (project.exists()) { project.delete(true, null); } super.doTearDown(); }
Source:
<code>protected ScheduledExecutorService executor() { final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor( new ThreadFactoryBuilder() .setDaemon(true) .setNameFormat(serviceName()) .build()); addListener(new Listener() { @Override public void terminated(State from) { executor.shutdown(); } @Override public void failed(State from, Throwable failure) { executor.shutdown(); <START> }}, MoreExecutors.sameThreadExecutor()); <END> return executor; }</code><technical_language>non-deprecated equivalent MoreExecutors .directExecutor()</technical_language>

Target:
protected ScheduledExecutorService executor() { final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor( new ThreadFactoryBuilder() .setDaemon(true) .setNameFormat(serviceName()) .build()); addListener(new Listener() { @Override public void terminated(State from) { executor.shutdown(); } @Override public void failed(State from, Throwable failure) { executor.shutdown(); }}, MoreExecutors.directExecutor()); return executor; }
Source:
<code>private static void retrieveSimpleColumn(Session session) { Row row = session.execute("SELECT b, m FROM examples.blobs WHERE k = 1").one(); ByteBuffer buffer = row.getBytes("b"); assert buffer.limit() - buffer.position() == 16; for (int i = buffer.position(); i < buffer.limit(); i++) { assert buffer.get(i) == (byte) 0xFF; } while (buffer.hasRemaining()) { <START> assert buffer.get() == (byte) 0xFF; <END> } assert buffer.position() == buffer.limit(); buffer.flip(); byte[] array = Bytes.getArray(buffer); assert array.length == 16; for (byte b : array) { assert b == (byte) 0xFF; } }</code><technical_language>Alternatively call .get() time assert returns separately, i.e.: java while (buffer.hasRemaining()) { byte b = buffer.get(); assert b == (byte) 0xFF; }</technical_language>

Target:
private static void retrieveSimpleColumn(Session session) { Row row = session.execute("SELECT b, m FROM examples.blobs WHERE k = 1").one(); ByteBuffer buffer = row.getBytes("b"); assert buffer.limit() - buffer.position() == 16; for (int i = buffer.position(); i < buffer.limit(); i++) { byte b = buffer.get(i); assert b == (byte) 0xFF; } while (buffer.hasRemaining()) { byte b = buffer.get(); assert b == (byte) 0xFF; } assert buffer.position() == buffer.limit(); buffer.flip(); byte[] array = Bytes.getArray(buffer); assert array.length == 16; for (byte b : array) { assert b == (byte) 0xFF; } }
Source:
<code>public void vlanIdTakenByDifferentNetwork() throws Exception { Network otherNetwork = new Network(); otherNetwork.setVlanId(DEFAULT_VLAN_ID); otherNetwork.setId(new Guid(OTHER_GUID)); List<Network> networks = new ArrayList<Network>(); <START> networks.add(otherNetwork); <END> vlanIdAvailableTest(new ValidationResult(VdcBllMessages.NETWORK_VLAN_IN_USE), networks); }</code><technical_language>replace lines need for networks variable a single call to: Collections.singletonList(otherNetwork) if file perform a list single item for read</technical_language>

Target:
public void vlanIdTakenByDifferentNetwork() throws Exception { Network otherNetwork = new Network(); otherNetwork.setVlanId(DEFAULT_VLAN_ID); otherNetwork.setId(new Guid(OTHER_GUID)); vlanIdAvailableTest(new ValidationResult(VdcBllMessages.NETWORK_VLAN_IN_USE), Collections.singletonList(otherNetwork)); }
Source:
<code><START> public void setup() throws Exception { <END> setupFlinkConfig(); flinkConfDir = temporaryFolder.newFolder().getAbsoluteFile(); hadoopConfDir = temporaryFolder.newFolder().getAbsoluteFile(); writeFlinkConfiguration(); Map<String, String> map = new HashMap<>(); map.put(ConfigConstants.ENV_FLINK_CONF_DIR, flinkConfDir.toString()); TestBaseUtils.setEnv(map); kubeClient = server.getClient().inNamespace(NAMESPACE); flinkKubeClient = new Fabric8FlinkKubeClient(flinkConfig, kubeClient, Executors::newDirectExecutorService); }</code><technical_language>necessary, idea: Instead of making methods overridable, this method final add empty onSetup() method overriden classes. way, classes remember call super.setup (they modify control flow of parent class) add @Before annotation</technical_language>

Target:
public final void setup() throws Exception { setupFlinkConfig(); flinkConfDir = temporaryFolder.newFolder().getAbsoluteFile(); hadoopConfDir = temporaryFolder.newFolder().getAbsoluteFile(); writeFlinkConfiguration(); Map<String, String> map = new HashMap<>(); map.put(ConfigConstants.ENV_FLINK_CONF_DIR, flinkConfDir.toString()); TestBaseUtils.setEnv(map); kubeClient = server.getClient().inNamespace(NAMESPACE); flinkKubeClient = new Fabric8FlinkKubeClient(flinkConfig, kubeClient, Executors::newDirectExecutorService); onSetup(); }
Source:
<code><START> public static Description wbFromDMN(final String description) { <END> if (description == null) { return new Description(""); } else { return new Description(description); } }</code><technical_language>reuse existing converter</technical_language>

Target:
public static Description wbFromDMN(final String description) { if (Objects.isNull(description)) { return new Description(""); } else { return new Description(description); } }
Source:
<code>public void removeChildAtIndex(final int childIndex) { if (0 <= childIndex && childIndex < jjtGetNumChildren()) { children = ArrayUtils.remove(children, childIndex); <START> for (int i = 0; i < jjtGetNumChildren(); i++) { <END> jjtGetChild(i).jjtSetChildIndex(i); } } }</code><technical_language>This loop safely start childIndex, previous indexes affected</technical_language>

Target:
public void removeChildAtIndex(final int childIndex) { if (0 <= childIndex && childIndex < jjtGetNumChildren()) { children = ArrayUtils.remove(children, childIndex); for (int i = childIndex; i < jjtGetNumChildren(); i++) { jjtGetChild(i).jjtSetChildIndex(i); } } }
Source:
<code>void deleteLargeMessageFile(final LargeServerMessage largeServerMessage) throws ActiveMQException { if (largeServerMessage.getPendingRecordID() < 0) { try { largeServerMessage.setPendingRecordID(storePendingLargeMessage(largeServerMessage.getMessageID(), largeServerMessage.getPendingRecordID())); } catch (Exception e) { throw new ActiveMQInternalErrorException(e.getMessage(), e); } } final SequentialFile file = largeServerMessage.getFile(); if (file == null) { return; } if (largeServerMessage.isDurable() && isReplicated()) { readLock(); try { if (isReplicated() && replicator.isSynchronizing()) { <START> synchronized (largeMessagesToDelete) { <END> largeMessagesToDelete.put(Long.valueOf(largeServerMessage.getMessageID()), largeServerMessage); } return; } } finally { readUnLock(); } } Runnable deleteAction = new Runnable() { @Override public void run() { try { readLock(); try { if (replicator != null) { replicator.largeMessageDelete(largeServerMessage.getMessageID(), JournalStorageManager.this); } file.delete(); confirmLargeMessage(largeServerMessage); } finally { readUnLock(); } } catch (Exception e) { ActiveMQServerLogger.LOGGER.journalErrorDeletingMessage(e, largeServerMessage.getMessageID()); } } }; if (executor == null) { deleteAction.run(); } else { executor.execute(deleteAction); } }</code><technical_language>If CHM is need sync</technical_language>

Target:
void deleteLargeMessageFile(final LargeServerMessage largeServerMessage) throws ActiveMQException { if (largeServerMessage.getPendingRecordID() < 0) { try { largeServerMessage.setPendingRecordID(storePendingLargeMessage(largeServerMessage.getMessageID(), largeServerMessage.getPendingRecordID())); } catch (Exception e) { throw new ActiveMQInternalErrorException(e.getMessage(), e); } } final SequentialFile file = largeServerMessage.getFile(); if (file == null) { return; } if (largeServerMessage.isDurable() && isReplicated()) { readLock(); try { if (isReplicated() && replicator.isSynchronizing()) { largeMessagesToDelete.put(largeServerMessage.getMessageID(), largeServerMessage); return; } } finally { readUnLock(); } } Runnable deleteAction = new Runnable() { @Override public void run() { try { readLock(); try { if (replicator != null) { replicator.largeMessageDelete(largeServerMessage.getMessageID(), JournalStorageManager.this); } file.delete(); confirmLargeMessage(largeServerMessage); } finally { readUnLock(); } } catch (Exception e) { ActiveMQServerLogger.LOGGER.journalErrorDeletingMessage(e, largeServerMessage.getMessageID()); } } }; if (executor == null) { deleteAction.run(); } else { executor.execute(deleteAction); } }
Source:
<code>public void should_fail_when_synchronous_call_on_io_thread() throws Exception { ResultSetFuture f = session.executeAsync("select release_version from system.local"); ListenableFuture<Void> f2 = Futures.transform(f, new Function<ResultSet, Void>() { @Override public Void apply(ResultSet input) { session.execute("select release_version from system.local"); return null; } }); try { f2.get(); <START> } catch (Exception e) { <END> assertThat(Throwables.getRootCause(e)) .isInstanceOf(IllegalStateException.class) .hasMessageContaining("Detected a synchronous Session call"); } }</code><technical_language>add a fail() call (after f2.get())</technical_language>

Target:
public void should_fail_when_synchronous_call_on_io_thread() throws Exception { ResultSetFuture f = session.executeAsync("select release_version from system.local"); ListenableFuture<Void> f2 = Futures.transform(f, new Function<ResultSet, Void>() { @Override public Void apply(ResultSet input) { session.execute("select release_version from system.local"); return null; } }); try { f2.get(); fail("Expected a failed future"); } catch (Exception e) { assertThat(Throwables.getRootCause(e)) .isInstanceOf(IllegalStateException.class) .hasMessageContaining("Detected a synchronous Session call"); } }
Source:
<code>public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) { if (rawType.equals(GHPoint.class)) { return new ParamConverter<T>() { @Override public T fromString(String value) { try { return (T) GHPoint.fromString(value); } catch (IllegalArgumentException ex) { throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) <START> .entity(new MultiException(new Throwable("Cannot parse point '" + value + "'"))) <END> .build()); } } @Override public String toString(T value) { return value.toString(); } }; } return null; }</code><technical_language>put this error message right IllegalArgumentException is thrown in GHPoint.fromString -- pass MultiException original ex is caught here, instead of creating a new Throwable</technical_language>

Target:
public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) { if (rawType.equals(GHPoint.class)) { return new ParamConverter<T>() { @Override public T fromString(String value) { try { return (T) GHPoint.fromString(value); } catch (IllegalArgumentException ex) { throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity(new MultiException(ex)) .build()); } } @Override public String toString(T value) { return value.toString(); } }; } return null; }
Source:
<code>public void init() { mainFrame = new MainFrame(displayOption); MessageLocationHighlightRenderersEditors.getInstance().addEditor( TextMessageLocationHighlight.class, new TextMessageLocationHighlightEditor()); MessageLocationHighlightRenderersEditors.getInstance().addRenderer( TextMessageLocationHighlight.class, new TextMessageLocationHighlightRenderer()); getWorkbench().getTabbedWork().setAlternativeParent(mainFrame.getPaneDisplay()); getWorkbench().getTabbedStatus().setAlternativeParent(mainFrame.getPaneDisplay()); getWorkbench().getTabbedSelect().setAlternativeParent(mainFrame.getPaneDisplay()); getMessagePanelsPositionController().restoreState(); <START> String statusString = ""; <END> for(Status status : AddOn.Status.values()) { try { statusString = Constant.messages.getString("cfu.status." + status.toString()); } catch (MissingResourceException mre) { statusString = status.toString(); } statusMap.put(status, new StatusUI(status, statusString)); } }</code><technical_language>Consider removing initialisation, necessary</technical_language>

Target:
public void init() { mainFrame = new MainFrame(displayOption); MessageLocationHighlightRenderersEditors.getInstance().addEditor( TextMessageLocationHighlight.class, new TextMessageLocationHighlightEditor()); MessageLocationHighlightRenderersEditors.getInstance().addRenderer( TextMessageLocationHighlight.class, new TextMessageLocationHighlightRenderer()); getWorkbench().getTabbedWork().setAlternativeParent(mainFrame.getPaneDisplay()); getWorkbench().getTabbedStatus().setAlternativeParent(mainFrame.getPaneDisplay()); getWorkbench().getTabbedSelect().setAlternativeParent(mainFrame.getPaneDisplay()); getMessagePanelsPositionController().restoreState(); String statusString; for(Status status : AddOn.Status.values()) { try { statusString = Constant.messages.getString("cfu.status." + status.toString()); } catch (MissingResourceException mre) { statusString = status.toString(); String errString="Caught " + mre.getClass().getName() + " " + mre.getMessage() + " when looking for i18n string: cfu.status." + statusString; if (Constant.isDevBuild()) { logger.error(errString); } else { logger.warn(errString); } } statusMap.put(status, new StatusUI(status, statusString)); } }
Source:
<code>public TaskExecution getLatestTaskExecutionForTaskName(String taskName) { <START> final List<TaskExecution> te = this.getLatestTaskExecutionsByTaskNames(taskName); <END> if (te.isEmpty()) { return null; } else if (te.size() == 1) { return te.get(0); } else { throw new IllegalStateException("Only expected a single TaskExecution but received " + te.size()); } }</code><technical_language>Need Assert.hasText for taskName</technical_language>

Target:
public TaskExecution getLatestTaskExecutionForTaskName(String taskName) { Assert.hasText(taskName, "The task name must not be empty."); final List<TaskExecution> taskExecutions = this.getLatestTaskExecutionsByTaskNames(taskName); if (taskExecutions.isEmpty()) { return null; } else if (taskExecutions.size() == 1) { return taskExecutions.get(0); } else { throw new IllegalStateException("Only expected a single TaskExecution but received " + taskExecutions.size()); } }
Source:
<code>protected Collection<String> getThemeLines() { Collection<String> lines = new ArrayList<>(); AbstractTheme theme = getTheme(); ThemeDefinition themeDef = getThemeDefinition(); <START> if (themeDef!= null && !themeDef.getName().equals("")) { <END> lines.add("import {applyTheme} from 'theme/theme.js';"); lines.add("applyTheme(document);"); } if (theme != null) { if (!theme.getHeaderInlineContents().isEmpty()) { lines.add(""); theme.getHeaderInlineContents() .forEach(html -> addLines(lines, String.format(THEME_LINE_TPL, NEW_LINE_TRIM .matcher(html).replaceAll("")))); } theme.getHtmlAttributes(themeDef.getVariant()) .forEach((key, value) -> addLines(lines, String.format(THEME_VARIANT_TPL, key, value))); lines.add(""); } return lines; }</code><technical_language>nit: formatted</technical_language>

Target:
protected Collection<String> getThemeLines() { Collection<String> lines = new ArrayList<>(); AbstractTheme theme = getTheme(); ThemeDefinition themeDef = getThemeDefinition(); if (themeDef != null && !"".equals(themeDef.getName())) { lines.add("import {applyTheme} from 'theme/theme-generated.js';"); lines.add("applyTheme(document);"); } if (theme != null) { if (!theme.getHeaderInlineContents().isEmpty()) { lines.add(""); theme.getHeaderInlineContents() .forEach(html -> addLines(lines, String.format(THEME_LINE_TPL, NEW_LINE_TRIM .matcher(html).replaceAll("")))); } if (themeDef != null) { theme.getHtmlAttributes(themeDef.getVariant()).forEach( (key, value) -> addLines(lines, String.format(THEME_VARIANT_TPL, key, value))); } lines.add(""); } return lines; }
Source:
<code><START> public void reset(long rateTimeInterval) { <END> reset(rateTimeInterval, DFLT_SZ); }</code><technical_language>Another method reset a bug: /** {@inheritDoc} */ @Override public void reset() { cntr = new HitRateMetricImpl(cntr.rateTimeInterval, cntr.size); } cntr copied a local variable in order avoid data races</technical_language>

Target:
public void reset(long rateTimeInterval) { reset(rateTimeInterval, DFLT_SIZE); }
Source:
<code>public void onActionModeStarted(android.view.ActionMode mode) { <START> if (CustomCabMenuHelper.shouldInjectCustomMenu(PageActivity.this, mode)) { <END> CustomCabMenuHelper.injectCustomMenu(PageActivity.this, mode); } prepareActionMode(mode); super.onActionModeStarted(mode); }</code><technical_language>I object work supported API levels. I a generic originView() type method useful</technical_language>

Target:
public void onActionModeStarted(android.view.ActionMode mode) { boolean wasCabOpen = isCabOpen(); currentActionMode = new CompatActionMode(mode, wasCabOpen); if (currentActionMode.shouldInjectCustomMenu(PageActivity.this)) { currentActionMode.injectCustomMenu(PageActivity.this); } prepareActionMode(); super.onActionModeStarted(mode); }
Source:
<code><START> public void testLatestApiVersionsRequest() throws IOException { <END> final short version = ApiKeys.API_VERSIONS.latestVersion(); TransportLayer transportLayer = mock(TransportLayer.class, Answers.RETURNS_DEEP_STUBS); Map<String, ?> configs = Collections.singletonMap(BrokerSecurityConfigs.SASL_ENABLED_MECHANISMS_CONFIG, Collections.singletonList(SCRAM_SHA_256.mechanismName())); ChannelMetadataRegistry metadataRegistry = new DefaultChannelMetadataRegistry(); SaslServerAuthenticator authenticator = setupAuthenticator(configs, transportLayer, SCRAM_SHA_256.mechanismName(), metadataRegistry); final RequestHeader header = new RequestHeader(ApiKeys.API_VERSIONS, version, "clientId", 0); final Struct headerStruct = header.toStruct(); final ApiVersionsRequest request = new ApiVersionsRequest.Builder().build(version); final Struct requestStruct = request.data.toStruct(version); when(transportLayer.socketChannel().socket().getInetAddress()).thenReturn(InetAddress.getLoopbackAddress()); when(transportLayer.read(any(ByteBuffer.class))).then(invocation -> { invocation.<ByteBuffer>getArgument(0).putInt(headerStruct.sizeOf() + requestStruct.sizeOf()); return 4; }).then(invocation -> { headerStruct.writeTo(invocation.getArgument(0)); requestStruct.writeTo(invocation.getArgument(0)); return headerStruct.sizeOf() + requestStruct.sizeOf(); }); authenticator.authenticate(); assertEquals("apache-kafka-java", metadataRegistry.clientInformation().softwareName()); assertEquals(AppInfoParser.getVersion(), metadataRegistry.clientInformation().softwareVersion()); verify(transportLayer, times(2)).read(any(ByteBuffer.class)); }</code><technical_language>this is similar previous test case, a version returns actual info "unknown". chance share some code</technical_language>

Target:
public void testLatestApiVersionsRequest() throws IOException { testApiVersionsRequest(ApiKeys.API_VERSIONS.latestVersion(), "apache-kafka-java", AppInfoParser.getVersion()); }