auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected void executeQueryCommand() { List<OvfEntityData> entityList = getOvfEntityList(); List<VmTemplate> vmTemplates = new ArrayList<>(); OvfHelper ovfHelper = getOvfHelper(); for (OvfEntityData ovf : entityList) { <START> VmTemplate vmTemplate = null; <END> try { vmTemplate = ovfHelper.readVmTemplateFromOvf(ovf.getOvfData()); vmTemplates.add(vmTemplate); } catch (OvfReaderException e) { log.debug("failed to parse a given ovf configuration: \n" + ovf.getOvfData(), e); getQueryReturnValue().setExceptionString("failed to parse a given ovf configuration " + e.getMessage()); } } getQueryReturnValue().setSucceeded(true); getQueryReturnValue().setReturnValue(vmTemplates); }</code><technical_language>1. define loop 2. remove execute vmTemplates.add ( ovfHelper.readVmTemplateFromOvf(ovf.getOvfData()))</technical_language>

Target:
protected void executeQueryCommand() { List<OvfEntityData> entityList = getOvfEntityList(VmEntityType.TEMPLATE); List<VmTemplate> vmTemplates = new ArrayList<>(); OvfHelper ovfHelper = getOvfHelper(); for (OvfEntityData ovf : entityList) { try { vmTemplates.add(ovfHelper.readVmTemplateFromOvf(ovf.getOvfData())); } catch (OvfReaderException e) { log.debug("failed to parse a given ovf configuration: \n" + ovf.getOvfData(), e); getQueryReturnValue().setExceptionString("failed to parse a given ovf configuration " + e.getMessage()); } } getQueryReturnValue().setSucceeded(true); getQueryReturnValue().setReturnValue(vmTemplates); }
Source:
<code>protected Set<View> getViewsAccordingToGeneralization(final Generalization generalization) { Set<View> viewsToDestroy = new HashSet<View>(); final Classifier general = generalization.getGeneral(); if <START> (general != null) { <END> final EList<NamedElement> members = general.getMembers(); for (final NamedElement member : members) { final Iterator<View> viewIt = CrossReferencerUtil.getCrossReferencingViews(member, null).iterator(); while (viewIt.hasNext()) { final View view = viewIt.next(); final GeneralizationUtil util = new GeneralizationUtil(); if (util.isConcernedByGeneralizationChanges(generalization, view)) { viewsToDestroy.add(view); } } } } return viewsToDestroy; }</code><technical_language>invert</technical_language>

Target:
protected Set<View> getViewsAccordingToGeneralization(final Generalization generalization) { Set<View> viewsToDestroy = new HashSet<View>(); final Classifier general = generalization.getGeneral(); if (null != general) { final EList<NamedElement> members = general.getMembers(); for (final NamedElement member : members) { final Iterator<View> viewIt = CrossReferencerUtil.getCrossReferencingViews(member, null).iterator(); while (viewIt.hasNext()) { final View view = viewIt.next(); final GeneralizationUtil util = new GeneralizationUtil(); if (util.isConcernedByGeneralizationChanges(generalization, view)) { viewsToDestroy.add(view); } } } } return viewsToDestroy; }
Source:
<code>public GroupByStrategy strategize(GroupByQuery query) { final String strategyString = query.getContextValue(CTX_KEY_STRATEGY, config.getDefaultStrategy()); switch (strategyString) { case STRATEGY_EPINEPHELINAE: return epi; case STRATEGY_OLD_FAITHFUL: return oldFaithful; default: <START> throw new ISE("No such strategy[%s]", strategyString); <END> } }</code><technical_language>default oldFaithful? This force queries a strategy</technical_language>

