auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public AssetView(List<Player> players) { setLayout(new MigLayout( "aligny top,wrap 15, gap 0", "0[]0[]0", "0[]1[]1[]1[]1[]1[]1[]1" )); if(players.size() > 1) add(new JLabel("Player"), MIG_CONFIG); else add(new JLabel()); add(newJLabel(WOOD_ICON), MIG_CONFIG); add(newJLabel(STONE_ICON), MIG_CONFIG); add(newJLabel(CLAY_ICON), MIG_CONFIG); add(newJLabel(ORE_ICON), MIG_CONFIG); add(newJLabel(LOOM_ICON), MIG_CONFIG); add(newJLabel(PAPYRUS_ICON), MIG_CONFIG); add(newJLabel(GLASS_ICON), MIG_CONFIG); add(newJLabel(SCIENCE1_ICON), MIG_CONFIG); add(newJLabel(SCIENCE2_ICON), MIG_CONFIG); add(newJLabel(SCIENCE3_ICON), MIG_CONFIG); add(newJLabel(GOLD_ICON), MIG_CONFIG); add(newJLabel(VICTORY_ICON), MIG_CONFIG); add(newJLabel(SHIELD_ICON), MIG_CONFIG); JLabel stageLabel = newJLabel(STAGE_ICON); resizeJLabelIcon(stageLabel,-1,60); add(stageLabel, MIG_CONFIG); for(Player player : players) { <START> if(players.size() > 1) add(new JLabel("Player " + player.getPlayerId())); <END> else add(new JLabel()); AssetMap playerAssets = player.getAssets(); for(String asset : Asset.ASSET_TYPES) { add(newTextJLabel("" + playerAssets.get(asset)),MIG_CONFIG); } } }</code><technical_language>consumer of AssetView. checked this disturb else</technical_language>

Target:
public AssetView(List<Player> players) { setLayout(new MigLayout( "aligny top,wrap 15, gap 0", "0[]0[]0", "0[]1[]1[]1[]1[]1[]1[]1" )); if(players.size() > 1) add(new JLabel("Player"), MIG_CONFIG); else add(new JLabel()); add(newJLabel(WOOD_ICON), MIG_CONFIG); add(newJLabel(STONE_ICON), MIG_CONFIG); add(newJLabel(CLAY_ICON), MIG_CONFIG); add(newJLabel(ORE_ICON), MIG_CONFIG); add(newJLabel(LOOM_ICON), MIG_CONFIG); add(newJLabel(PAPYRUS_ICON), MIG_CONFIG); add(newJLabel(GLASS_ICON), MIG_CONFIG); add(newJLabel(SCIENCE1_ICON), MIG_CONFIG); add(newJLabel(SCIENCE2_ICON), MIG_CONFIG); add(newJLabel(SCIENCE3_ICON), MIG_CONFIG); add(newJLabel(GOLD_ICON), MIG_CONFIG); add(newJLabel(VICTORY_ICON), MIG_CONFIG); add(newJLabel(SHIELD_ICON), MIG_CONFIG); JLabel stageLabel = newJLabel(STAGE_ICON); resizeJLabelIcon(stageLabel,-1,60); add(stageLabel, MIG_CONFIG); for(Player player : players) { if(players.size() > 1) add(new JLabel(player.toString())); else add(new JLabel()); AssetMap playerAssets = player.getAssets(); for(String asset : Asset.ASSET_TYPES) { add(newTextJLabel("" + playerAssets.get(asset)),MIG_CONFIG); } } }
Source:
<code>void activate() { try { Central.bndCall(() -> { process(); <START> list = memoize(this::list0); <END> return null; }); } catch (Exception e) { logger.error("Could not activate {}", getName(), e); } }</code><technical_language>This do want. creates memoize object. need wrap supplier. move bndCall invocation list0</technical_language>

Target:
void activate() { process(); }
Source:
<code>public void testAdaptor() throws Exception { byte[] testByteArray = new byte[]{1, 2, 3}; ByteArrayObjectDataOutput out = new ByteArrayObjectDataOutput(10, mockSerializationService, ByteOrder.BIG_ENDIAN); <START> ByteArrayObjectDataInput in = new ByteArrayObjectDataInput(out.buffer, mockSerializationService, ByteOrder.BIG_ENDIAN, false); <END> adapter.write(out, testByteArray); byte[] read = (byte[]) adapter.read(in); Serializer impl = adapter.getImpl(); assertArrayEquals(testByteArray, read); assertEquals(serializer, impl); assertEquals(serializer.getTypeId(), adapter.getTypeId()); }</code><technical_language>Minor suggestion: create constructors hide false compatibility flag touch places classes in "compatibility mode" is possible</technical_language>

Target:
public void testAdaptor() throws Exception { byte[] testByteArray = new byte[]{1, 2, 3}; ByteArrayObjectDataOutput out = new ByteArrayObjectDataOutput(10, mockSerializationService, ByteOrder.BIG_ENDIAN); ByteArrayObjectDataInput in = new ByteArrayObjectDataInput(out.buffer, mockSerializationService, ByteOrder.BIG_ENDIAN); adapter.write(out, testByteArray); byte[] read = (byte[]) adapter.read(in); Serializer impl = adapter.getImpl(); assertArrayEquals(testByteArray, read); assertEquals(serializer, impl); assertEquals(serializer.getTypeId(), adapter.getTypeId()); }
Source:
<code>public void onFileDeleting(OfflineFileDeleteEvent event) { AlertDialog.Builder builder = new AlertDialog.Builder(this); <START> builder.setTitle("Delete file"); <END> builder.setMessage("Are you sure?"); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { deleteFileFromOfflineStorage(event.getFile()); } }); builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alertDialog = builder.create(); alertDialog.show(); }</code><technical_language>I recommend putting strings visible user in strings.xml</technical_language>

Target:
public void onFileDeleting(OfflineFileDeleteEvent event) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.alert_delete_dialog); builder.setMessage(R.string.alert_delete_confirm); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { deleteFileFromOfflineStorage(event.getFile()); } }); builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alertDialog = builder.create(); alertDialog.show(); }
Source:
<code>private Stream<String> complaintsForResourceType(List<Protos.Resource> resources, String resourceName, double minSize) { double totalSize = resources.stream().filter(resource -> resource.getName().equals(resourceName)).collect(Collectors.summingDouble(resource -> resource.getScalar().getValue())); if (totalSize < minSize) { <START> return Arrays.asList("required minimum " + minSize + " " + resourceName + " but offer only has " + totalSize + " in total").stream(); <END> } else { String[] reasons = new String[]{}; return Arrays.asList(reasons).stream(); } }</code><technical_language>java.util.Collections.singletonList() is a lot safer, immutable</technical_language>

