auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void configure(Requirement<?> requirement) { if (!(requirement instanceof PropertyConfiguration)){ throw new IllegalArgumentException("The requirement does not implement " + PropertyConfiguration.class); } boolean configurationSet = false; for (Object configuration : this.configurations) { <START> try { <END> log.debug("Setting property based configuration to requirement " + requirement.getClass()); PropertyBasedConfiguration config = (PropertyBasedConfiguration) configuration; setter.set(requirement, config); log.debug("Configuration successfully set"); configurationSet = true; break; } catch (RedDeerConfigurationException e) { log.error("This property based configuration (" + configuration + ") cannot be set to " + requirement.toString()); } catch (ClassCastException e) { log.error("This configuration (" + configuration + ") cannot be set to " + requirement.toString() + " " + e); } } if (!configurationSet) { throw new RedDeerConfigurationException("None of the given configurations " + "could have ben set as configuration of the requirement " + requirement.getClass().getName()); } }</code><technical_language>change try-catch isAssignableFrom</technical_language>

Target:
public void configure(Requirement<?> requirement) { if (!(requirement instanceof PropertyConfiguration)){ throw new IllegalArgumentException("The requirement does not implement " + PropertyConfiguration.class); } boolean configurationSet = false; for (Object configuration : this.configurations) { if (PropertyBasedConfiguration.class.isAssignableFrom(configuration.getClass())) { try { log.debug("Setting property based configuration to requirement " + requirement.getClass()); PropertyBasedConfiguration config = (PropertyBasedConfiguration) configuration; if (requirement.getClass().getCanonicalName().equalsIgnoreCase(config.getRequirementClassName())) { setter.set(requirement, config); log.debug("Configuration successfully set"); configurationSet = true; break; } } catch (RedDeerConfigurationException e) { log.error("This property based configuration (" + configuration + ") cannot be set to " + requirement.toString()); } } } if (!configurationSet) { throw new RedDeerConfigurationException("None of the given configurations " + "could have ben set as configuration of the requirement " + requirement.getClass().getName()); } }
Source:
<code>private ListenableOrderedSet<String> initSelectedItems() { return new ListenableOrderedSet<String>() { private static final long serialVersionUID = 1L; @Override public void onAdd(String item) { populateSelectedItemsString(); checkBoxes.get(item).setValue(true); } @Override public void onRemove(String item) { populateSelectedItemsString(); checkBoxes.get(item).setValue(false); } @Override public void onRemoveAll(Collection<String> items) { populateSelectedItemsString(); for (String item : items) { checkBoxes.get(item).setValue(false); } } @Override public void onRemoveAll() { <START> Iterator<Entry<String, CheckBox>> iterator = checkBoxes.entrySet().iterator(); <END> while (iterator.hasNext()) { Entry<String, CheckBox> mapEntry = iterator.next(); mapEntry.getValue().setValue(false); } } @Override public void onAddAll(Collection<String> items) { populateSelectedItemsString(); for (String item : items) { checkBoxes.get(item).setValue(true); } } }; }</code><technical_language>leave out populateSelectedItemsString() here</technical_language>

Target:
private ObservableOrderedSet<String> initSelectedItems() { return new ObservableOrderedSet<String>() { private static final long serialVersionUID = 1L; @Override public void onAdd(String item) { updateValue(); checkBoxes.get(item).setValue(true); } @Override public void onRemove(String item) { updateValue(); checkBoxes.get(item).setValue(false); } @Override public void onRemoveAll(Collection<String> items) { updateValue(); for (String item : items) { checkBoxes.get(item).setValue(false); } } @Override public void onRemoveAll() { updateValue(); Iterator<Entry<String, CheckBox>> iterator = checkBoxes.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, CheckBox> mapEntry = iterator.next(); mapEntry.getValue().setValue(false); } } @Override public void onAddAll(Collection<String> items) { updateValue(); for (String item : items) { checkBoxes.get(item).setValue(true); } } }; }
Source:
<code>public void init() { setRetryPublisher(tracePublisher); setTypeReference(new TypeReference<java.util.List<Trace>>() { }); setProcessor(new AbstractProcessor<Trace, Void>(ProcessorType.ManyToMany) { @Override public List<Void> processManyToMany(String tenantId, List<Trace> items) throws Exception { long startTime = 0; if (perfLog.isLoggable(Level.FINEST)) { startTime = System.currentTimeMillis(); perfLog.finest("Performance: about to store trace (first id=" + items.get(0).getId() + ")"); } <START> traceService.storeTraces(tenantId, items); <END> if (perfLog.isLoggable(Level.FINEST)) { perfLog.finest("Performance: store trace (first id=" + items.get(0).getId() + ") duration=" + (System.currentTimeMillis() - startTime) + "ms"); } return null; } }); }</code><technical_language>If exception here, next log duration. wrap this a try-finally? Also, I this suited for interceptor @AroundInvoke. This way, reuse logic other critical places</technical_language>

Target:
public void init() { setRetryPublisher(tracePublisher); setTypeReference(new TypeReference<java.util.List<Trace>>() { }); setProcessor(new AbstractProcessor<Trace, Void>(ProcessorType.ManyToMany) { @Override public List<Void> processManyToMany(String tenantId, List<Trace> items) throws Exception { traceService.storeTraces(tenantId, items); return null; } }); }
Source:
<code>public void testRemoteSLDMultipleStyles() throws Exception { final URL remoteSldUrl = getClass().getResource("MultipleStyles.sld"); this.allParameters.put("SLD", remoteSldUrl.toExternalForm()); this.allParameters.put("LAYER", "cite:Ponds"); this.allParameters.put("STYLE", "Ponds"); GetLegendGraphicRequest request = <START> requestReader.read(new GetLegendGraphicRequest(null), allParameters, allParameters); <END> Style selectedStyle = request.getStyles().get(0); assertNotNull(selectedStyle); assertEquals("Ponds", selectedStyle.getName()); this.allParameters.put("LAYER", "cite:Lakes"); this.allParameters.put("STYLE", "Lakes"); request = requestReader.read(new GetLegendGraphicRequest(null), allParameters, allParameters); selectedStyle = request.getStyles().get(0); assertNotNull(selectedStyle); assertEquals("Lakes", selectedStyle.getName()); }</code><technical_language>this null params greatest sight... a param constructor instead? pass wms in here</technical_language>