Target:
public GroupByStrategy strategize(GroupByQuery query) { final String strategyString = query.getContextValue(CTX_KEY_STRATEGY, config.getDefaultStrategy()); switch (strategyString) { case STRATEGY_V2: return strategyV2; case STRATEGY_V1: return strategyV1; default: throw new ISE("No such strategy[%s]", strategyString); } }
Source:
<code>public static Block toMap(MapType mapType, BlockBuilderAppender keyAppender, BlockBuilderAppender valueAppender, ConnectorSession connectorSession, Slice json) { try (JsonParser jsonParser = createJsonParser(JSON_FACTORY, json)) { BlockBuilder mapBlockBuilder = mapType.createBlockBuilder(new BlockBuilderStatus(), 1); <START> BlockBuilder singleMapBlockBuilder = mapBlockBuilder.beginBlockEntry(); <END> jsonParser.nextToken(); if (jsonParser.getCurrentToken() == JsonToken.VALUE_NULL) { return null; } checkState(jsonParser.currentToken() == JsonToken.START_OBJECT, "Expected a json object"); int position = 0; HashTable hashTable = new HashTable(mapType.getKeyType()); while (jsonParser.nextValue() != JsonToken.END_OBJECT) { keyAppender.append(jsonParser, singleMapBlockBuilder); valueAppender.append(jsonParser, singleMapBlockBuilder); if (hashTable.contains(singleMapBlockBuilder, position)) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Duplicate keys are not allowed"); } hashTable.add(singleMapBlockBuilder, position); position += 2; } mapBlockBuilder.closeEntry(); return mapType.getObject(mapBlockBuilder, mapBlockBuilder.getPositionCount() - 1); } catch (RuntimeException e) { throw new PrestoException(INVALID_CAST_ARGUMENT, format("Value %s cannot be cast to %s", json.toStringUtf8(), mapType), e); } catch (IOException e) { throw Throwables.propagate(e); } }</code><technical_language>Move lines down. cheap. needed if return null</technical_language>

Target:
public static Block toMap(MapType mapType, BlockBuilderAppender keyAppender, BlockBuilderAppender valueAppender, ConnectorSession connectorSession, Slice json) { try (JsonParser jsonParser = createJsonParser(JSON_FACTORY, json)) { jsonParser.nextToken(); if (jsonParser.getCurrentToken() == JsonToken.VALUE_NULL) { return null; } if (jsonParser.getCurrentToken() != START_OBJECT) { throw new JsonCastException(format("Expected a json object, but got %s", jsonParser.getText())); } BlockBuilder mapBlockBuilder = mapType.createBlockBuilder(new BlockBuilderStatus(), 1); BlockBuilder singleMapBlockBuilder = mapBlockBuilder.beginBlockEntry(); HashTable hashTable = new HashTable(mapType.getKeyType(), singleMapBlockBuilder); int position = 0; while (jsonParser.nextToken() != JsonToken.END_OBJECT) { keyAppender.append(jsonParser, singleMapBlockBuilder); jsonParser.nextToken(); valueAppender.append(jsonParser, singleMapBlockBuilder); if (!hashTable.addIfAbsent(position)) { throw new JsonCastException("Duplicate keys are not allowed"); } position += 2; } if (jsonParser.nextToken() != null) { throw new JsonCastException(format("Unexpected trailing token: %s", jsonParser.getText())); } mapBlockBuilder.closeEntry(); return mapType.getObject(mapBlockBuilder, mapBlockBuilder.getPositionCount() - 1); } catch (PrestoException | JsonCastException e) { throw new PrestoException(INVALID_CAST_ARGUMENT, format("Cannot cast to %s. %s\n%s", mapType, e.getMessage(), truncateIfNecessaryForErrorMessage(json)), e); } catch (Exception e) { throw new PrestoException(INVALID_CAST_ARGUMENT, format("Cannot cast to %s.\n%s", mapType, truncateIfNecessaryForErrorMessage(json)), e); } }
Source:
<code>public String getSecureMessage() { final String userName = Optional.ofNullable(securityContext.getUser()). map(u -> u.getName()). <START> orElse("UNNOWN"); <END> LOG.info("Secure endpoint called by {}", userName); return "A secure message that was requested by " + userName; }</code><technical_language>Missing 'K'</technical_language>

Target:
public String getSecureMessage() { final String userName = Optional.ofNullable(securityContext.getUser()). map(u -> u.getName()). orElse("UNKNOWN"); LOG.info("Secure endpoint called by {}", userName); return "A secure message that was requested by " + userName; }
Source:
<code>private IAction createClampAction() { Action action = new Action(Messages.TmfChartView_ClampYAxis, IAction.AS_PUSH_BUTTON) { @Override public void run() { <START> super.run(); <END> LockRangeDialog rangeDialog = new LockRangeDialog(getSite().getShell(), getChartViewer()); rangeDialog.open(); } }; action.setChecked(false); return action; }</code><technical_language>need call this, assumed Action.run() implementation is empty</technical_language>

Target:
private IAction createClampAction() { Action action = new Action(Messages.TmfChartView_LockYAxis, IAction.AS_PUSH_BUTTON) { @Override public void run() { super.run(); LockRangeDialog rangeDialog = new LockRangeDialog(getSite().getShell(), getChartViewer()); rangeDialog.open(); } }; action.setChecked(false); return action; }
Source:
<code>public void testCheckAttributeReturnNull() throws Exception { <START> System.out.println("testCheckAttriubuteReturnNull()"); <END> attributeToCheck.setValue(null); classInstance.checkAttributeSyntax(session, new Member(), new Group(), attributeToCheck); }</code><technical_language>Typo</technical_language>

Target:
public void testCheckAttributeReturnNull() throws Exception { System.out.println("testCheckAttributeReturnNull()"); attributeToCheck.setValue(null); classInstance.checkAttributeSyntax(session, new Member(), new Group(), attributeToCheck); }
Source:
<code>protected String computeMetricName(Message<?> message) { <START> String counterName = nameExpression.getValue(evaluationContext, message, CharSequence.class).toString(); <END> return counterName; }</code><technical_language>need assign counterName return next line. However, add a null check for evaluationContext</technical_language>

Target:
protected String computeMetricName(Message<?> message) { return nameExpression.getValue(evaluationContext, message, CharSequence.class).toString(); }
Source:
<code>private static Optional<IntegerStatistics> mergeIntegerStatistics(Optional<IntegerStatistics> first, Optional<IntegerStatistics> second) { if (first.isPresent() && second.isPresent()) { return Optional.of(new IntegerStatistics( reduce(first.get().getMin(), second.get().getMin(), SELECT_MIN, true), reduce(first.get().getMax(), second.get().getMax(), SELECT_MAX, true))); } <START> return Optional.empty(); <END> }</code><technical_language>if is present, return empty if is present fields absent, return Why? Leave some explanation in code. (here & a times below)</technical_language>

Target:
private static Optional<IntegerStatistics> mergeIntegerStatistics(Optional<IntegerStatistics> first, Optional<IntegerStatistics> second) { if (first.isPresent() && second.isPresent()) { return Optional.of(new IntegerStatistics( reduce(first.get().getMin(), second.get().getMin(), MIN, true), reduce(first.get().getMax(), second.get().getMax(), MAX, true))); } return Optional.empty(); }
Source:
<code>public String putBlob(BlobProperties blobProperties, ByteBuffer userMetadata, InputStream blobStream) throws CoordinatorException { <START> PartitionId partitionId = getPartitionForPut(); <END> BlobId blobId = new BlobId(partitionId); OperationContext oc = getOperationContext(); PutOperation putOperation = new PutOperation(datacenterName, connectionPool, requesterPool, oc, blobId, operationTimeoutMs, blobProperties, userMetadata, blobStream, (short) 1, (short) 1); putOperation.execute(); notificationSystem.onBlobCreated(blobId.getID(), blobProperties, userMetadata.array()); return blobId.getID(); }</code><technical_language>need sanity checks AmbryCoordinator::putBlob() deliberately left out</technical_language>

Target:
public String putBlob(BlobProperties blobProperties, ByteBuffer userMetadata, InputStream blobStream) throws CoordinatorException { PartitionId partitionId = getPartitionForPut(); BlobId blobId = new BlobId(partitionId); OperationContext oc = getOperationContext(); PutOperation putOperation = new PutOperation(datacenterName, connectionPool, requesterPool, oc, blobId, operationTimeoutMs, blobProperties, userMetadata, blobStream, 1, 1); putOperation.execute(); notificationSystem.onBlobCreated(blobId.getID(), blobProperties, userMetadata.array()); return blobId.getID(); }
Source:
<code>protected void onSetSSLParameters(SSLParameters sslParameters) { <START> if (endpointIdentificationAlgorithm == null) { <END> super.onSetSSLParameters(sslParameters); } else { sslParameters.setEndpointIdentificationAlgorithm(endpointIdentificationAlgorithm); } }</code><technical_language>If I understand correctly, endpointIdentificationAlgorithm is null in this test. empty string is instead</technical_language>

Target:
protected void onSetSSLParameters(SSLParameters sslParameters) { if (endpointIdentificationAlgorithm != null) { sslParameters.setEndpointIdentificationAlgorithm(endpointIdentificationAlgorithm); } }
Source:
<code>public static void main(String[] args) throws FlinkException { checkArgument(args.length > 0, "Command not specified."); Command command = Command.valueOf(args[0]); <START> String[] commandArgs = Arrays.copyOfRange(args, 1, args.length); Configuration configuration = FlinkConfigLoader.loadConfiguration(commandArgs); <END> List<String> output = runCommand(command, configuration); for (String outputLine : output) { System.out.println(EXECUTION_PREFIX + outputLine); } }</code><technical_language>this refactor. good argument command, print outputs prefix, IMO common contract for BashJavaUtils commands. However, assumption remaining arguments for generating Configuration true. is true based current state GET_JM/TM_RESOURCE_PARAMS commands. This problem ATM, I pass in commandArgs generate Configuration getJm/TmResourceParams</technical_language>

Target:
public static void main(String[] args) throws FlinkException { checkArgument(args.length > 0, "Command not specified."); Command command = Command.valueOf(args[0]); String[] commandArgs = Arrays.copyOfRange(args, 1, args.length); List<String> output = runCommand(command, commandArgs); for (String outputLine : output) { System.out.println(EXECUTION_PREFIX + outputLine); } }
Source:
<code>public <I extends T> RegistryObject<I> register(final String name, final Supplier<? extends I> sup) { Objects.requireNonNull(name); Objects.requireNonNull(sup); final ResourceLocation key = new ResourceLocation(modid, name); RegistryObject<I> ret; <START> try { ret = RegistryObject.of(key, this.type); } catch (IllegalArgumentException e) { LOGGER.error("Errored while trying to register an entry. This likely happened due to registering for a custom registry, use lazyRegister instead."); throw new IllegalArgumentException("Null registry used in DeferredRegister"); } <END> if (entries.putIfAbsent((RegistryObject<T>) ret, () -> sup.get().setRegistryName(key)) != null) { throw new IllegalArgumentException("Duplicate registration " + name); } return ret; }</code><technical_language>Instead of a try/catch more sense check if this.type is null directly</technical_language>

Target:
public <I extends T> RegistryObject<I> register(final String name, final Supplier<? extends I> sup) { Objects.requireNonNull(name); Objects.requireNonNull(sup); final ResourceLocation key = new ResourceLocation(modid, name); if(this.type == null) { LOGGER.error("Errored while trying to register an entry. This likely happened due to registering for a custom registry, use lazyRegister instead."); throw new IllegalArgumentException("Null registry used in DeferredRegister"); } RegistryObject<I> ret = RegistryObject.of(key, this.type); if (entries.putIfAbsent((RegistryObject<T>) ret, () -> sup.get().setRegistryName(key)) != null) { throw new IllegalArgumentException("Duplicate registration " + name); } return ret; }
Source:
<code>public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine sslEngine) throws CertificateException { if (delegate instanceof X509ExtendedTrustManager) { <START> ((X509ExtendedTrustManager)delegate).checkClientTrusted(chain, authType, sslEngine); <END> } else { throw new UnsupportedOperationException(); } verifier.checkChain(chain); }</code><technical_language>IMHO copy-paste bug - checkServerTrusted instead</technical_language>

Target:
public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine sslEngine) throws CertificateException { if (delegate instanceof X509ExtendedTrustManager) { ((X509ExtendedTrustManager)delegate).checkServerTrusted(chain, authType, sslEngine); } else { throw new UnsupportedOperationException(); } verifier.checkChain(chain); }
Source:
<code>public Genotype makeWithShallowCopy() { final Map<String, Object> ea = (extendedAttributes == null) ? NO_ATTRIBUTES : new HashMap<>(extendedAttributes); final List<Allele> al = new ArrayList<>(alleles); final int[] copyAD = (AD == null) ? null : Arrays.copyOf(AD, AD.length); <START> final int[] copyPL = (AD == null) ? null : Arrays.copyOf(PL, PL.length); <END> return new FastGenotype(sampleName, al, isPhased, GQ, DP, copyAD, copyPL, filters, ea); }</code><technical_language>PL == null, I</technical_language>

Target:
public Genotype makeWithShallowCopy() { final Map<String, Object> ea = (extendedAttributes == null) ? NO_ATTRIBUTES : new HashMap<>(extendedAttributes); final List<Allele> al = new ArrayList<>(alleles); final int[] copyAD = (AD == null) ? null : Arrays.copyOf(AD, AD.length); final int[] copyPL = (PL == null) ? null : Arrays.copyOf(PL, PL.length); return new FastGenotype(sampleName, al, isPhased, GQ, DP, copyAD, copyPL, filters, ea); }
Source:
<code>public void start() { try { LOGGER.log(Level.INFO, "Starting rest server"); webManager.start(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error occurred when starting rest server", e); throw new VXQueryRuntimeException("Unable to start REST server", e); } <START> LOGGER.log(Level.INFO, "Rest server started"); <END> }</code><technical_language>this in try? For consistency, LOGGER messages in place for start stop functions</technical_language>

Target:
public void start() { try { LOGGER.log(Level.FINE, "Starting rest server on port: " + port); webManager.start(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error occurred when starting rest server", e); throw new VXQueryRuntimeException("Unable to start REST server", e); } LOGGER.log(Level.INFO, "Rest server started on port: " + port); }
Source:
<code><START> public void validateSpecifications(@NonNull JSONObject specifications, Options options, @NonNull final ResponseListener<Boolean> listener) throws JSONException { <END> if (specifications == null) { throw new IllegalArgumentException("Collection.validateSpecifications: specifications cannot be null"); } JSONObject data = new JSONObject() .put("body", new JSONObject() .put(this.getIndex(), new JSONObject() .put(this.getCollection(), specifications) ) ); try { this.kuzzle.addHeaders(data, this.getHeaders()); this.kuzzle.query(makeQueryArgs("collection", "validateSpecifications"), data, options, new OnQueryDoneListener() { @Override public void onSuccess(JSONObject response) { try { listener.onSuccess(response.getJSONObject("result").getBoolean("valid")); } catch (JSONException e) { throw new RuntimeException(e); } } @Override public void onError(JSONObject error) { listener.onError(error); } }); } catch (JSONException e) { throw new RuntimeException(e); } }</code><technical_language>check if listener is null throw IllegalArgumentException if</technical_language>

Target:
public void validateSpecifications(@NonNull JSONObject specifications, Options options, @NonNull final ResponseListener<Boolean> listener) throws JSONException { if (specifications == null) { throw new IllegalArgumentException("Collection.validateSpecifications: specifications cannot be null"); } if (listener == null) { throw new IllegalArgumentException("listener cannot be null"); } JSONObject data = new JSONObject() .put("body", new JSONObject() .put(this.getIndex(), new JSONObject() .put(this.getCollection(), specifications) ) ); try { this.kuzzle.addHeaders(data, this.getHeaders()); this.kuzzle.query(makeQueryArgs("collection", "validateSpecifications"), data, options, new OnQueryDoneListener() { @Override public void onSuccess(JSONObject response) { try { listener.onSuccess(response.getJSONObject("result").getBoolean("valid")); } catch (JSONException e) { throw new RuntimeException(e); } } @Override public void onError(JSONObject error) { listener.onError(error); } }); } catch (JSONException e) { throw new RuntimeException(e); } }
Source:
<code>private void showLightStyle() { final TextView titleView = (TextView) mInAppView.findViewById(R.id.com_mixpanel_android_notification_title); final ImageView notifImage = (ImageView) mInAppView.findViewById(R.id.com_mixpanel_android_notification_image); GradientDrawable viewBackground = new GradientDrawable(); <START> viewBackground.setColor(0xFFFFFFFF); <END> viewBackground.setStroke(2, Color.rgb(218, 223, 232)); viewBackground.setCornerRadius(6); if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { mInAppView.setBackgroundDrawable(viewBackground); } else { mInAppView.setBackground(viewBackground); } titleView.setTextColor(Color.rgb(123, 146, 163)); Drawable myIcon = new BitmapDrawable(getResources(), mDisplayState.getInAppNotification().getImage()); final int newColor = Color.rgb(123, 146, 163); myIcon.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP); notifImage.setImageDrawable(myIcon); }</code><technical_language>Color.WHITE more readable</technical_language>

Target:
private void showLightStyle() { final TextView titleView = (TextView) mInAppView.findViewById(R.id.com_mixpanel_android_notification_title); final ImageView notifImage = (ImageView) mInAppView.findViewById(R.id.com_mixpanel_android_notification_image); GradientDrawable viewBackground = new GradientDrawable(); viewBackground.setColor(Color.WHITE); viewBackground.setCornerRadius(6); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { viewBackground.setStroke(2, getResources().getColor(R.color.com_mixpanel_android_inapp_light_softgray)); titleView.setTextColor(getResources().getColor(R.color.com_mixpanel_android_inapp_light_gray)); } else { viewBackground.setStroke(2, getResources().getColor(R.color.com_mixpanel_android_inapp_light_softgray, null)); titleView.setTextColor(getResources().getColor(R.color.com_mixpanel_android_inapp_light_gray, null)); } if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { mInAppView.setBackgroundDrawable(viewBackground); } else { mInAppView.setBackground(viewBackground); } Drawable myIcon = new BitmapDrawable(getResources(), mDisplayState.getInAppNotification().getImage()); final int newColor; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { newColor = getResources().getColor(R.color.com_mixpanel_android_inapp_light_gray); } else { newColor = getResources().getColor(R.color.com_mixpanel_android_inapp_light_gray, null); } myIcon.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP); notifImage.setImageDrawable(myIcon); }
Source:
<code>public Project getProject(String name) { Project fetchedProject = null; try { fetchedProject = projectLoader.fetchProjectByName(name); loadAllProjectFlows(fetchedProject); } catch (ProjectManagerException e) { <START> logger.error("Could not load project from store.", e); <END> } return fetchedProject; }</code><technical_language>log project name well</technical_language>

Target:
public Project getProject(String name) { Project fetchedProject = null; try { fetchedProject = projectLoader.fetchProjectByName(name); loadAllProjectFlows(fetchedProject); } catch (ProjectManagerException e) { logger.error("Could not load project" + name + " from store.", e); } return fetchedProject; }
Source:
<code>public void doesNotLoadLeaderPaxosAsNamespace() { <START> Set<String> namespaces = diskNamespaceLoader.getAllPersistedNamespaces().stream().map(client -> client.value()).collect( <END> Collectors.toSet()); assertThat(namespaces).containsExactlyInAnyOrder(NAMESPACE_1, NAMESPACE_2); }</code><technical_language>nit: a method reference (Client::value opposed x -> x.value())</technical_language>

Target:
public void doesNotLoadLeaderPaxosAsNamespace() { Set<String> namespaces = diskNamespaceLoader.getAllPersistedNamespaces().stream().map(Client::value).collect( Collectors.toSet()); assertThat(namespaces).containsExactlyInAnyOrder(NAMESPACE_1, NAMESPACE_2); }
Source:
<code>public ViewPage createPageWithAttachment(EntityReference reference, String content, String title, String attachmentName, InputStream attachmentData) throws Exception { ViewPage vp = createPage(reference, content, title); attachFile(reference, attachmentName, attachmentData, false); <START> return vp; <END> }</code><technical_language>call other signature here, null credentials</technical_language>

Target:
public ViewPage createPageWithAttachment(EntityReference reference, String content, String title, String attachmentName, InputStream attachmentData) throws Exception { return createPageWithAttachment(reference, content, title, attachmentName, attachmentData, null); }
Source:
<code>protected boolean uploadSegment(File segmentTarFile, SegmentUploader segmentUploader, SegmentCompletionProtocol.Request.Params params) { URI segmentLocation = segmentUploader.uploadSegment(segmentTarFile, new LLCSegmentName(params.getSegmentName())); if (segmentLocation != null) { params.withSegmentLocation(segmentLocation.toString()); } else { <START> params.withSegmentLocation("peer:/ END> } return true; }</code><technical_language>Please put "peer" a scheme in CommonConstants refer everywhere. Please change PinotLLCRealtimeSegmentManager, tests SegmentCompletionTest, PinotLLCRealtimeSegmentManagerTest</technical_language>

Target:
protected String uploadSegment(File segmentTarFile, SegmentUploader segmentUploader, SegmentCompletionProtocol.Request.Params params) { URI segmentLocation = segmentUploader.uploadSegment(segmentTarFile, new LLCSegmentName(params.getSegmentName())); if (segmentLocation == null) { return StringUtil.join("/", CommonConstants.Segment.PEER_SEGMENT_DOWNLOAD_SCHEME, params.getSegmentName()); } return segmentLocation.toString(); }
Source:
<code>private VBox createMatchingMilestonesBox() { VBox milestoneGroup = new VBox(); <START> milestoneGroup.setPrefHeight(30 * MilestonePickerState.BEST_MATCHING_LIMIT); <END> milestoneGroup.setStyle("-fx-border-radius: 3;-fx-background-color: white;-fx-border-color: black;"); return milestoneGroup; }</code><technical_language>Is 30 (detailedMilestoneBox.setPrefHeight(30))? If yes, abstract out a constant</technical_language>

Target:
private VBox createMatchingMilestonesBox() { VBox milestoneGroup = new VBox(); milestoneGroup.setPrefHeight(DETAILED_MILESTONE_HEIGHT * MilestonePickerState.BEST_MATCHING_LIMIT); milestoneGroup.setStyle("-fx-border-radius: 3;-fx-background-color: white;-fx-border-color: black;"); return milestoneGroup; }
Source:
<code>public void execute(AbstractBuild<?, ?> build) throws DockerException, IOException { DockerClient client = getClient(build); String xImage = expand(build, image); String xCommand = expand(build, dockerCommand); String xHostname = expand(build, hostname); LOGGER.info("Pulling image " + xImage); final StringBuilder resultBuilder = new StringBuilder(); PullImageResultCallback resultCallback = new PullImageResultCallback() { <START> public void onNext(PullResponseItem item) { <END> if (item.getStatus() != null && item.getProgress() == null) { resultBuilder.append("\n").append(item.getId()).append(":").append(item.getStatus()); } super.onNext(item); } }; client.pullImageCmd(xImage).exec(resultCallback).awaitSuccess(); String strResult = resultBuilder.toString(); LOGGER.log(Level.INFO, "Pull result = {0}", strResult); LOGGER.log(Level.INFO, "Starting container for image {0}", xImage); DockerTemplateBase template = new DockerSimpleTemplate(xImage, dnsString, xCommand, volumesString, volumesFrom, environmentsString, lxcConfString, xHostname, memoryLimit, cpuShares, bindPorts, bindAllPorts, privileged, tty, macAddress); String containerId = DockerCloud.runContainer(template, client, null); LOGGER.log(Level.INFO, "Started container {0}", containerId); getLaunchAction(build).started(client, containerId); }</code><technical_language>fill stringbuilder, print listener</technical_language>

Target:
public void execute(AbstractBuild<?, ?> build) throws DockerException, IOException { DockerClient client = getClient(build); String xImage = expand(build, image); String xCommand = expand(build, dockerCommand); String xHostname = expand(build, hostname); LOGGER.info("Pulling image " + xImage); PullImageResultCallback resultCallback = new PullImageResultCallback() { public void onNext(PullResponseItem item) { if (item.getStatus() != null && item.getProgress() == null) { LOGGER.info(item.getId() + ":" + item.getStatus()); } super.onNext(item); } }; client.pullImageCmd(xImage).exec(resultCallback).awaitSuccess(); LOGGER.log(Level.INFO, "Starting container for image {0}", xImage); DockerTemplateBase template = new DockerSimpleTemplate(xImage, dnsString, xCommand, volumesString, volumesFrom, environmentsString, lxcConfString, xHostname, memoryLimit, cpuShares, bindPorts, bindAllPorts, privileged, tty, macAddress); String containerId = DockerCloud.runContainer(template, client, null); LOGGER.log(Level.INFO, "Started container {0}", containerId); getLaunchAction(build).started(client, containerId); }
Source:
<code>private static void putNextGroup( ResultSet rs, ExtMap next, ExtMap context ) throws SQLException { if (!next.containsKey(Authz.GroupRecord.NAMESPACE)) { <START> next.put(GroupKeys.DB_ID, rs.getInt("group_id")); <END> next.put(Authz.GroupRecord.NAMESPACE, rs.getString("namespace")); next.put(Authz.GroupRecord.ID, rs.getString("group_uuid")); next.put(Authz.GroupRecord.NAME, rs.getString("group_name")); next.put(Authz.GroupRecord.DISPLAY_NAME, rs.getString("group_display_name")); next.putIfAbsent(Authz.GroupRecord.DISPLAY_NAME, ""); next.put(AuthzInternal.GROUP_DESCRIPTION, rs.getString("group_description")); next.putIfAbsent(AuthzInternal.GROUP_DESCRIPTION, ""); next.put(Authz.GroupRecord.GROUPS, new ArrayList<ExtMap>()); } if (context.get(Global.SearchContext.WITH_GROUPS, Boolean.class)) { String nested = rs.getString("group_group_id"); if (nested != null) { ExtMap group = new ExtMap(); group.put(Authz.GroupRecord.NAMESPACE, rs.getString("namespace")); group.put(Authz.GroupRecord.ID, rs.getString("group_group_uuid")); group.put(Authz.GroupRecord.NAME, rs.getString("group_group_name")); group.put(Authz.GroupRecord.DISPLAY_NAME, rs.getString("group_group_display_name")); group.putIfAbsent(Authz.GroupRecord.DISPLAY_NAME, ""); group.put(AuthzInternal.GROUP_DESCRIPTION, rs.getString("group_group_description")); group.putIfAbsent(AuthzInternal.GROUP_DESCRIPTION, ""); next.get(Authz.PrincipalRecord.GROUPS, ArrayList.class).add(group); } } }</code><technical_language>Please ALL_ATTRIBUTES flag add DB_ID results for cli invocations, want expose DB_ID engine. For details please a <LINK_0></technical_language>

Target:
private static void putNextGroup( ResultSet rs, ExtMap next, ExtMap context ) throws SQLException { if (!next.containsKey(Authz.GroupRecord.NAMESPACE)) { next.put(Authz.GroupRecord.NAMESPACE, rs.getString("namespace")); next.put(Authz.GroupRecord.ID, rs.getString("group_uuid")); next.put(Authz.GroupRecord.NAME, rs.getString("group_name")); next.put(Authz.GroupRecord.DISPLAY_NAME, rs.getString("group_display_name")); next.putIfAbsent(Authz.GroupRecord.DISPLAY_NAME, ""); next.put(AuthzInternal.GROUP_DESCRIPTION, rs.getString("group_description")); next.putIfAbsent(AuthzInternal.GROUP_DESCRIPTION, ""); next.put(Authz.GroupRecord.GROUPS, new ArrayList<ExtMap>()); } if (context.get(Global.SearchContext.ALL_ATTRIBUTES, Boolean.class, false)) { next.put(GroupKeys.DB_ID, rs.getInt("group_id")); } if (context.get(Global.SearchContext.WITH_GROUPS, Boolean.class)) { String nested = rs.getString("group_group_id"); if (nested != null) { ExtMap group = new ExtMap(); group.put(Authz.GroupRecord.NAMESPACE, rs.getString("namespace")); group.put(Authz.GroupRecord.ID, rs.getString("group_group_uuid")); group.put(Authz.GroupRecord.NAME, rs.getString("group_group_name")); group.put(Authz.GroupRecord.DISPLAY_NAME, rs.getString("group_group_display_name")); group.putIfAbsent(Authz.GroupRecord.DISPLAY_NAME, ""); group.put(AuthzInternal.GROUP_DESCRIPTION, rs.getString("group_group_description")); group.putIfAbsent(AuthzInternal.GROUP_DESCRIPTION, ""); next.get(Authz.PrincipalRecord.GROUPS, ArrayList.class).add(group); } } }
Source:
<code>protected void onLoginFinished() { AnalyticsUtils.trackAnalyticsSignIn(mAccountStore, mSiteStore, true); <START> mLoginListener.loggedInViaSocialAccount(SiteUtils.getCurrentSiteIds(mSiteStore, false)); <END> }</code><technical_language>start of Google login process do it, yeap. Note in case list need preserved survive rotations</technical_language>

Target:
protected void onLoginFinished() { AnalyticsUtils.trackAnalyticsSignIn(mAccountStore, mSiteStore, true); mLoginListener.loggedInViaSocialAccount(mOldSitesIDs); }
Source:
<code>private void downloadTokenAndStart(final Fragment fragment) { final ApiDownloader task = new ApiDownloader(fragment.getActivity(), ListFragment.lameStatic.dbHelper, null, MainActivity.TOKEN_URL, true, false, true, ApiDownloader.REQUEST_POST, new ApiListener() { @Override public void requestComplete(final JSONObject json, final boolean isCache) { try { final SharedPreferences prefs = fragment.getContext() <START> .getSharedPreferences(ListFragment.SHARED_PREFS, 0); <END> if (json.getBoolean("success")) { final String authname = json.getString("authname"); final String token = json.getString("token"); final SharedPreferences.Editor edit = prefs.edit(); edit.putString(ListFragment.PREF_AUTHNAME, authname); edit.putString(ListFragment.PREF_TOKEN, token); edit.apply(); start(); } else { MainActivity.warn("login failed. json: " + json); } } catch (final JSONException ex) { MainActivity.warn("json exception: " + ex + " json: " + json, ex); } } }); task.start(); }</code><technical_language>this prefs needs move, pry stay close is used. Guessing organically while playing solutions</technical_language>

Target:
private void downloadTokenAndStart(final Fragment fragment) { final ApiDownloader task = new ApiDownloader(fragment.getActivity(), ListFragment.lameStatic.dbHelper, null, MainActivity.TOKEN_URL, true, false, true, ApiDownloader.REQUEST_POST, new ApiListener() { @Override public void requestComplete(final JSONObject json, final boolean isCache) throws WiGLEAuthException { try { if (json.getBoolean("success")) { final String authname = json.getString("authname"); final String token = json.getString("token"); final SharedPreferences prefs = fragment.getContext() .getSharedPreferences(ListFragment.SHARED_PREFS, 0); final SharedPreferences.Editor edit = prefs.edit(); edit.putString(ListFragment.PREF_AUTHNAME, authname); edit.putString(ListFragment.PREF_TOKEN, token); edit.apply(); start(); } else if (json.has("credential_0")) { String message = "login failed for " + json.getString("credential_0"); MainActivity.warn(message); throw new WiGLEAuthException(message); } else { throw new WiGLEAuthException("Unable to log in."); } } catch (final JSONException ex) { MainActivity.warn("json exception: " + ex + " json: " + json, ex); throw new WiGLEAuthException("Unable to log in."); } } }); task.start(); }
Source:
<code>private void releaseWhenMergeCumulateThrowsInExpand(int untilFailure, boolean shouldFail) { ByteBuf oldCumulation = UnpooledByteBufAllocator.DEFAULT.heapBuffer(8, 8); final WriteFailingByteBuf newCumulation = new WriteFailingByteBuf(untilFailure, 16); ByteBufAllocator allocator = new AbstractByteBufAllocator(false) { @Override public boolean isDirectBufferPooled() { return false; } @Override protected ByteBuf newHeapBuffer(int initialCapacity, int maxCapacity) { return newCumulation; } @Override protected ByteBuf newDirectBuffer(int initialCapacity, int maxCapacity) { throw new UnsupportedOperationException(); } }; ByteBuf in = Unpooled.buffer().writeZero(12); Throwable thrown = null; try { ByteToMessageDecoder.MERGE_CUMULATOR.cumulate(allocator, oldCumulation, in); } catch (Throwable t) { thrown = t; } assertEquals(0, in.refCnt()); if (shouldFail) { assertSame(newCumulation.writeError(), thrown); assertEquals(1, oldCumulation.refCnt()); assertEquals(0, newCumulation.refCnt()); } else { assertNull(thrown); assertEquals(0, oldCumulation.refCnt()); assertEquals(1, newCumulation.refCnt()); } <START> } <END></code><technical_language>need call newCumulation.release(); ensure leak buffers in test</technical_language>

Target:
private void releaseWhenMergeCumulateThrowsInExpand(int untilFailure, boolean shouldFail) { ByteBuf oldCumulation = UnpooledByteBufAllocator.DEFAULT.heapBuffer(8, 8); final WriteFailingByteBuf newCumulation = new WriteFailingByteBuf(untilFailure, 16); ByteBufAllocator allocator = new AbstractByteBufAllocator(false) { @Override public boolean isDirectBufferPooled() { return false; } @Override protected ByteBuf newHeapBuffer(int initialCapacity, int maxCapacity) { return newCumulation; } @Override protected ByteBuf newDirectBuffer(int initialCapacity, int maxCapacity) { throw new UnsupportedOperationException(); } }; ByteBuf in = Unpooled.buffer().writeZero(12); Throwable thrown = null; try { ByteToMessageDecoder.MERGE_CUMULATOR.cumulate(allocator, oldCumulation, in); } catch (Throwable t) { thrown = t; } assertEquals(0, in.refCnt()); if (shouldFail) { assertSame(newCumulation.writeError(), thrown); assertEquals(1, oldCumulation.refCnt()); oldCumulation.release(); assertEquals(0, newCumulation.refCnt()); } else { assertNull(thrown); assertEquals(0, oldCumulation.refCnt()); assertEquals(1, newCumulation.refCnt()); newCumulation.release(); } }
Source:
<code>public T select() { int chance = random.nextInt(100); <START> for (Map.Entry<T, Integer> entry : operations.entrySet()) { <END> Integer probability = entry.getValue(); if ((chance -= probability) < 0) { return entry.getKey(); } } return defaultOperation; }</code><technical_language>a structure find a random operation. need iterate 50 items average find a good one; this in book is bad practice introduced a high constant factor overhead in selection algorithm. generating a Integer is dangerous; ok-ish -128..127 is cached... I find flaky. that; is reason for it. Tip: array of T size 100 generated random is index in this array. need loop anything. need generate a Integer instance</technical_language>

Target:
public T select() { int chance = random.nextInt(operations.length); return (T) operations[chance]; }
Source:
<code>public FormValidation doCheckSecurityOptsString(@QueryParameter String securityOptsString) { final List<String> securityOpts = splitAndFilterEmptyList(securityOptsString, "\n"); for (String securityOpt : securityOpts) { if (securityOpt.trim().split("=").length < 2) { <START> return FormValidation.error("Wrong security option format: '%s'", securityOpt); <END> } } return FormValidation.ok(); }</code><technical_language><LINK_0>, while _most_ of --security-opt arguments of form "name=value", isn't: > --security-opt="no-new-privileges:true|false" : Disable/enable container processes gaining new privileges ...and this is confused example: > docker run --security-opt no-new-privileges -it centos bash a :true :false end. As-is, this code complain user if option in form</technical_language>

Target:
public FormValidation doCheckSecurityOptsString(@QueryParameter String securityOptsString) { final List<String> securityOpts = splitAndFilterEmptyList(securityOptsString, "\n"); for (String securityOpt : securityOpts) { if ( !( securityOpt.trim().split("=").length == 2 || securityOpt.trim().startsWith( "no-new-privileges" ) ) ) { return FormValidation.warning("Security option may be incorrect. Please double check syntax: '%s'", securityOpt); } } return FormValidation.ok(); }
Source:
<code>private void setRegexMatchedTopicsToSourceNodes() { if (hasSubscriptionUpdates()) { for (final String nodeName : nodeToSourcePatterns.keySet()) { <START> final List<String> sourceTopics = ((SourceNodeFactory) nodeFactories.get(nodeName)) <END> .getTopics(subscriptionUpdates); nodeToSourceTopics.put(nodeName, sourceTopics); sourceTopicNames.addAll(sourceTopics); } log.debug("Updated nodeToSourceTopics: {}", nodeToSourceTopics); } }</code><technical_language>nit: I understand change for compactness, I find a hard follow. This is subjective feel free is</technical_language>

Target:
private void setRegexMatchedTopicsToSourceNodes() { if (hasSubscriptionUpdates()) { for (final String nodeName : nodeToSourcePatterns.keySet()) { final SourceNodeFactory sourceNode = (SourceNodeFactory) nodeFactories.get(nodeName); final List<String> sourceTopics = sourceNode.getTopics(subscriptionUpdates); nodeToSourceTopics.put(nodeName, sourceTopics); sourceTopicNames.addAll(sourceTopics); } log.debug("Updated nodeToSourceTopics: {}", nodeToSourceTopics); } }
Source:
<code>public void testBookieStartException() throws Exception { File journalDir = createTempDir("bookie", "journal"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(journalDir)); File ledgerDir = createTempDir("bookie", "ledger"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(ledgerDir)); int numOfEntries = 100; BookieJournalTest.writeV5Journal(Bookie.getCurrentDirectory(journalDir), numOfEntries, "testV5Journal".getBytes()); ServerConfiguration conf = TestBKConfiguration.newServerConfiguration(); int port = PortManager.nextFreePort(); conf.setBookiePort(port).setJournalDirName(journalDir.getPath()) .setLedgerDirNames(new String[] { ledgerDir.getPath() }).setMetadataServiceUri(metadataServiceUri) .setLedgerStorageClass(MockInterleavedLedgerStorage.class.getName()); BookieConfiguration bkConf = new BookieConfiguration(conf); Cookie.Builder cookieBuilder = Cookie.generateCookie(conf); Cookie cookie = cookieBuilder.build(); cookie.writeToDirectory(new File(journalDir, "current")); cookie.writeToDirectory(new File(ledgerDir, "current")); LifecycleComponent server = Main.buildBookieServer(bkConf); CompletableFuture<Void> startFuture = ComponentStarter.startComponent(server); <START> startFuture.get(); <END> }</code><technical_language>this line expected throw exception</technical_language>

Target:
public void testBookieStartException() throws Exception { File journalDir = createTempDir("bookie", "journal"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(journalDir)); File ledgerDir = createTempDir("bookie", "ledger"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(ledgerDir)); int numOfEntries = 100; BookieJournalTest.writeV5Journal(Bookie.getCurrentDirectory(journalDir), numOfEntries, "testV5Journal".getBytes()); ServerConfiguration conf = TestBKConfiguration.newServerConfiguration(); int port = PortManager.nextFreePort(); conf.setBookiePort(port).setJournalDirName(journalDir.getPath()) .setLedgerDirNames(new String[] { ledgerDir.getPath() }).setMetadataServiceUri(metadataServiceUri) .setLedgerStorageClass(MockInterleavedLedgerStorage.class.getName()); BookieConfiguration bkConf = new BookieConfiguration(conf); Cookie.Builder cookieBuilder = Cookie.generateCookie(conf); Cookie cookie = cookieBuilder.build(); cookie.writeToDirectory(new File(journalDir, "current")); cookie.writeToDirectory(new File(ledgerDir, "current")); LifecycleComponent server = Main.buildBookieServer(bkConf); CompletableFuture<Void> startFuture = ComponentStarter.startComponent(server); startFuture.get(); loggerOutput.expect((List<LoggingEvent> logEvents) -> { assertThat(logEvents, hasItem(hasProperty("message", containsString("Triggered exceptionHandler of Component:")))); }); }
Source:
<code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_firestore_paging); ButterKnife.bind(this); mFirestore = FirebaseFirestore.getInstance(); <START> mProgressBar.setIndeterminate(true); <END> setUpAdapter(); }</code><technical_language>move this XML</technical_language>

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_firestore_paging); ButterKnife.bind(this); mFirestore = FirebaseFirestore.getInstance(); mItemsCollection = mFirestore.collection("items"); setUpAdapter(); }
Source:
<code>public float getFloat(ByteBuffer buf, int position) { <START> return delegate.getFloat(buf, position + Byte.BYTES); <END> }</code><technical_language>above, suggested a defensive check</technical_language>

Target:
public float getFloat(ByteBuffer buf, int position) { if (isNull(buf, position)) { throw new IllegalStateException("Cannot return float for Null Value"); } return delegate.getFloat(buf, position + Byte.BYTES); }
Source:
<code>public boolean shouldForceTargets() { <START> totem.onChunkUnloaded(); totem.world.isAreaLoaded(pos, (int)villageArea.getAverageEdgeLength()); <END> return this.totem.captureForceTargetTimer > VampirismConfig.BALANCE.viForceTargetTime.get(); }</code><technical_language>Is this intended</technical_language>

Target:
public boolean shouldForceTargets() { return this.totem.captureForceTargetTimer > VampirismConfig.BALANCE.viForceTargetTime.get(); }
Source:
<code>public int getSSLPort() { <START> if (ports.containsKey("sslport")) { <END> return ports.get("sslport"); } else { throw new IllegalStateException("No SSL port exists for the Data Node " + hostname + ":" + port); } }</code><technical_language>I guess (PortType.SSL)</technical_language>

Target:
public int getSSLPort() { if (hasSSLPort()) { return ports.get(PortType.SSL); } else { throw new IllegalStateException("No SSL port exists for the Data Node " + hostname + ":" + port); } }
Source:
<code>private void internalStopTracking() { if (isTracking()) { if (logger.isLoggable(getClass(), TechnicalLogSeverity.WARNING)) { this.logger.log(getClass(), TechnicalLogSeverity.WARNING, "Stopping Time tracker tracking..."); } if (flushThread.isStarted()) { flushThread.interrupt(); } for (final FlushEventListener listener : getActiveFlushEventListeners()) { listener.notifyStopTracking(); } <START> if (logger.isLoggable(getClass(), TechnicalLogSeverity.WARNING)) { <END> this.logger.log(getClass(), TechnicalLogSeverity.WARNING, "Time tracker tracking is deactivated."); } } }</code><technical_language>warnings factories in methods constants this code easier read</technical_language>

Target:
private void internalStopTracking() { if (isTracking()) { log(TechnicalLogSeverity.WARNING, "Stopping Time tracker tracking..."); if (flushThread.isStarted()) { flushThread.interrupt(); } for (final FlushEventListener listener : getActiveFlushEventListeners()) { listener.notifyStopTracking(); } log(TechnicalLogSeverity.WARNING, "Time tracker tracking is deactivated."); } }
Source:
<code>public void visitToken(DetailAST ast) { final int type = ast.getType(); final boolean hasNoSlist = ast.findFirstToken(TokenTypes.SLIST) == null; boolean hasViolation = hasNoSlist && !isSkipStatement(ast); <START> switch (type) { <END> case TokenTypes.LITERAL_FOR: case TokenTypes.LITERAL_WHILE: hasViolation = hasViolation && !isEmptyLoopBodyAllowed(ast); break; case TokenTypes.LITERAL_CASE: case TokenTypes.LITERAL_DEFAULT: hasViolation = hasViolation && hasUnbracedStatements(ast); break; case TokenTypes.LITERAL_ELSE: hasViolation = hasViolation && ast.findFirstToken(TokenTypes.LITERAL_IF) == null; break; default: break; } if (hasViolation) { log(ast.getLineNo(), MSG_KEY_NEED_BRACES, ast.getText()); } }</code><technical_language>@strkkk please move this switch a new method. method if (hasNoSlist && !isSkipStatement(ast) && needBraces(ast)) { log(ast.getLineNo(), MSG_KEY_NEED_BRACES, ast.getText()); } needBraces method more readable strnge boolean = boolean && expr</technical_language>

Target:
public void visitToken(DetailAST ast) { final boolean hasNoSlist = ast.findFirstToken(TokenTypes.SLIST) == null; if (hasNoSlist && !isSkipStatement(ast) && isBracesNeeded(ast)) { log(ast.getLineNo(), MSG_KEY_NEED_BRACES, ast.getText()); } }
Source:
<code>public int compare(@NotNull TcpDiscoveryNode firstNode, @NotNull TcpDiscoveryNode secondNode) { Long firstRegionId = firstNode.getClusterRegionId(); Long secondRegionId = secondNode.getClusterRegionId(); <START> if (firstRegionId == null && secondRegionId == null) <END> return firstNode.compareTo(secondNode); if (firstRegionId == null) return -1; if (secondRegionId == null) return 1; if (firstRegionId.equals(secondRegionId)) return firstNode.compareTo(secondNode); return firstRegionId.compareTo(secondRegionId); }</code><technical_language>plenty of formatting issues - please refer <LINK_0></technical_language>

Target:
@Override public int compare(@NotNull TcpDiscoveryNode firstNode, @NotNull TcpDiscoveryNode secondNode) { long firstRegionId = firstNode.getClusterRegionId(); long secondRegionId = secondNode.getClusterRegionId(); if (firstRegionId == secondRegionId) return firstNode.compareTo(secondNode); return (firstRegionId<secondRegionId)?-1:1; }