Target:
private Stream<String> complaintsForResourceType(List<Protos.Resource> resources, String resourceName, double minSize) { double totalSize = resources.stream().filter(resource -> resource.getName().equals(resourceName)).collect(Collectors.summingDouble(resource -> resource.getScalar().getValue())); if (totalSize < minSize) { return Collections.singletonList("required minimum " + minSize + " " + resourceName + " but offer only has " + totalSize + " in total").stream(); } else { return Arrays.asList(new String[]{}).stream(); } }
Source:
<code>public Configuration loadConfiguration() { File configFile = getFileSystemConfigFile(); if (!configFile.exists()) { LOGGER.warn(" file " + configFile + " does not exist --> loading default config.xml from classpath"); return ScenarioDocuXMLFileUtil.unmarshal(Configuration.class, getDefaultConfigFile()); } LOGGER.info(" loading configuration from file: " + configFile); <START> return ScenarioDocuXMLFileUtil.unmarshal(Configuration.class, configFile); <END> }</code><technical_language>@mi-we I else block is necessary - ... I recommend put - more explicit (easier read) other is done</technical_language>

Target:
public Configuration loadConfiguration() { File configFile = getFileSystemConfigFile(); if (!configFile.exists()) { LOGGER.warn(" file " + configFile + " does not exist --> loading default config.xml from classpath"); return ScenarioDocuXMLFileUtil.unmarshal(Configuration.class, getDefaultConfigFile()); } else { LOGGER.info(" loading configuration from file: " + configFile); return ScenarioDocuXMLFileUtil.unmarshal(Configuration.class, configFile); } }
Source:
<code>public boolean isEligible(TaskResult result) { <START> StepResult<Boolean> stepResult = (StepResult<Boolean>) result.getStepResult(SignUpInclusionCriteriaStepIdentifier); <END> if(stepResult != null) { return stepResult.getResult(); } return false; }</code><technical_language>@crayne This supposed part of this PR, right</technical_language>

Target:
public boolean isEligible(TaskResult result) { StepResult<Boolean> stepResult = (StepResult<Boolean>) result.getStepResult(SignUpTask.SignUpInclusionCriteriaStepIdentifier); if(stepResult != null) { return stepResult.getResult(); } return false; }
Source:
<code>public Map<String, String> getKeywordMap(NodeTemplate nodeTemplate) { <START> return MutableMap.of( <END> "SELF", nodeTemplate.getName() ); }</code><technical_language>Is mutability required</technical_language>

Target:
public Map<String, String> getKeywordMap(NodeTemplate nodeTemplate) { ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); String nodeTemplateName = nodeTemplate.getName(); if (nodeTemplateName != null) { builder.put("SELF", nodeTemplateName); } return builder.build(); }
Source:
<code>protected void endWithFailure() { unLockImage(); log.warnFormat("Failed to extend size of the volume '${0}', user: '${1}'", getImage().getId(), getUserName()); addCustomValue("DiskId", getImageId().toString()); addCustomValue("UserName", getUserName()); AuditLogDirector.log(this, AuditLogType.USER_EXTEND_DISK_SIZE_FAILURE); <START> setSucceeded(true); <END> }</code><technical_language>if command ended failure, is setSucceeded true? Also, implications of a failed extend size - is disk in "healthy" condition this operation</technical_language>

Target:
protected void endWithFailure() { if (log.isWarnEnabled()) { log.warnFormat("Failed to extend size of the volume '${0}', user: '${1}'", getImage().getId(), getUserName()); } updateAuditLog(AuditLogType.USER_EXTEND_DISK_SIZE_FAILURE); getReturnValue().setEndActionTryAgain(false); }
Source:
<code>public void openLink(final String link) { if (ChanSettings.openLinkConfirmation.get()) { new AlertDialog.Builder(getContext()) .setNegativeButton(R.string.cancel, null) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { <START> if (ChanSettings.openLinkBrowser.get()) { <END> AndroidUtils.openLink(link); } else { AndroidUtils.openLinkInBrowser((Activity) getContext(), link); } } }) .setTitle(R.string.open_link_confirmation) .setMessage(link) .show(); } else { if (ChanSettings.openLinkBrowser.get()) { AndroidUtils.openLink(link); } else { AndroidUtils.openLinkInBrowser((Activity) getContext(), link); } } }</code><technical_language>create a method for this duplicated code</technical_language>

Target:
public void openLink(final String link) { if (ChanSettings.openLinkConfirmation.get()) { new AlertDialog.Builder(getContext()) .setNegativeButton(R.string.cancel, null) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { openLinkConfirmed(link); } }) .setTitle(R.string.open_link_confirmation) .setMessage(link) .show(); } else { openLinkConfirmed(link); } }
Source:
<code><START> private DatasetTrainer<IgniteModel<IS, O>, L> getTrainer() { <END> if (submodelInput2AggregatingInputConverter == null && submodelsTrainers.isEmpty()) throw new IllegalStateException("There should be at least one way for submodels " + "input to be propageted to aggregator."); if (submodelOutput2VectorConverter == null || vector2SubmodelInputConverter == null) throw new IllegalStateException("There should be a specified way to convert vectors to submodels " + "input and submodels output to vector"); if (aggregatingInputMerger == null) throw new IllegalStateException("Binary operator used to convert outputs of submodels is not specified"); List<DatasetTrainer<IgniteModel<IS, IA>, L>> subs = new ArrayList<>(); if (submodelInput2AggregatingInputConverter != null) { DatasetTrainer<IgniteModel<IS, IS>, L> id = DatasetTrainer.identityTrainer(); DatasetTrainer<IgniteModel<IS, IA>, L> mappedId = CompositionUtils.unsafeCoerce( AdaptableDatasetTrainer.of(id).afterTrainedModel(submodelInput2AggregatingInputConverter)); subs.add(mappedId); } subs.addAll(submodelsTrainers); TrainersParallelComposition<IS, IA, L> composition = new TrainersParallelComposition<>(subs); IgniteBiFunction<List<IgniteModel<IS, IA>>, Vector, Vector> featureMapper = getFeatureExtractorForAggregator( submodelOutput2VectorConverter, vector2SubmodelInputConverter); return AdaptableDatasetTrainer .of(composition) .afterTrainedModel(lst -> lst.stream().reduce(aggregatingInputMerger).get()) .andThen(aggregatorTrainer, model -> new DatasetMapping<L, L>() { @Override public Vector mapFeatures(Vector v) { List<IgniteModel<IS, IA>> models = ((ModelsParallelComposition<IS, IA>)model.innerModel()).submodels(); return featureMapper.apply(models, v); } @Override public L mapLabels(L lbl) { return lbl; } }).unsafeSimplyTyped(); }</code><technical_language>Is split this method smaller? Quiet hard understand here</technical_language>