Target:
public void testRemoteSLDMultipleStyles() throws Exception { final URL remoteSldUrl = getClass().getResource("MultipleStyles.sld"); this.allParameters.put("SLD", remoteSldUrl.toExternalForm()); this.allParameters.put("LAYER", "cite:Ponds"); this.allParameters.put("STYLE", "Ponds"); GetLegendGraphicRequest request = requestReader.read(new GetLegendGraphicRequest(), allParameters, allParameters); Style selectedStyle = request.getStyles().get(0); assertNotNull(selectedStyle); assertEquals("Ponds", selectedStyle.getName()); this.allParameters.put("LAYER", "cite:Lakes"); this.allParameters.put("STYLE", "Lakes"); request = requestReader.read(new GetLegendGraphicRequest(), allParameters, allParameters); selectedStyle = request.getStyles().get(0); assertNotNull(selectedStyle); assertEquals("Lakes", selectedStyle.getName()); }
Source:
<code>public boolean onKeyDown(int keycode, KeyEvent event) { if (keycode == KeyEvent.KEYCODE_BACK) { if (currentScreen != HomeScreenState.GALLERY) { newGallery frag = new newGallery(); getSupportFragmentManager().beginTransaction() .replace(R.id.fragment_container, frag) .commit(); currentScreen = HomeScreenState.GALLERY; <START> keycode = 0; <END> } else { AlertDialog.Builder alertbox = new AlertDialog.Builder(ctx); alertbox.setMessage(getString(R.string.exit_message)); alertbox.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); System.exit(0); } }); alertbox.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); alertbox.create().show(); } } return super.onKeyDown(keycode, event); }</code><technical_language>stated in issue need this</technical_language>

Target:
public boolean onKeyDown(int keycode, KeyEvent event) { if (keycode == KeyEvent.KEYCODE_BACK) { if (currentScreen != HomeScreenState.GALLERY) { newGallery frag = new newGallery(); getSupportFragmentManager().beginTransaction() .replace(R.id.fragment_container, frag) .commit(); currentScreen = HomeScreenState.GALLERY; } else { AlertDialog.Builder alertbox = new AlertDialog.Builder(ctx); alertbox.setMessage(getString(R.string.exit_message)); alertbox.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); System.exit(0); } }); alertbox.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); alertbox.create().show(); } } return super.onKeyDown(keycode, event); }
Source:
<code>public void findLocationByName_ShouldFindCorrectLocationByName() { mDatabase.locationRoomDAO().findLocationByName("name"); <START> mDatabase.locationRoomDAO().findLocationByName("display") <END> .test() .assertValue(actualLocationEntity -> Objects.equals(actualLocationEntity.getName(), "name") && Objects.equals(actualLocationEntity.getDescription(), "description") && Objects.equals(actualLocationEntity.getDisplay(), "display")); }</code><technical_language>is this line added</technical_language>

Target:
public void findLocationByName_ShouldFindCorrectLocationByName() { mDatabase.locationRoomDAO().addLocation(expectedLocationEntity1); mDatabase.locationRoomDAO().findLocationByName("display") .test() .assertValue(actualLocationEntity -> Objects.equals(actualLocationEntity.getName(), "name") && Objects.equals(actualLocationEntity.getDescription(), "description") && Objects.equals(actualLocationEntity.getDisplay(), "display")); }
Source:
<code>public static Map<String, Object> virtualTableQueryToMap(VirtualTableQueryFilter queryFilter) { Map<String, Object> map = new HashMap<>(); <START> List<Long> columnsId = queryFilter.getColumnsId(); <END> long index = queryFilter.getIndex(); int count = queryFilter.getCount(); map.put("columnId", columnsId); map.put("index", index); map.put("count", count); return map; }</code><technical_language>null safety warning. add NonNullByDefault VirtualTableQueryFilter EventTableQueryFilter fix</technical_language>

Target:
public static Map<String, Object> virtualTableQueryToMap(VirtualTableQueryFilter queryFilter) { Map<String, Object> map = new HashMap<>(); List<Long> columnsId = queryFilter.getColumnsId(); long index = queryFilter.getIndex(); int count = queryFilter.getCount(); map.put(COLUMN_ID_KEY, columnsId); map.put(TABLE_INDEX, index); map.put(TABLE_COUNT, count); return map; }
Source:
<code>private String asYaml(Tool tool, KubernetesList list) throws DevfileRecipeFormatException { try { return Serialization.asYaml(list); } catch (KubernetesClientException e) { throw new DevfileRecipeFormatException( format( <START> "Unable to deserialize specified local file content for tool '%s'", tool.getName())); <END> } }</code><technical_language>Please consider adding original error message thrown exception</technical_language>

Target:
private String asYaml(Tool tool, KubernetesList list) throws DevfileRecipeFormatException { try { return Serialization.asYaml(list); } catch (KubernetesClientException e) { throw new DevfileRecipeFormatException( format( "Unable to deserialize specified local file content for tool '%s'. Error: %s", tool.getName(), e.getMessage())); } }
Source:
<code><START> public QuotaDependency getQuotaDependency() { <END> return this.quotaDependency; }</code><technical_language>remove this</technical_language>

Target:
public QuotaDependency getQuotaDependency() { return quotaDependency; }
Source:
<code>public InstanceOfExpr(final Expression expression, final ReferenceType type) { <START> this(null, expression, type); <END> }</code><technical_language>In other nodes, constructors call specific constructor avoid constructor spaghetti. this-call "null" end for example</technical_language>

Target:
public InstanceOfExpr(final Expression expression, final ReferenceType type) { this(null, expression, type, null); }
Source:
<code>public int getLightPercentile(final int lightValue) { <START> if (lightValue > MAX_LIGHT) <END> return MAX_LIGHT_PERCENTILE; return this.distributionLookup.get(lightValue); }</code><technical_language>braces please! {^_^}</technical_language>

Target:
public int getLightPercentile(final int lightValue) { if (lightValue > MAX_LIGHT) { return MAX_LIGHT_PERCENTILE; } return this.distributionLookup.get(lightValue); }
Source:
<code>public static WebArchive createWebArchiveNoGw() { Map<String,String> replacements = new HashMap(); replacements.put("2727", String.valueOf(mediaPort)); replacements.put("8080", String.valueOf(restcommHTTPPort)); replacements.put("8090", String.valueOf(mockPort)); replacements.put("5080", String.valueOf(restcommPort)); replacements.put("5070", String.valueOf(georgePort)); <START> replacements.put("5090", String.valueOf(bobPort)); <END> replacements.put("5091", String.valueOf(alicePort)); replacements.put("5092", String.valueOf(mariaPort)); replacements.put("5093", String.valueOf(dimitriPort)); replacements.put("5094", String.valueOf(alicePort2)); replacements.put("5095", String.valueOf(clientWithAppPort)); replacements.put("5096", String.valueOf(fotiniPort)); replacements.put("5097", String.valueOf(bobPort)); replacements.put("5098", String.valueOf(leftyPort)); List<String> resources = new ArrayList( Arrays.asList( "dial-conference-entry.xml", "dial-fork-entry.xml", "dial-uri-entry.xml", "dial-client-entry.xml", "dial-number-entry.xml")); return WebArchiveUtil.createWebArchiveNoGw( "restcomm-delay.xml", "restcomm.script_dialTest", resources, replacements); }</code><technical_language>i dont get replacing client ports, dont exist in restcomm.xml, i missing</technical_language>

Target:
public static WebArchive createWebArchiveNoGw() { reconfigurePorts(); Map<String,String> replacements = new HashMap(); replacements.put("2727", String.valueOf(mediaPort)); replacements.put("8080", String.valueOf(restcommHTTPPort)); replacements.put("8090", String.valueOf(mockPort)); replacements.put("5080", String.valueOf(restcommPort)); replacements.put("5070", String.valueOf(georgePort)); replacements.put("5090", String.valueOf(bobPort)); replacements.put("5091", String.valueOf(alicePort)); replacements.put("5092", String.valueOf(mariaPort)); replacements.put("5093", String.valueOf(dimitriPort)); replacements.put("5094", String.valueOf(alicePort2)); replacements.put("5095", String.valueOf(clientWithAppPort)); replacements.put("5096", String.valueOf(fotiniPort)); replacements.put("5097", String.valueOf(bobPort)); replacements.put("5098", String.valueOf(leftyPort)); List<String> resources = new ArrayList( Arrays.asList( "dial-conference-entry.xml", "dial-fork-entry.xml", "dial-uri-entry.xml", "dial-client-entry.xml", "dial-number-entry.xml")); return WebArchiveUtil.createWebArchiveNoGw( "restcomm-delay.xml", "restcomm.script_dialTest", resources, replacements); }
Source:
<code>public VersionRangeType get(String feature) { <START> return all().get(feature); <END> }</code><technical_language>nit: a personal preference, internal reference a public function code usage check easier, features.get(feature)</technical_language>

Target:
public VersionRangeType get(String feature) { return features.get(feature); }
Source:
<code>public Void call(ApiCaller ac, Deserializer parms) throws PerunException { <START> ac.getGroupsManager().forceGroupStructureSynchronization(ac.getSession(), <END> ac.getGroupById(parms.readInt("group"))); return null; }</code><technical_language>ac.stateChangingCheck(); @zlamalp</technical_language>

Target:
public Group call(ApiCaller ac, Deserializer parms) throws PerunException { ac.stateChangingCheck(); if (parms.contains("group")) { if (parms.contains("parentGroup")) { return ac.getGroupsManager().createGroup(ac.getSession(), ac.getGroupById(parms.readInt("parentGroup")), parms.read("group", Group.class)); } else if (parms.contains("vo")) { Group group = parms.read("group", Group.class); if (group.getParentGroupId() == null) { return ac.getGroupsManager().createGroup(ac.getSession(), ac.getVoById(parms.readInt("vo")), group); } else { throw new RpcException(RpcException.Type.WRONG_PARAMETER, "Top-level groups can't have parentGroupId set!"); } } else { throw new RpcException(RpcException.Type.MISSING_VALUE, "vo or parentGroup"); } } else if (parms.contains("name") && parms.contains("description")) { if (parms.contains("parentGroup")) { String name = parms.readString("name"); String description = parms.readString("description"); Group group = new Group(name, description); return ac.getGroupsManager().createGroup(ac.getSession(), ac.getGroupById(parms.readInt("parentGroup")), group); } else if (parms.contains("vo")) { String name = parms.readString("name"); String description = parms.readString("description"); Group group = new Group(name, description); return ac.getGroupsManager().createGroup(ac.getSession(), ac.getVoById(parms.readInt("vo")), group); } else { throw new RpcException(RpcException.Type.MISSING_VALUE, "vo or parentGroup"); } } else { throw new RpcException(RpcException.Type.MISSING_VALUE, "group or (name and description)"); } }
Source:
<code>public String getColumnText(Object element, XViewerColumn column, int columnIndex) { try { if (element instanceof Artifact) { Artifact refArt = ((Artifact) element).getSoleAttributeValue(AtsAttributeTypes.TaskToChangedArtifactReference, null); if (refArt != null) { Branch refBranch = refArt.getFullBranch(); if (refBranch.getBranchState().equals( BranchState.COMMITTED) || refBranch.getBranchType().isBaselineBranch()) { <START> return "Commited"; <END> } else if (refArt.isDeleted()) { return "Deleted"; } else if (refArt.getLastModified().after(((Artifact) element).getLastModified())) { return refArt.getLastModified().toString(); } else { return "Unmodified"; } } } } catch (OseeCoreException ex) { return LogUtil.getCellExceptionString(ex); } return ""; }</code><technical_language>move Deleted check. A deleted artifact couldhave a branch Deleted flag is more important Committed</technical_language>