Target:
private DatasetTrainer<IgniteModel<IS, O>, L> getTrainer() { checkConsistency(); List<DatasetTrainer<IgniteModel<IS, IA>, L>> subs = new ArrayList<>(); if (submodelInput2AggregatingInputConverter != null) { DatasetTrainer<IgniteModel<IS, IS>, L> id = DatasetTrainer.identityTrainer(); DatasetTrainer<IgniteModel<IS, IA>, L> mappedId = CompositionUtils.unsafeCoerce( AdaptableDatasetTrainer.of(id).afterTrainedModel(submodelInput2AggregatingInputConverter)); subs.add(mappedId); } subs.addAll(submodelsTrainers); TrainersParallelComposition<IS, IA, L> composition = new TrainersParallelComposition<>(subs); IgniteBiFunction<List<IgniteModel<IS, IA>>, Vector, Vector> featureMapper = getFeatureExtractorForAggregator( submodelOutput2VectorConverter, vector2SubmodelInputConverter); return AdaptableDatasetTrainer .of(composition) .afterTrainedModel(lst -> lst.stream().reduce(aggregatingInputMerger).get()) .andThen(aggregatorTrainer, model -> new DatasetMapping<L, L>() { @Override public Vector mapFeatures(Vector v) { List<IgniteModel<IS, IA>> models = ((ModelsParallelComposition<IS, IA>)model.innerModel()).submodels(); return featureMapper.apply(models, v); } @Override public L mapLabels(L lbl) { return lbl; } }).unsafeSimplyTyped(); }
Source:
<code>public void proxy(HttpServletRequest req, HttpServletResponse resp, HttpProxyRequestOptions options) throws IOException { if (options == null) { options = new HttpProxyRequestOptions(); } <START> boolean includeRequestPayload = isIncludeRequestPayload(req); <END> String url = rewriteUrl(req, options); HttpRequest httpReq = BEANS.get(DefaultHttpTransportManager.class).getHttpRequestFactory().buildRequest(req.getMethod(), new GenericUrl(url), null); httpReq = prepareRequest(httpReq); writeRequestHeaders(req, httpReq); writeCustomRequestHeaders(httpReq, options.getCustomRequestHeaders()); if (includeRequestPayload) { if (!req.getParameterMap().isEmpty()) { writeRequestParameters(req, httpReq); } else { writeRequestPayload(req, httpReq); } } HttpResponse httpResp = httpReq.execute(); writeResponseHeaders(resp, httpResp); writeResponseStatus(resp, httpResp); writeResponsePayload(resp, httpResp); LOG.debug("Forwarded request to {}", req.getMethod(), url); }</code><technical_language>This boolean variable is unnecessary, call isIncludeRequestPayload() inlined</technical_language>

Target:
public void proxy(HttpServletRequest req, HttpServletResponse resp, HttpProxyRequestOptions options) throws IOException { if (options == null) { options = new HttpProxyRequestOptions(); } String url = rewriteUrl(req, options); HttpRequest httpReq = BEANS.get(DefaultHttpTransportManager.class).getHttpRequestFactory().buildRequest(req.getMethod(), new GenericUrl(url), null); httpReq = prepareRequest(httpReq); writeRequestHeaders(req, httpReq); writeCustomRequestHeaders(httpReq, options.getCustomRequestHeaders()); if (shouldIncludeRequestPayload(req)) { if (!req.getParameterMap().isEmpty()) { writeRequestParameters(req, httpReq); } else { writeRequestPayload(req, httpReq); } } HttpResponse httpResp = httpReq.execute(); writeResponseHeaders(resp, httpResp); writeResponseStatus(resp, httpResp); writeResponsePayload(resp, httpResp); LOG.debug("Forwarded request to {}", req.getMethod(), url); }
Source:
<code>protected AdditionsAndRetractions parseN3ToChange( List<String> requiredAdds, List<String> optionalAdds, List<String> requiredDels, List<String> optionalDels, VitroRequest vreq, EditConfigurationVTwo editConfig) throws Exception{ List<Model> adds = parseN3ToRDF(requiredAdds, REQUIRED); adds.addAll( parseN3ToRDF(optionalAdds, OPTIONAL)); List<Model> retracts = new ArrayList<Model>(); if( requiredDels != null && optionalDels != null ){ String lingCxt=null; try { <START> if (editConfig != null && editConfig.getLiteralsInScope().get("label").get(0).getLanguage() != "") { <END> lingCxt = editConfig.getLiteralsInScope().get("label").get(0).getLanguage(); } else { lingCxt = vreq.getLocale().getLanguage(); if (!vreq.getLocale().getCountry().isEmpty()) { lingCxt += "-" + vreq.getLocale().getCountry(); } } } catch (Exception e) { } retracts.addAll( parseN3ToRDF(requiredDels, REQUIRED, lingCxt) ); retracts.addAll( parseN3ToRDF(optionalDels, OPTIONAL, lingCxt) ); } return new AdditionsAndRetractions(adds,retracts); }</code><technical_language>Instead of !=, !...equals(). ..or .isEmpty(). Is a chance language null? If so, StringUtils.isBlank()</technical_language>