Target:
public String getColumnText(Object element, XViewerColumn column, int columnIndex) { try { if (element instanceof Artifact) { Artifact refArt = ((Artifact) element).getSoleAttributeValue(AtsAttributeTypes.TaskToChangedArtifactReference, null); if (refArt != null) { Branch refBranch = refArt.getFullBranch(); if (refArt.isDeleted()) { return "Deleted"; } else if (refBranch.getBranchState().equals( BranchState.COMMITTED) || refBranch.getBranchType().isBaselineBranch()) { return "Commited"; } else if (refArt.getLastModified().after(((Artifact) element).getLastModified())) { return refArt.getLastModified().toString(); } else { return "Unmodified"; } } } } catch (OseeCoreException ex) { return LogUtil.getCellExceptionString(ex); } return ""; }
Source:
<code>public void writeBytes(Binary v) { int i = 0; byte[] vb = v.getBytesUnsafe(); int length = previous.length < vb.length ? previous.length : vb.length; for(i = 0; (i < length) && (previous[i] == vb[i]); i++); prefixLengthWriter.writeInteger(i); <START> suffixWriter.writeBytes(Binary.fromUnmodifiedByteArray(vb, i, vb.length - i)); <END> previous = vb; }</code><technical_language>This odd. contract for unsafe access bytes backing another Binary is immediately forget matter if change. in this case create a constant Binary signals bytes change. this is change passing won't. need is ability get a slice of original v inherits is reused constant: java Binary slice(int start, int length);</technical_language>

Target:
public void writeBytes(Binary v) { int i = 0; byte[] vb = v.getBytes(); int length = previous.length < vb.length ? previous.length : vb.length; for(i = 0; (i < length) && (previous[i] == vb[i]); i++); prefixLengthWriter.writeInteger(i); suffixWriter.writeBytes(v.slice(i, vb.length - i)); previous = vb; }
Source:
<code><START> public void testIsAdHocAutostart_false() throws Exception { <END> String id = UUID.randomUUID().toString(); AdHocSubProcess adHocSubProcess = bpmn2.createAdHocSubProcess(); adHocSubProcess.setId(id); CustomElement.autoStart.of(adHocSubProcess).set(Boolean.FALSE); tested = new AdHocSubProcessPropertyReader(adHocSubProcess, definitionResolverReal.getDiagram(), definitionResolverReal); assertFalse(tested.isAdHocAutostart()); }</code><technical_language>Exception is thrown</technical_language>

Target:
public void testIsAdHocAutostart_false() { String id = UUID.randomUUID().toString(); AdHocSubProcess adHocSubProcess = bpmn2.createAdHocSubProcess(); adHocSubProcess.setId(id); CustomElement.autoStart.of(adHocSubProcess).set(Boolean.FALSE); tested = new AdHocSubProcessPropertyReader(adHocSubProcess, definitionResolverReal.getDiagram(), definitionResolverReal); assertFalse(tested.isAdHocAutostart()); }
Source:
<code>protected void executeCommand() { VDSGroup vdsGroup = getVdsGroup(); boolean initSucceeded = true; getVds().setPowerManagementControlledByPolicy(true); <START> DbFacade.getInstance().getVdsDynamicDao().update(getVds().getDynamicData()); <END> if (vdsGroup.supportsTrustedService()) { initSucceeded = initTrustedService(); } if (initSucceeded && vdsGroup.supportsVirtService()) { initSucceeded = initVirtResources(); } if (initSucceeded && vdsGroup.supportsGlusterService()) { initSucceeded = initGlusterHost(); } setSucceeded(initSucceeded); }</code><technical_language>1) updating VdsDynamic risky - contains host status lead races. prefer updating specific field. 2) need update if feature is disabled</technical_language>

Target:
protected void executeCommand() { VDSGroup vdsGroup = getVdsGroup(); boolean initSucceeded = true; getVds().setPowerManagementControlledByPolicy(true); DbFacade.getInstance().getVdsDynamicDao().updateVdsDynamicPowerManagementPolicyFlag( getVds().getId(), getVds().isPowerManagementControlledByPolicy()); if (vdsGroup.supportsTrustedService()) { initSucceeded = initTrustedService(); } if (initSucceeded && vdsGroup.supportsVirtService()) { initSucceeded = initVirtResources(); } if (initSucceeded && vdsGroup.supportsGlusterService()) { initSucceeded = initGlusterHost(); } setSucceeded(initSucceeded); }
Source:
<code>public void buildDependencyGraph(AbstractProject owner, DependencyGraph graph) { if (!canDeclare(owner)) return; for (BuildTriggerConfig config : configs) { List<AbstractProject> projectList = config.getProjectList(owner.getParent(), null); for (AbstractProject project : projectList) { if (config.triggerFromChildProjects() && owner instanceof ItemGroup) { ItemGroup parent = (ItemGroup) owner; <START> for (AbstractProject child : (Collection<AbstractProject>)parent.getItems()) { <END> ParameterizedDependency.add(child, project, config, graph); } } else{ ParameterizedDependency.add(owner, project, config, graph); } } } }</code><technical_language>This cast is strictly speaking unsafe is guarantee contains AbstractProjects</technical_language>

Target:
public void buildDependencyGraph(AbstractProject owner, DependencyGraph graph) { if (!canDeclare(owner)) return; for (BuildTriggerConfig config : configs) { List<AbstractProject> projectList = config.getProjectList(owner.getParent(), null); for (AbstractProject project : projectList) { if (config.isTriggerFromChildProjects() && owner instanceof ItemGroup) { ItemGroup<Item> parent = (ItemGroup) owner; for (Item item : parent.getItems()) { if(item instanceof AbstractProject){ AbstractProject child = (AbstractProject) item; ParameterizedDependency.add(child, project, config, graph); } } } else{ ParameterizedDependency.add(owner, project, config, graph); } } } }
Source:
<code>public static String validateFileName(String fileName) throws IllegalArgumentException{ <START> if (!isSet(fileName) || REGEX_FILENAME_INVALID_CHARS.matcher(fileName).matches()) { <END> throw new IllegalArgumentException("Invalid Filename passed in: " + fileName); } else { return fileName; } }</code><technical_language>I change (very smart) I this change is a good candidate create unit test test previous code working new code</technical_language>