Target:
protected AdditionsAndRetractions parseN3ToChange( List<String> requiredAdds, List<String> optionalAdds, List<String> requiredDels, List<String> optionalDels, VitroRequest vreq, EditConfigurationVTwo editConfig) throws Exception{ List<Model> adds = parseN3ToRDF(requiredAdds, REQUIRED); adds.addAll( parseN3ToRDF(optionalAdds, OPTIONAL)); List<Model> retracts = new ArrayList<Model>(); if( requiredDels != null && optionalDels != null ){ String lingCxt=null; try { Boolean getLabelLanguage = false; if (!StringUtils.isBlank(editConfig.formUrl) && editConfig.formUrl.contains("RDFSLabelGenerator")) { getLabelLanguage = true; } if (editConfig != null && !StringUtils.isBlank(editConfig.getLiteralsInScope().get("label").get(0).getLanguage()) && getLabelLanguage) { lingCxt = editConfig.getLiteralsInScope().get("label").get(0).getLanguage(); } else { lingCxt = vreq.getLocale().getLanguage(); if (!vreq.getLocale().getCountry().isEmpty()) { lingCxt += "-" + vreq.getLocale().getCountry(); } } } catch (Exception e) { } retracts.addAll( parseN3ToRDF(requiredDels, REQUIRED, lingCxt) ); retracts.addAll( parseN3ToRDF(optionalDels, OPTIONAL, lingCxt) ); } return new AdditionsAndRetractions(adds,retracts); }
Source:
<code>private static EventFiringWebDriver getChromeInstance() { String chromeBinaryPath = ""; String osName = System.getProperty("os.name").toUpperCase(); if (osName.contains("WINDOWS")) { <START> chromeBinaryPath = "/chromedriver_win32/chromedriver.exe"; <END> }else if (osName.contains("MAC")) { chromeBinaryPath = "/chromedriver_mac32/chromedriver"; }else if (osName.contains("LINUX")) { chromeBinaryPath ="/chromedriver_linux32/chromedriver"; File chromedriver = new File(ClassLoader.getSystemResource("ChromeDriver" + chromeBinaryPath ) .getPath()); chromedriver.setExecutable(true); } System.setProperty("webdriver.chrome.driver", new File(ClassLoader.getSystemResource("ChromeDriver" + chromeBinaryPath ).getPath()).getAbsolutePath()); if ("CHROMEMOBILE".equals(browserName)) { chromeOptions.addArguments( "--user-agent=" + userAgentRegistry.getUserAgent("iPhone") ); } if ("CHROMEMOBILEMERCURY".equals(browserName)) { chromeOptions.addArguments( "--user-agent=" + userAgentRegistry.getUserAgent("iPhone+Mercury") ); } caps.setCapability(ChromeOptions.CAPABILITY, chromeOptions); setBrowserLogging(Level.SEVERE); return new EventFiringWebDriver(new ChromeDriver(caps)); }</code><technical_language>I chromedrver_win32 directory in repo chromedriver for win</technical_language>

Target:
private static EventFiringWebDriver getChromeInstance() { String chromeBinaryPath = ""; String osName = System.getProperty("os.name").toUpperCase(); if (osName.contains("WINDOWS")) { chromeBinaryPath = "/chromedriver_win32/chromedriver.exe"; }else if (osName.contains("MAC")) { chromeBinaryPath = "/chromedriver_mac32/chromedriver"; }else if (osName.contains("LINUX")) { chromeBinaryPath ="/chromedriver_linux64/chromedriver"; File chromedriver = new File(ClassLoader.getSystemResource("ChromeDriver" + chromeBinaryPath ) .getPath()); chromedriver.setExecutable(true); } System.setProperty("webdriver.chrome.driver", new File(ClassLoader.getSystemResource("ChromeDriver" + chromeBinaryPath ).getPath()).getPath()); if ("CHROMEMOBILE".equals(browserName)) { chromeOptions.addArguments( "--user-agent=" + userAgentRegistry.getUserAgent("iPhone") ); } if ("CHROMEMOBILEMERCURY".equals(browserName)) { chromeOptions.addArguments( "--user-agent=" + userAgentRegistry.getUserAgent("iPhone+Mercury") ); } caps.setCapability(ChromeOptions.CAPABILITY, chromeOptions); setBrowserLogging(Level.SEVERE); return new EventFiringWebDriver(new ChromeDriver(caps)); }
Source:
<code>public void testValidatePipeFailAsNotTheSame() throws Exception { <START> session.put("key", "2:22:22"); pipe.setHashSessionKey("key"); pipe.configure(); PipeRunResult res = doPipe(pipe, "password", session); assertEquals(null, res.getPipeForward()); <END> }</code><technical_language>I understand pipeforward equals null, case :S is happening here</technical_language>

Target:
public void testValidatePipeFailAsNotTheSame() throws Exception { String hashed = PasswordHash.createHash("password"); session.put("key", hashed+"2132"); pipe.setHashSessionKey("key"); pipe.configure(); pipe.registerForward(new PipeForward("failure", "random/path")); PipeRunResult res = doPipe(pipe, "password", session); assertEquals("failure", res.getPipeForward().getName()); }
Source:
<code><START> public MergeRequestFilterWIP getWip() { return wip; } <END></code><technical_language>return a Boolean</technical_language>

Target:
public Boolean getWip() { return wip; }
Source:
<code>public void setQueryDatum(ExternalDataInstance queryResultInstance) { SessionDatum datum = getNeededDatum(); if (datum instanceof RemoteQueryDatum) { StackFrameStep step = new StackFrameStep(SessionFrame.STATE_QUERY_REQUEST, datum.getDataId(), datum.getValue()); <START> frame.pushStep(step); <END> if (queryResultInstance != null) { instances.put(datum.getDataId(), queryResultInstance); } syncState(); } else { throw new RuntimeException("Trying to set query successful when one isn't needed."); } }</code><technical_language>curious here: injecting instance straight frame? odd in sync this way</technical_language>

Target:
public void setQueryDatum(ExternalDataInstance queryResultInstance) { SessionDatum datum = getNeededDatum(); if (datum instanceof RemoteQueryDatum) { StackFrameStep step = new StackFrameStep(SessionFrame.STATE_QUERY_REQUEST, datum.getDataId(), datum.getValue(), queryResultInstance); frame.pushStep(step); syncState(); } else { throw new RuntimeException("Trying to set query successful when one isn't needed."); } }
Source:
<code>String getTraceId(HttpServletRequest req) { final String stringValue = getStringParameter(req, "id", null); <START> return TRACE_ID_PATTERN.matcher(stringValue).matches() ? stringValue : null; <END> }</code><technical_language>This produce NPE matcher if stringValue is null. want add a check for that: suggestion if (stringValue == null) { return null; } return TRACE_ID_PATTERN.matcher(stringValue).matches() ? stringValue : null;</technical_language>