Target:
public static String validateFileName(String fileName) throws IllegalArgumentException{ if (!isSet(fileName) || REGEX_FILENAME_INVALID_CHARS.matcher(fileName).find()) { throw new IllegalArgumentException("Invalid Filename passed in: " + fileName); } else { return fileName; } }
Source:
<code>protected CompletionStage<Collection<M>> handleMessageAsync(M message, MessageCollector collector, TaskCoordinator coordinator) { Object key, value; if (outputStream.isKeyed()) { key = ((KV) message).getKey(); value = ((KV) message).getValue(); } else { key = null; value = message; } collector.send(new OutgoingMessageEnvelope(systemStream, null, key, value)); <START> return CompletableFuture.completedFuture(new ArrayList<M>(Arrays.asList(message))); <END> }</code><technical_language>do need new Array here? ImmutableList</technical_language>

Target:
protected CompletionStage<Collection<M>> handleMessageAsync(M message, MessageCollector collector, TaskCoordinator coordinator) { Object key, value; if (outputStream.isKeyed()) { key = ((KV) message).getKey(); value = ((KV) message).getValue(); } else { key = null; value = message; } collector.send(new OutgoingMessageEnvelope(systemStream, null, key, value)); return CompletableFuture.completedFuture(Collections.singleton(message)); }
Source:
<code>public Table getTable(TableName tableName) throws HiveException { <START> return tableName.getDb() == null ? this.getTable(tableName.getTable(), true) : this <END> .getTable(tableName.getDb(), tableName.getTable(), true); }</code><technical_language>a table db is invalid? is needed temporarilt - this is done</technical_language>

Target:
public Table getTable(TableName tableName) throws HiveException { return this.getTable(ObjectUtils.firstNonNull(tableName.getDb(), SessionState.get().getCurrentDatabase()), tableName.getTable(), true); }
Source:
<code>public void setValues() { overwriteAllowProperty.setValue(!initialBibtexKeyPatternPreferences.avoidOverwritingCiteKey()); <START> overwriteWarningProperty.setValue(initialBibtexKeyPatternPreferences.isWarningBeforeOverwrite()); <END> generateOnSaveProperty.setValue(initialBibtexKeyPatternPreferences.isGenerateKeysBeforeSaving()); if (initialBibtexKeyPatternPreferences.getKeyLetters() == BibtexKeyPatternPreferences.KeyLetters.ALWAYS) { letterAlwaysAddProperty.setValue(true); letterStartAProperty.setValue(false); letterStartBProperty.setValue(false); } else if (initialBibtexKeyPatternPreferences.getKeyLetters() == BibtexKeyPatternPreferences.KeyLetters.SECOND_WITH_A) { letterAlwaysAddProperty.setValue(false); letterStartAProperty.setValue(true); letterStartBProperty.setValue(false); } else { letterAlwaysAddProperty.setValue(false); letterStartAProperty.setValue(false); letterStartBProperty.setValue(true); } keyPatternRegexProperty.setValue(initialBibtexKeyPatternPreferences.getKeyPatternRegex()); keyPatternReplacementProperty.setValue(initialBibtexKeyPatternPreferences.getKeyPatternReplacement()); unwantedCharactersProperty.setValue(initialBibtexKeyPatternPreferences.getUnwantedCharacters()); }</code><technical_language>I prefix is here: shouldAvoidOverwriting, shouldWarnBeforeOverwrite shouldGenerateKeysBeforeSaving. <LINK_0></technical_language>

Target:
public void setValues() { overwriteAllowProperty.setValue(!initialBibtexKeyPatternPreferences.shouldAvoidOverwriteCiteKey()); overwriteWarningProperty.setValue(initialBibtexKeyPatternPreferences.shouldWarnBeforeOverwriteCiteKey()); generateOnSaveProperty.setValue(initialBibtexKeyPatternPreferences.shouldGenerateCiteKeysBeforeSaving()); if (initialBibtexKeyPatternPreferences.getKeySuffix() == BibtexKeyPatternPreferences.KeySuffix.ALWAYS) { letterAlwaysAddProperty.setValue(true); letterStartAProperty.setValue(false); letterStartBProperty.setValue(false); } else if (initialBibtexKeyPatternPreferences.getKeySuffix() == BibtexKeyPatternPreferences.KeySuffix.SECOND_WITH_A) { letterAlwaysAddProperty.setValue(false); letterStartAProperty.setValue(true); letterStartBProperty.setValue(false); } else { letterAlwaysAddProperty.setValue(false); letterStartAProperty.setValue(false); letterStartBProperty.setValue(true); } keyPatternRegexProperty.setValue(initialBibtexKeyPatternPreferences.getKeyPatternRegex()); keyPatternReplacementProperty.setValue(initialBibtexKeyPatternPreferences.getKeyPatternReplacement()); unwantedCharactersProperty.setValue(initialBibtexKeyPatternPreferences.getUnwantedCharacters()); }
Source:
<code><START> public static Optional<Duration> parseDuration(String stringAsDuration) throws Exception { <END> if (stringAsDuration != null && stringAsDuration.length() > 0) { final String[] parts = stringAsDuration.split(":"); if (parts.length > 3) { throw new Exception("Wrong format: " + stringAsDuration); } int seconds = 0; if (parts.length == 3) { seconds += 60 * 60 * Integer.parseInt(parts[0]); seconds += 60 * Integer.parseInt(parts[1]); seconds += Integer.parseInt(parts[2]); } if (parts.length == 2) { seconds += 60 * Integer.parseInt(parts[0]); seconds += Integer.parseInt(parts[1]); } if (parts.length == 1) { seconds += Integer.parseInt(parts[0]); } return Optional.of(Duration.ofSeconds(seconds)); } else { return Optional.empty(); } }</code><technical_language>![MAJOR](<LINK_0> 'Severity: MAJOR') Define throw a dedicated exception instead of a generic one. [![rule](<LINK_1>](<LINK_2></technical_language>

Target:
public static Optional<Duration> parseDuration(String stringAsDuration) throws Exception { if (stringAsDuration != null && stringAsDuration.length() > 0) { final Date date = applyFormats(stringAsDuration, new SimpleDateFormat("HH:mm:ss"), new SimpleDateFormat("mm:ss"), new SimpleDateFormat("ss")); return Optional.of(Duration.ofMillis(date.getTime())); } else { return Optional.empty(); } }
Source:
<code><START> public void shouldDropUnselectedLabelIndexes() throws Exception <END> { GraphDatabaseService db = db( LabelIndex.NATIVE ); Node nodeA = createNode( db ); assertNodes( db, nodeA ); db.shutdown(); db = db( LabelIndex.LUCENE ); Node nodeB = createNode( db ); assertNodes( db, nodeA, nodeB ); db.shutdown(); db = db( LabelIndex.NATIVE ); Node nodeC = createNode( db ); assertNodes( db, nodeA, nodeB, nodeC ); db.shutdown(); }</code><technical_language>a test for LUCENE -> NATIVE -> LUCENE</technical_language>

Target:
public void shouldDropUnselectedLabelIndexes() throws Exception { LabelIndex[] types = LabelIndex.values(); Set<Node> expectedNodes = new HashSet<>(); for ( int i = 0; i < 5; i++ ) { GraphDatabaseService db = db( random.among( types ) ); Node node = createNode( db ); expectedNodes.add( node ); assertNodes( db, expectedNodes ); db.shutdown(); } }
Source:
<code>protected boolean canDoAction() { <START> if (getVds() == null) { <END> return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_HOST_NOT_EXIST); } if (!isValidVdsStatus()) { addCanDoActionMessage(VdcBllMessages.VAR__HOST_STATUS__UP_MAINTENANCE_OR_NON_OPERATIONAL); addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_VDS_STATUS_ILLEGAL); return false; } return true; }</code><technical_language>Do mind write utilize ValidationResult API</technical_language>

Target:
protected boolean canDoAction() { if (!(validate(hostExists()) && validate(hostStatusValid()))){ return false; } return true; }
Source:
<code>public List<String> getBuildCauses() { <START> return new ArrayList<String>(causes); <END> }</code><technical_language>new ArrayList<>(causes);</technical_language>

Target:
public List<String> getBuildCauses() { return new ArrayList<>(causes); }
Source:
<code>private int checkSourceAddress() { for (InetAddress address : <START> mNai.linkProperties.getAllAddresses()) <END> { if (address.equals(mPacket.srcAddress)) { return SUCCESS; } } return ERROR_INVALID_IP_ADDRESS; }</code><technical_language>I this is correct. If clatd is in address, need convert packet IPv4 IPv6 here, a NAT46 implementation in Java</technical_language>

Target:
private int checkSourceAddress() { for (InetAddress address : mNai.linkProperties.getAddresses()) { if (address.equals(mPacket.srcAddress)) { return SUCCESS; } } return ERROR_INVALID_IP_ADDRESS; }
Source:
<code>default Constraint binPacking(IntVar[] itemBin, int[] itemSize, IntVar[] binLoad, int offset) { if (itemBin.length != itemSize.length) { throw new SolverException("itemBin and itemSize arrays should have same size"); } Model model = itemBin[0].getModel(); int sum = 0; for (int i = 0; i<itemSize.length; i++) { sum += itemSize[i]; } int maxCapa = binLoad[0].getUB(); for(int j = 1; j<binLoad.length; j++) { maxCapa = Math.max(maxCapa, binLoad[j].getUB()); } List<IntVar> list = new ArrayList<>(itemBin.length); for(int i = 0; i<itemBin.length; i++) { <START> if(itemSize[i] > (int) Math.ceil(1.0*maxCapa/2)) { <END> list.add(itemBin[i]); } } Constraint diffConstraint; if(list.size() > 2) { diffConstraint = model.allDifferent(list.toArray(new IntVar[0])); } else if(list.size() == 2) { diffConstraint = model.arithm(list.get(0), "!=", list.get(1)); } else { diffConstraint = model.trueConstraint(); } return Constraint.merge( ConstraintsName.BINPACKING, new Constraint(ConstraintsName.BINPACKING, new PropBinPacking(itemBin, itemSize, binLoad, offset)), model.sum(binLoad, "=", sum), diffConstraint ); }</code><technical_language>computing (int) Math.ceil(1.0*maxCapa/2) for for-loop</technical_language>

Target:
default Constraint binPacking(IntVar[] itemBin, int[] itemSize, IntVar[] binLoad, int offset) { if (itemBin.length != itemSize.length) { throw new SolverException("itemBin and itemSize arrays should have same size"); } Model model = itemBin[0].getModel(); int sum = 0; for (int i = 0; i<itemSize.length; i++) { sum += itemSize[i]; } int maxCapa = binLoad[0].getUB(); for(int j = 1; j<binLoad.length; j++) { maxCapa = Math.max(maxCapa, binLoad[j].getUB()); } int thresholdCapa = (int) Math.ceil(1.0*maxCapa/2); List<IntVar> list = new ArrayList<>(itemBin.length); for(int i = 0; i<itemBin.length; i++) { if(itemSize[i] > thresholdCapa) { list.add(itemBin[i]); } } return Constraint.merge( ConstraintsName.BINPACKING, new Constraint(ConstraintsName.BINPACKING, new PropBinPacking(itemBin, itemSize, binLoad, offset)), model.sum(binLoad, "=", sum), model.allDifferent(list.toArray(new IntVar[0])) ); }
Source:
<code>public Credentials convert(String source) { <START> String data[] = source.split(","); <END> return new Credentials(data[0], data[1]); }</code><technical_language>Typically put Array designators "[]" type, variable</technical_language>