Target:
String getTraceId(HttpServletRequest req) { final String stringValue = getStringParameter(req, "id", null); if (stringValue == null) { return null; } return TRACE_ID_PATTERN.matcher(stringValue).matches() ? stringValue : null; }
Source:
<code>private void checkValidationParameterValue(IElementParameter param) { if (param.isShow(getElementParameters()) && param.getFieldType().equals(EParameterFieldType.TEXT) <START> && param instanceof IGenericElementParameter) { <END> String paramValue = String.valueOf(param.getValue()); if (!ContextParameterUtils.isContainContextParam(paramValue)) { org.talend.daikon.properties.property.Property property = ((IGenericElementParameter) param).getProperty(); if (property != null && GenericTypeUtils.isIntegerType(property)) { boolean isDigits = org.apache.commons.lang.math.NumberUtils.isDigits(paramValue); if (!isDigits) { String errorMessage = Messages.getString("Node.parameter.value.validation.integer", param.getDisplayName()); Problems.add(ProblemStatus.ERROR, this, errorMessage); } } } } }</code><technical_language>Please put **instanceof** check avoid **isShow** check if possible: if (param instanceof IGenericElementParameter && param.getFieldType().equals(EParameterFieldType.TEXT) && param.isShow(getElementParameters()))</technical_language>

Target:
private void checkValidationParameterValue(IElementParameter param) { if (param instanceof IGenericElementParameter && param.getFieldType().equals(EParameterFieldType.TEXT) && param.isShow(getElementParameters())) { String paramValue = String.valueOf(param.getValue()); if (!ContextParameterUtils.isContainContextParam(paramValue)) { org.talend.daikon.properties.property.Property property = ((IGenericElementParameter) param).getProperty(); if (property != null && GenericTypeUtils.isIntegerType(property)) { boolean isDigits = org.apache.commons.lang.math.NumberUtils.isDigits(paramValue); if (!isDigits) { String errorMessage = Messages.getString("Node.parameter.value.validation.integer", param.getDisplayName()); Problems.add(ProblemStatus.ERROR, this, errorMessage); } } } } }
Source:
<code>public void shouldReturnRefundTransactionWhenThereAreChargeAndRefundTransactions() throws Exception { RefundTransactionEntity refundTransaction = new RefundTransactionEntity(); String refundReference = "someRefundReference"; <START> refundTransaction.setRefundExternalId(refundReference); <END> paymentRequestEntity.addTransaction(refundTransaction); List<RefundTransactionEntity> refundTransactions = paymentRequestEntity.getRefundTransactions(); assertThat(refundTransactions.size(), is(1)); assertThat(refundTransactions.get(0).getRefundExternalId(), is(refundReference)); }</code><technical_language>local variable is called refundReference external ID</technical_language>

Target:
public void shouldReturnRefundTransactionWhenThereAreChargeAndRefundTransactions() throws Exception { RefundTransactionEntity refundTransaction = new RefundTransactionEntity(); String refundExternalId = "someRefundExternalId"; refundTransaction.setRefundExternalId(refundExternalId); paymentRequestEntity.addTransaction(refundTransaction); List<RefundTransactionEntity> refundTransactions = paymentRequestEntity.getRefundTransactions(); assertThat(refundTransactions.size(), is(1)); assertThat(refundTransactions.get(0).getRefundExternalId(), is(refundExternalId)); }
Source:
<code>public void setObservationLevel(final String observationLevel) { final Integer datasetTypeId = DatasetTypeEnum.getIdByName(observationLevel); <START> if(datasetTypeId > 0) { <END> this.observationLevel = Integer.toString(datasetTypeId); } else { this.observationLevel = observationLevel; } }</code><technical_language>I this logic reside elsewhere, a service controller class. A DTO properties getters setters. a unit test for this logic</technical_language>

Target:
public void setObservationLevel(final String observationLevel) { this.observationLevel = observationLevel; }
Source:
<code>public void expungeMessages(List<? extends Message> messages) throws MessagingException { if (messages.isEmpty()) { return; } checkOpen(); String[] uids = new String[messages.size()]; for (int i = 0, count = messages.size(); i < count; i++) { uids[i] = messages.get(i).getUid(); } try { executeSimpleCommand(String.format("UID EXPUNGE %s", combine(uids, ','))); <START> return; <END> } catch (IOException ioe) { throw ioExceptionHandler(connection, ioe); } }</code><technical_language>unnecessary return statement</technical_language>

Target:
public void expungeMessages(List<? extends Message> messages) throws MessagingException { if (messages.isEmpty()) { return; } checkOpen(); String[] uids = MessageUtils.getUidsFromMessages(messages); try { executeSimpleCommand(String.format("UID EXPUNGE %s", combine(uids, ','))); } catch (IOException ioe) { throw ioExceptionHandler(connection, ioe); } }
Source:
<code>boolean fillChunks() { PutChunk chunkToFill; <START> if (chunkFillComplete || operationCompleted) { <END> return true; } do { if (channelReadBuffer == null) { try { channelReadBuffer = chunkFillerChannel.getNextChunk(0); } catch (InterruptedException e) { throw new IllegalStateException( "Received InterruptedException from a call that is expected to be non-blocking."); } } if (channelReadBuffer != null) { chunkToFill = getChunkToFill(); if (chunkToFill == null) { break; } bytesFilledSoFar += chunkToFill.fillFrom(channelReadBuffer); if (chunkToFill.isFull() || bytesFilledSoFar == blobSize) { chunkToFill.onFillComplete(); } if (!channelReadBuffer.hasRemaining()) { channelReadBuffer = null; chunkFillerChannel.resolveOldestChunk(null); } } else { break; } } while (bytesFilledSoFar < blobSize); if (bytesFilledSoFar == blobSize) { chunkFillComplete = true; } return chunkFillComplete; }</code><technical_language>operationCompleted volatile</technical_language>

Target:
void fillChunks() throws InterruptedException { PutChunk chunkToFill; if (!chunkFillingCompleted && !operationCompleted) { do { if (channelReadBuffer == null) { channelReadBuffer = chunkFillerChannel.getNextChunk(0); } if (channelReadBuffer != null) { chunkToFill = getChunkToFill(); if (chunkToFill == null) { break; } bytesFilledSoFar += chunkToFill.fillFrom(channelReadBuffer); if (!channelReadBuffer.hasRemaining()) { chunkFillerChannel.resolveOldestChunk(null); channelReadBuffer = null; } } else { break; } } while (bytesFilledSoFar < blobSize); if (bytesFilledSoFar == blobSize) { chunkFillingCompleted = true; } } }
Source:
<code>public long writeTo(WritableByteChannel channel) throws IOException { long written = 0; try { if (sentBytes < sizeInBytes()) { <START> prepareBuffer(); <END> if (bufferToSend.hasRemaining()) { written = channel.write(bufferToSend); } if (!bufferToSend.hasRemaining() && blob != null) { int n = 0, currentWritten = -1; while (bufferIndex < nioBuffersFromBlob.length && currentWritten != 0) { ByteBuffer byteBuffer = nioBuffersFromBlob[bufferIndex]; currentWritten = channel.write(byteBuffer); n += currentWritten; if (!byteBuffer.hasRemaining()) { bufferIndex++; } } blob.skipBytes(n); written += n; okayToWriteCrc = !blob.isReadable(); } if (okayToWriteCrc && crcBuf.hasRemaining()) { if (blob != null) { blob.release(); blob = null; } written += channel.write(crcBuf); } sentBytes += written; } } catch (Exception e) { if (blob != null) { blob.release(); blob = null; } } return written; }</code><technical_language>optional: I suggest renaming this method moving "if" statement out of method. this: if (bufferToSend == null) { // this is time this method called, prepare buffer send header other metadata prepareBufferToSend(); }</technical_language>

Target:
public long writeTo(WritableByteChannel channel) throws IOException { long written = 0; try { if (sentBytes < sizeInBytes()) { if (bufferToSend == null) { prepareBuffer(); } if (bufferToSend.hasRemaining()) { written = channel.write(bufferToSend); } if (!bufferToSend.hasRemaining() && blob != null) { int totalWrittenBytesForBlob = 0, currentWritten = -1; while (bufferIndex < nioBuffersFromBlob.length && currentWritten != 0) { ByteBuffer byteBuffer = nioBuffersFromBlob[bufferIndex]; currentWritten = channel.write(byteBuffer); totalWrittenBytesForBlob += currentWritten; if (!byteBuffer.hasRemaining()) { bufferIndex++; } } blob.skipBytes(totalWrittenBytesForBlob); written += totalWrittenBytesForBlob; okayToWriteCrc = !blob.isReadable(); } if (okayToWriteCrc && crcBuf.hasRemaining()) { if (blob != null) { blob.release(); blob = null; } written += channel.write(crcBuf); } sentBytes += written; } } catch (Exception e) { if (blob != null) { blob.release(); blob = null; } } return written; }
Source:
<code>public void setHeader(final SAMFileHeader header) { this.mHeader = header; if (null == header) { if (null != mReferenceIndex && !mReferenceIndex.equals(NO_ALIGNMENT_REFERENCE_INDEX)) { mReferenceIndex = null; } if (null != mMateReferenceIndex && !mMateReferenceIndex.equals(NO_ALIGNMENT_REFERENCE_INDEX)) { mMateReferenceIndex = null; <START> } <END> } else { setReferenceName(mReferenceName); setMateReferenceName(mMateReferenceName); } }</code><technical_language>Is a reason clearing indices if equal NO_ALIGNMENT_REFERENCE_INDEX? I unconditionally nulling out indices for clarity's sake. If null out equal NO_ALIGNMENT_REFERENCE_INDEX, reference name is equal NO_ALIGNMENT_REFERENCE_NAME, index get reset NO_ALIGNMENT_REFERENCE_INDEX next access in implementation (even in headerless case)</technical_language>

Target:
public void setHeader(final SAMFileHeader header) { this.mHeader = header; if (null == header) { mReferenceIndex = null; mMateReferenceIndex = null; } else { setReferenceName(mReferenceName); setMateReferenceName(mMateReferenceName); } }
Source:
<code>public Sprite slice(int x, int y, int width, int height) { if(withinImage(x, y) && withinImage(x + width - 1, y + height - 1)) { <START> BufferedImage bi = ImageStore.createTranslucentImage(width, height); <END> bi.createGraphics().drawImage(image, 0, 0, width, height, x, y, x + width, y + height, null); return new StaticImageSprite(bi); } return new EmptySprite(); }</code><technical_language>Please, refactor this abreviation. <naming</technical_language>

Target:
public Sprite slice(int x, int y, int width, int height) { if(withinImage(x, y) && withinImage(x + width - 1, y + height - 1)) { BufferedImage newImage = ImageStore.createTranslucentImage(width, height); newImage.createGraphics().drawImage(this.image, 0, 0, width, height, x, y, x + width, y + height, null); return new StaticImageSprite(newImage); } return new EmptySprite(); }
Source:
<code>private PooledWriter(final Writer<A> writer, final BlockingQueue<A> queue, final int writeThreshold) { <START> if (writeThreshold <= 0) throw new IllegalArgumentException("writeThreshold must be >= 1"); if (writeThreshold > queue.remainingCapacity()) throw new IllegalArgumentException("writeThreshold can't be larger then queue capacity."); <END> this.writer = writer; this.queue = queue; this.writeThreshold = writeThreshold; }</code><technical_language>suggestion if (writeThreshold <= 0) throw new IllegalArgumentException("writeThreshold >= 1: " + writeThreshold); if (writeThreshold > queue.remainingCapacity()) throw new IllegalArgumentException("writeThreshold (" + writeThreshold + ") larger queue capacity (" + queue.remainingCapacity() + ").");</technical_language>

Target:
private PooledWriter(final Writer<A> writer, final BlockingQueue<A> queue, final int writeThreshold) { if (writeThreshold <= 0) throw new IllegalArgumentException("writeThreshold must be >= 1: " + writeThreshold); if (writeThreshold > queue.remainingCapacity()) throw new IllegalArgumentException("writeThreshold (" + writeThreshold + ") can't be larger then queue capacity (" + queue.remainingCapacity() + ")."); this.writer = writer; this.queue = queue; this.writeThreshold = writeThreshold; }
Source:
<code>public Set<Pair<WorkerInfo, ArrayList<String>>> selectExecutors(StressBenchConfig config, List<WorkerInfo> jobWorkerInfoList, SelectExecutorsContext context) throws Exception { Set<Pair<WorkerInfo, ArrayList<String>>> result = Sets.newHashSet(); for (WorkerInfo worker : jobWorkerInfoList) { ArrayList<String> args = new ArrayList<>(2); args.add(BaseParameters.ID_FLAG); args.add(worker.getAddress().getHost() + "-" + worker.getId()); result.add(new Pair<>(worker, args)); <START> LOG.info("selectExecutors() args={}", args); <END> } return result; }</code><technical_language>nit: debug? for other new logs in this file</technical_language>

Target:
public Set<Pair<WorkerInfo, ArrayList<String>>> selectExecutors(StressBenchConfig config, List<WorkerInfo> jobWorkerInfoList, SelectExecutorsContext context) throws Exception { Set<Pair<WorkerInfo, ArrayList<String>>> result = Sets.newHashSet(); List<WorkerInfo> workerList = Lists.newArrayList(jobWorkerInfoList); workerList.sort(Comparator.comparingInt(w -> w.getAddress().hashCode())); int clusterLimit = config.getClusterLimit(); if (clusterLimit <= 0) { clusterLimit = workerList.size(); } workerList = workerList.subList(0, clusterLimit); for (WorkerInfo worker : workerList) { ArrayList<String> args = new ArrayList<>(2); args.add(BaseParameters.ID_FLAG); args.add(worker.getAddress().getHost() + "-" + worker.getId()); result.add(new Pair<>(worker, args)); } return result; }
Source:
<code>public Value getValue(Session session) { Value value = expr.getValue(session); if (value == ValueNull.INSTANCE) { return ValueNull.INSTANCE; } int valueType = value.getValueType(); <START> if (valueType >= Value.TINYINT && valueType <= Value.BIGINT) { return value; } String name = value.getString(); ArrayList<Table> tables = session.getDatabase().getAllTablesAndViews(true); ArrayList<Table> tempTables = session.getLocalTempTables(); <END> tables.addAll(tempTables); for (Table table : tables) { if (table.isHidden()) { continue; } if (table.getName().equals(name)) { return ValueInteger.get(table.getId()); } ArrayList<Index> indexes = table.getIndexes(); if (indexes != null) { for (Index index : indexes) { if (index.getCreateSQL() == null) { continue; } if (index.getName().equals(name)) { return ValueInteger.get(index.getId()); } } } } throw DbException.get(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, name); }</code><technical_language>This expression declared type INTEGER return ValueNull.INSTANCE instances of ValueInteger. convertToInt(null), 32-bit unsigned values need special handling avoid NUMERIC_VALUE_OUT_OF_RANGE_2 error</technical_language>

Target:
public Value getValue(Session session) { Value value = expr.getValue(session); if (value == ValueNull.INSTANCE) { return ValueNull.INSTANCE; } int valueType = value.getValueType(); if (valueType >= Value.TINYINT && valueType <= Value.INTEGER) { return value.convertToInt(null); } if (valueType == Value.BIGINT) { return ValueInteger.get((int) value.getLong()); } String name = value.getString(); ArrayList<Table> tables = session.getDatabase().getAllTablesAndViews(true); ArrayList<Table> tempTables = session.getLocalTempTables(); tables.addAll(tempTables); for (Table table : tables) { if (table.isHidden()) { continue; } if (table.getName().equals(name)) { return ValueInteger.get(table.getId()); } ArrayList<Index> indexes = table.getIndexes(); if (indexes != null) { for (Index index : indexes) { if (index.getCreateSQL() == null) { continue; } if (index.getName().equals(name)) { return ValueInteger.get(index.getId()); } } } } throw DbException.get(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, name); }
Source:
<code>public static Properties getIntegrationProperties(BeanFactory beanFactory) { <START> Properties properties = new Properties(IntegrationProperties.defaults()); <END> if (beanFactory != null) { Properties userProperties = getBeanOfType(beanFactory, INTEGRATION_PROPERTIES_BEAN_NAME, Properties.class); if (userProperties != null) { properties.putAll(userProperties); } } return properties; }</code><technical_language>I putAll() defaults - a common java developer error is get() instead of getProperty() a Properties object. getProperty() for defaults if found</technical_language>

Target:
public static Properties getIntegrationProperties(BeanFactory beanFactory) { Properties properties = new Properties(); properties.putAll(IntegrationProperties.defaults()); if (beanFactory != null) { Properties userProperties = getBeanOfType(beanFactory, INTEGRATION_GLOBAL_PROPERTIES_BEAN_NAME, Properties.class); if (userProperties != null) { properties.putAll(userProperties); } } return properties; }
Source:
<code>public int syncFromChangesMerging(Collection<Change> changes, boolean verifyResult) { if (changes.isEmpty()) { return 0; } <START> Set<String> entityIds = newHashSetWithExpectedSize(changes.size()); <END> List<Statement> insertStatements = new ArrayList<>(); ClassifiedStatements classifiedStatements = new ClassifiedStatements(uris); Set<String> valueSet = new HashSet<>(); Set<String> refSet = new HashSet<>(); int modified = 0; for (final Change change : changes) { if (change.getStatements() == null) { continue; } entityIds.add(change.entityId()); insertStatements.addAll(change.getStatements()); classifiedStatements.classify(change.getStatements(), change.entityId()); valueSet.addAll(change.getValueCleanupList()); refSet.addAll(change.getRefCleanupList()); if (insertStatements.size() > maxStatementsPerBatch || classifiedStatements.getDataSize() > maxPostDataSize) { log.info("Too much data with bytes - sending batch out, last ID {}", classifiedStatements.getDataSize(), change.entityId()); modified += sendMergingUpdateBatch(uris.entity(), uris.statement(), entityIds, insertStatements, classifiedStatements, refSet, valueSet, verifyResult); entityIds.clear(); insertStatements.clear(); classifiedStatements.clear(); valueSet.clear(); refSet.clear(); } } if (!entityIds.isEmpty()) { modified += sendMergingUpdateBatch(uris.entity(), uris.statement(), entityIds, insertStatements, classifiedStatements, refSet, valueSet, verifyResult); } return modified; }</code><technical_language>This code suspiciously similar in syncFromChanges(). need eliminate code duplication</technical_language>

Target:
public int syncFromChangesMerging(Collection<Change> changes, boolean verifyResult) { if (changes.isEmpty()) { return 0; } Set<String> entityIds = newHashSetWithExpectedSize(changes.size()); List<Statement> insertStatements = new ArrayList<>(); ClassifiedStatements classifiedStatements = new ClassifiedStatements(uris); Set<String> valueSet = new HashSet<>(); Set<String> refSet = new HashSet<>(); int modified = 0; for (final Change change : changes) { if (change.getStatements() == null) { continue; } entityIds.add(change.entityId()); insertStatements.addAll(change.getStatements()); classifiedStatements.classify(change.getStatements(), change.entityId()); valueSet.addAll(change.getValueCleanupList()); refSet.addAll(change.getRefCleanupList()); if (insertStatements.size() > maxStatementsPerBatch || classifiedStatements.getDataSize() > maxPostDataSize) { log.info("Too much data with bytes - sending batch out, last ID {}", classifiedStatements.getDataSize(), change.entityId()); modified += sendMergingUpdateBatch(uris.entity(), uris.statement(), entityIds, insertStatements, refSet, valueSet, verifyResult); entityIds.clear(); insertStatements.clear(); classifiedStatements.clear(); valueSet.clear(); refSet.clear(); } } if (!entityIds.isEmpty()) { modified += sendMergingUpdateBatch(uris.entity(), uris.statement(), entityIds, insertStatements, refSet, valueSet, verifyResult); } return modified; }
Source:
<code>public static void output(@AggregationState TDigestAndPercentileState state, BlockBuilder out) { TDigest digest = state.getDigest(); List<Double> percentiles = state.getPercentiles(); if (percentiles == null || digest == null) { out.appendNull(); return; } <START> checkState(percentiles.get(0) != -1.0, "Percentile is missing"); <END> checkCondition(0 <= percentiles.get(0), INVALID_FUNCTION_ARGUMENT, "Percentile must be non-negative"); DOUBLE.writeDouble(out, digest.getQuantile(percentiles.get(0))); out.closeEntry(); }</code><technical_language>this happen</technical_language>

Target:
public static void output(@AggregationState TDigestAndPercentileState state, BlockBuilder out) { TDigest digest = state.getDigest(); List<Double> percentiles = state.getPercentiles(); if (percentiles == null || digest == null) { out.appendNull(); return; } checkCondition(0 <= percentiles.get(0) && percentiles.get(0) <= 1, INVALID_FUNCTION_ARGUMENT, "Percentile must be between 0 and 1"); DOUBLE.writeDouble(out, digest.getQuantile(percentiles.get(0))); out.closeEntry(); }
Source:
<code>public Range<String> toRange() { if (this.range == null) { synchronized (this) { <START> if (range != null) { <END> this.range = new Range<String>(this.getMinInclusive(), this.getMaxExclusive(), true, false); } } } return this.range; }</code><technical_language>Should'n range == null</technical_language>

Target:
public Range<String> toRange() { if (this.range == null) { synchronized (this) { if (range == null) { this.range = new Range<String>(this.getMinInclusive(), this.getMaxExclusive(), true, false); } } } return this.range; }
Source:
<code><START> protected final List<?> createValues() <END> { switch (withNulls) { case ALL: return NULL_VALUES; case PARTIAL: return IntStream.range(0, ROWS).mapToObj(i -> i % 2 == 0 ? createValue() : null).collect(toList()); default: return IntStream.range(0, ROWS).mapToObj(i -> createValue()).collect(toList()); } }</code><technical_language>nit: final method. (Also, a side note: final for tmp variables)</technical_language>

Target:
protected List<?> createValues() { switch (withNulls) { case ALL: return NULL_VALUES; case PARTIAL: return IntStream.range(0, ROWS).mapToObj(i -> i % 2 == 0 ? createValue() : null).collect(toList()); default: return IntStream.range(0, ROWS).mapToObj(i -> createValue()).collect(toList()); } }
Source:
<code>public RemoteFramework fork(List<String> vmArgs, Map<String, String> systemProperties, Map<String, Object> frameworkProperties, List<String> beforeFrameworkClasspath, List<String> afterFrameworkClasspath) { <START> port = Integer.parseInt(System.getProperty(EXAM_FORKED_INVOKER_PORT, String.valueOf(getFreePort().getPort()))); <END> LOG.debug("using RMI registry at port {}", port); String rmiName = "ExamRemoteFramework-" + UUID.randomUUID().toString(); try { String address = InetAddress.getLoopbackAddress().getHostAddress(); System.setProperty("java.rmi.server.hostname", address); registry = LocateRegistry.createRegistry(port); Map<String, String> systemPropsNew = new HashMap<>(systemProperties); systemPropsNew.put("java.rmi.server.hostname", address); systemPropsNew.put(RemoteFramework.RMI_PORT_KEY, Integer.toString(port)); systemPropsNew.put(RemoteFramework.RMI_NAME_KEY, rmiName); String[] vmOptions = buildSystemProperties(vmArgs, systemPropsNew); String[] args = buildFrameworkProperties(frameworkProperties); javaRunner = new DefaultJavaRunner(false); javaRunner.exec(vmOptions, buildClasspath(beforeFrameworkClasspath, afterFrameworkClasspath), RemoteFrameworkImpl.class.getName(), args, getJavaHome(), null); return findRemoteFramework(address, port, rmiName); } catch (RemoteException | ExecutionException | URISyntaxException exc) { throw new TestContainerException(exc); } }</code><technical_language>I check if system property is set this. Otherwise, ports scanned result is thrown away</technical_language>

Target:
public RemoteFramework fork(List<String> vmArgs, Map<String, String> systemProperties, Map<String, Object> frameworkProperties, List<String> beforeFrameworkClasspath, List<String> afterFrameworkClasspath) { port = getPort(); LOG.debug("using RMI registry at port {}", port); String rmiName = "ExamRemoteFramework-" + UUID.randomUUID().toString(); try { String address = InetAddress.getLoopbackAddress().getHostAddress(); System.setProperty("java.rmi.server.hostname", address); registry = LocateRegistry.createRegistry(port); Map<String, String> systemPropsNew = new HashMap<>(systemProperties); systemPropsNew.put("java.rmi.server.hostname", address); systemPropsNew.put(RemoteFramework.RMI_PORT_KEY, Integer.toString(port)); systemPropsNew.put(RemoteFramework.RMI_NAME_KEY, rmiName); String[] vmOptions = buildSystemProperties(vmArgs, systemPropsNew); String[] args = buildFrameworkProperties(frameworkProperties); javaRunner = new DefaultJavaRunner(false); javaRunner.exec(vmOptions, buildClasspath(beforeFrameworkClasspath, afterFrameworkClasspath), RemoteFrameworkImpl.class.getName(), args, getJavaHome(), null); return findRemoteFramework(address, port, rmiName); } catch (RemoteException | ExecutionException | URISyntaxException exc) { throw new TestContainerException(exc); } }