Target:
public Credentials convert(String source) { String[] data = source.split(","); return new Credentials(data[0], data[1]); }
Source:
<code>private Object[] executeAggregateExp(PageContext pc, SQL sql, Query source, Expression exp, boolean includeNull, boolean returnDistinct) throws PageException { Object[] result = new Object[source.getRecordcount()]; if (exp instanceof Value) { Object value = ((Value) exp).getValue(); for (int i = 0; i < source.getRecordcount(); i++) { result[i] = value; } return result; } if (exp instanceof Column) { result = ((QueryColumnImpl) source.getColumn(((Column) exp).getColumn())).toArray(); if (!returnDistinct && includeNull) { return result; } else { Stream<Object> resultStream = Arrays.stream(result); if (!includeNull) resultStream = resultStream.filter(s -> (s != null)); if (returnDistinct) resultStream = resultStream.distinct(); <START> return resultStream.toArray(Object[]::new); <END> } } if (exp instanceof Operation) { for (int i = 0; i < source.getRecordcount(); i++) { result[i] = executeOperation(pc, sql, source, (Operation) exp, i + 1); } if (!returnDistinct && includeNull) { return result; } else { Stream<Object> resultStream = Arrays.stream(result); if (!includeNull) resultStream = resultStream.filter(s -> (s != null)); if (returnDistinct) resultStream = resultStream.distinct(); return resultStream.toArray(Object[]::new); } } throw new DatabaseException("unsupported sql statement [" + exp + "]", null, sql, null); }</code><technical_language>syntax work Java 8 compile Java 8 for compatibility, symply do resultStream.toArray()</technical_language>

Target:
private Object[] executeAggregateExp(PageContext pc, SQL sql, Query source, Expression exp, boolean includeNull, boolean returnDistinct) throws PageException { Object[] result = new Object[source.getRecordcount()]; if (exp instanceof Value) { Object value = ((Value) exp).getValue(); for (int i = 0; i < source.getRecordcount(); i++) { result[i] = value; } return result; } if (exp instanceof Column) { result = ((QueryColumnImpl) source.getColumn(((Column) exp).getColumn())).toArray(); if (!returnDistinct && includeNull) { return result; } else { Stream<Object> resultStream = Arrays.stream(result); if (!includeNull) resultStream = resultStream.filter(s -> (s != null)); if (returnDistinct) resultStream = resultStream.distinct(); return resultStream.toArray(); } } if (exp instanceof Operation) { for (int i = 0; i < source.getRecordcount(); i++) { result[i] = executeOperation(pc, sql, source, (Operation) exp, i + 1); } if (!returnDistinct && includeNull) { return result; } else { Stream<Object> resultStream = Arrays.stream(result); if (!includeNull) resultStream = resultStream.filter(s -> (s != null)); if (returnDistinct) resultStream = resultStream.distinct(); return resultStream.toArray(); } } throw new DatabaseException("unsupported sql statement [" + exp + "]", null, sql, null); }
Source:
<code>public DiscoveryResult createResult(ServiceInfo service) { ThingUID uid = getThingUID(service); Map<String, Object> properties = new HashMap<>(2); properties.put(DigitalSTROMBindingConstants.HOST, hostAdress); properties.put(DigitalSTROMBindingConstants.DS_ID, dsid); if (uid != null) { <START> return DiscoveryResultBuilder.create(uid).withProperties(properties).withLabel("DigitalSTROM-Server") <END> .build(); } return null; }</code><technical_language>do withRepresentationProperty(DS_ID)</technical_language>

Target:
public DiscoveryResult createResult(ServiceInfo service) { if (service.getApplication().contains("dssweb")) { ThingUID uid = getThingUID(service); if (uid != null) { String hostAddress = service.getName() + "." + service.getDomain() + "."; Map<String, Object> properties = new HashMap<>(2); properties.put(DigitalSTROMBindingConstants.HOST, hostAddress); properties.put(DigitalSTROMBindingConstants.DS_ID, uid.getId()); return DiscoveryResultBuilder.create(uid).withProperties(properties) .withRepresentationProperty(uid.getId()).withLabel("digitalSTROM-Server").build(); } } return null; }
Source:
<code>public static Matrix4f parseMatrix(JsonElement e) { if (!e.isJsonArray()) throw new JsonParseException("Matrix: expected an array, got: " + e); JsonArray m = e.getAsJsonArray(); if (m.size() != 3) throw new JsonParseException("Matrix: expected an array of length 3, got: " + m.size()); Matrix4f ret = new Matrix4f(); for (int i = 0; i < 3; i++) { if (!m.get(i).isJsonArray()) throw new JsonParseException("Matrix row: expected an array, got: " + m.get(i)); JsonArray r = m.get(i).getAsJsonArray(); if (r.size() != 4) throw new JsonParseException("Matrix row: expected an array of length 4, got: " + r.size()); for (int j = 0; j < 4; j++) { try { ret.setElement(i, j, r.get(i).getAsNumber().floatValue()); } catch (ClassCastException ex) { <START> throw new JsonParseException("Matrix element: expected number, got: " + r.get(i)); <END> } } } return ret; }</code><technical_language>end of this line "r.get(j));" instead of r.get(i));"</technical_language>

Target:
public static Matrix4f parseMatrix(JsonElement e) { if (!e.isJsonArray()) throw new JsonParseException("Matrix: expected an array, got: " + e); JsonArray m = e.getAsJsonArray(); if (m.size() != 3) throw new JsonParseException("Matrix: expected an array of length 3, got: " + m.size()); Matrix4f ret = new Matrix4f(); for (int i = 0; i < 3; i++) { if (!m.get(i).isJsonArray()) throw new JsonParseException("Matrix row: expected an array, got: " + m.get(i)); JsonArray r = m.get(i).getAsJsonArray(); if (r.size() != 4) throw new JsonParseException("Matrix row: expected an array of length 4, got: " + r.size()); for (int j = 0; j < 4; j++) { try { ret.setElement(i, j, r.get(j).getAsNumber().floatValue()); } catch (ClassCastException ex) { throw new JsonParseException("Matrix element: expected number, got: " + r.get(j)); } } } return ret; }
Source:
<code>public void testErrorMessageOnInvalidLambdaBody() { <START> assertInvalidFunction("reduce(ARRAY [1, 2], 0, (s, x) -> concat(s, x), s -> s)", FUNCTION_NOT_FOUND); <END> }</code><technical_language>is message here</technical_language>

Target:
public void testErrorMessageOnInvalidLambdaBody() { assertInvalidFunction("reduce(ARRAY [1, 2], 0, (s, x) -> concat(s, x), s -> s)", FUNCTION_NOT_FOUND, "Unexpected parameters (integer, integer) for function concat. Expected: concat(array(E), E) for type(s): E or concat(E, array(E)) for type(s): E or concat(array(E)) for type(s): E (wrong number of arguments: expected 1 got 2) or concat(varchar) for type(s): (wrong number of arguments: expected 1 got 2) or concat(varbinary) for type(s): (wrong number of arguments: expected 1 got 2)"); }
Source:
<code>public TenderFilter(Double minPrice, Double maxPrice, List<Integer> categories, List<Integer> locations, List<Integer> items, List<Integer> statuses, Date minDate, Date maxDate) { this.minPrice = (minPrice!=null)?minPrice:0; this.maxPrice = (maxPrice!=null)?maxPrice:999999999.99; if (categories==null) { setCategoryFlag(1); }else { this.categories =categories; setCategoryFlag(0); } if (locations==null){ setLocationFlag(1); }else { this.locations = locations; setLocationFlag(0); } if (items==null){ setItemFlag(1); }else { this.items = items; setItemFlag(0); } if (statuses==null) { List<Integer> list = new ArrayList<>(); list.add(OPEN_TENDER_STATUS); list.add(IN_PROGRESS_TENDER_STATUS); setStatuses(list); }else { this.statuses = statuses; } this.minDate = (minDate!=null)?minDate:new Date(); <START> this.maxDate = (maxDate!=null)?maxDate:new Date((new Date().getTime())+2419200000l); <END> }</code><technical_language>do put this changes of this PR</technical_language>

Target:
public TenderFilter(Double minPrice, Double maxPrice, List<Integer> categories, List<Integer> locations, List<Integer> items, List<Integer> statuses, Date minDate, Date maxDate) { this.minPrice = (minPrice!=null)?minPrice:0; this.maxPrice = (maxPrice!=null)?maxPrice:999999999.99; if (categories==null) { setCategoryFlag(1); }else { this.categories =categories; setCategoryFlag(0); } if (locations==null){ setLocationFlag(1); }else { this.locations = locations; setLocationFlag(0); } if (items==null){ setItemFlag(1); }else { this.items = items; setItemFlag(0); } if (statuses==null) { List<Integer> list = new ArrayList<>(); list.add(OPEN_TENDER_STATUS); list.add(IN_PROGRESS_TENDER_STATUS); setStatuses(list); }else { this.statuses = statuses; } this.minDate = (minDate!=null)?minDate:new Date((new Date().getTime())-604800000l); this.maxDate = (maxDate!=null)?maxDate:new Date(); }
Source:
<code>protected File doInBackground(Void... voids) { mAppMorph.morphApp(mLabel, mIcon); <START> return null; <END> }</code><technical_language>AsyncTask<Void, Void, Void> if returning null anyway? (Haven't worked AsyncTasks, if possible?)</technical_language>

Target:
protected Void doInBackground(Void... voids) { mAppMorph.morphApp(mLabel, mIcon); return null; }
Source:
<code>protected VDS selectBestProxy(FenceProxySourceType fenceProxySource, Guid excludedHostId) { return getDbFacade().getVdsDao().getAll().stream() <START> .filter(vds -> !vds.getId().equals(fencedHost.getId()) <END> && !isHostExcluded(vds, excludedHostId) && isHostFromSelectedSource(vds, fenceProxySource) && areAgentsVersionCompatible(vds) && isFencingPolicySupported(vds, getMinSupportedVersionForFencingPolicy()) && !isHostNetworkUnreachable(vds)) .sorted((x, y) -> (x.getStatus() == VDSStatus.Up ? -1 : y.getStatus() == VDSStatus.Up ? 1 : 0)) .findFirst() .orElse(null); }</code><technical_language>work: .filter(vds -> { log.debug("Evaluating host '{}'", vds.getHostName()); return !vds.getId().equals(fencedHost.getId()) && !isHostExcluded(vds, excludedHostId) && isHostFromSelectedSource(vds, fenceProxySource) && areAgentsVersionCompatible(vds) && isFencingPolicySupported(vds, getMinSupportedVersionForFencingPolicy()) && !isHostNetworkUnreachable(vds); })</technical_language>

Target:
protected VDS selectBestProxy(FenceProxySourceType fenceProxySource, Guid excludedHostId) { return getDbFacade().getVdsDao().getAll().stream() .peek(vds -> log.debug("Evaluating host '{}'", vds.getHostName())) .filter(vds -> !Objects.equals(vds.getId(), fencedHost.getId())) .filter(vds -> !isHostExcluded(vds, excludedHostId)) .filter(vds -> isHostFromSelectedSource(vds, fenceProxySource)) .filter(this::areAgentsVersionCompatible) .filter(vds -> isFencingPolicySupported(vds, getMinSupportedVersionForFencingPolicy())) .filter(vds -> !isHostNetworkUnreachable(vds)) .sorted(Comparator.comparingInt(vds -> vds.getStatus() == VDSStatus.Up ? -1 : 1)) .findFirst() .orElse(null); }
Source:
<code>public void illegalStateExceptionThrownWhenConstraintMatchNotEnabled() { <START> ScoreHolder scoreHolder = buildScoreHolder(false); <END> thrown.expect(IllegalStateException.class); thrown.expectMessage("constraintMatchEnabled"); scoreHolder.getConstraintMatchTotals().clear(); }</code><technical_language>agreed :) rename field "thrown" "expectedException" link expected is more clear</technical_language>

Target:
public void illegalStateExceptionThrownWhenConstraintMatchNotEnabled() { ScoreHolder scoreHolder = buildScoreHolder(false); expectedException.expect(IllegalStateException.class); expectedException.expectMessage("constraintMatchEnabled"); scoreHolder.getConstraintMatchTotals().clear(); }
Source:
<code>public PositionedCryptoInputStream(Properties props, InputStream in, byte[] key, byte[] iv, long streamOffset) throws IOException { <START> this(in, Utils.getCipherInstance(props), Utils.getBufferSize(props), key, iv, streamOffset); <END> }</code><technical_language>invoke super(in, Utils.getCipherInstance(props), Utils.getBufferSize(props), key, iv, streamOffset) instead of declaring a construction in L66:L74</technical_language>

Target:
public PositionedCryptoInputStream(Properties props, InputStream in, byte[] key, byte[] iv, long streamOffset) throws IOException { this(in, CipherFactory.getInstance(props), Utils.getBufferSize(props), key, iv, streamOffset); }