auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void deleteSequencerServiceRecord(SequencerServiceRecord serviceRecord) throws IOException { <START> backingManager.deleteSequencerServiceRecord(serviceRecord); <END> }</code><technical_language>users able delete</technical_language>

Target:
public void deleteSequencerServiceRecord(SequencerServiceRecord serviceRecord) throws IOException { if (getCurrentUser().isAdmin()) { backingManager.deleteSequencerServiceRecord(serviceRecord); } }
Source:
<code>public void init(H http) throws Exception { validateInput(); String key = getKey(); RememberMeServices rememberMeServices = getRememberMeServices(http, key); if (rememberMeServices instanceof AbstractRememberMeServices) { <START> key = ((AbstractRememberMeServices) rememberMeServices).getKey(); <END> } http.setSharedObject(RememberMeServices.class, rememberMeServices); LogoutConfigurer<H> logoutConfigurer = http.getConfigurer(LogoutConfigurer.class); if (logoutConfigurer != null && this.logoutHandler != null) { logoutConfigurer.addLogoutHandler(this.logoutHandler); } RememberMeAuthenticationProvider authenticationProvider = new RememberMeAuthenticationProvider( key); authenticationProvider = postProcess(authenticationProvider); http.authenticationProvider(authenticationProvider); initDefaultLoginFilter(http); }</code><technical_language>do want override key if user in .key("..."). check if key is null AbstractRememberMeServices</technical_language>

Target:
public void init(H http) throws Exception { validateInput(); String key = getKey(); RememberMeServices rememberMeServices = getRememberMeServices(http, key); http.setSharedObject(RememberMeServices.class, rememberMeServices); LogoutConfigurer<H> logoutConfigurer = http.getConfigurer(LogoutConfigurer.class); if (logoutConfigurer != null && this.logoutHandler != null) { logoutConfigurer.addLogoutHandler(this.logoutHandler); } RememberMeAuthenticationProvider authenticationProvider = new RememberMeAuthenticationProvider( key); authenticationProvider = postProcess(authenticationProvider); http.authenticationProvider(authenticationProvider); initDefaultLoginFilter(http); }
Source:
<code>public void testBasicProvider() { BasicSymbolProvider symbolProvider = getSymbolProvider(); symbolProvider.setMappingFiles(MappingFileTest.getMappingFiles()); String symbolText = symbolProvider.getSymbolText(Long.parseUnsignedLong("601050", 16)); assertEquals("__dso_handle", symbolText); symbolText = symbolProvider.getSymbolText(Long.parseUnsignedLong("400752", 16)); assertEquals("A little bit after nm_ouput's frame_dummy", symbolText); symbolText = symbolProvider.getSymbolText(1, 0L, Long.parseUnsignedLong("400752", 16)); assertEquals("frame_dummy", symbolText); symbolText = symbolProvider.getSymbolText(123, 0L, Long.parseUnsignedLong("4005d0", 16)); assertEquals("same address as nm_output", symbolText); symbolText = symbolProvider.getSymbolText(123, 0L, Long.parseUnsignedLong("400735", 16)); assertEquals("A little bit before nm_ouput's frame_dummy", symbolText); symbolText = symbolProvider.getSymbolText(123, 0L, Long.parseUnsignedLong("ffeeddccbbaa0090", 16)); assertEquals("One huge <START> sombol from <END> nm mapping", symbolText); symbolText = symbolProvider.getSymbolText(1, 0L, Long.parseUnsignedLong("ffeeddccbbaa0090", 16)); assertNull(symbolText); }</code><technical_language>If correct mapping file, forget change here</technical_language>

Target:
public void testBasicProvider() { BasicSymbolProvider symbolProvider = getSymbolProvider(); symbolProvider.setMappingFiles(MappingFileTest.getMappingFiles()); String symbolText = symbolProvider.getSymbolText(Long.parseUnsignedLong("601050", 16)); assertEquals("__dso_handle", symbolText); symbolText = symbolProvider.getSymbolText(Long.parseUnsignedLong("400752", 16)); assertEquals("A little bit after nm_ouput's frame_dummy", symbolText); symbolText = symbolProvider.getSymbolText(1, 0L, Long.parseUnsignedLong("400752", 16)); assertEquals("frame_dummy", symbolText); symbolText = symbolProvider.getSymbolText(123, 0L, Long.parseUnsignedLong("4005d0", 16)); assertEquals("same address as nm_output", symbolText); symbolText = symbolProvider.getSymbolText(123, 0L, Long.parseUnsignedLong("400735", 16)); assertEquals("A little bit before nm_ouput's frame_dummy", symbolText); symbolText = symbolProvider.getSymbolText(123, 0L, Long.parseUnsignedLong("ffeeddccbbaa0090", 16)); assertEquals("One huge symbol from nm mapping", symbolText); symbolText = symbolProvider.getSymbolText(1, 0L, Long.parseUnsignedLong("ffeeddccbbaa0090", 16)); assertNull(symbolText); }
Source:
<code>protected Object extractPlanningId(Object externalObject) { Object planningId = planningIdMemberAccessor.executeGetter(externalObject); if (planningId == null) { throw new IllegalArgumentException("The planningId (" + planningId <START> + ") of the member (" + planningIdMemberAccessor <END> + ") on externalObject (" + externalObject + ") must not be null.\n" + "Maybe initialize the planningId of the original object before solving" + " or remove the " + PlanningId.class.getSimpleName() + " annotation" + " or change the " + PlanningSolution.class.getSimpleName() + " annotation's " + LocationStrategyType.class.getSimpleName() + "."); } return Pair.of(externalObject.getClass(), planningId); }</code><technical_language>I if member is a superclass. revert this prove for edge case. (note I worried verbose error messages - verbosity in toString() shows in debugger - I more worried of showing context is relative)</technical_language>

Target:
protected Object extractPlanningId(Object externalObject) { Object planningId = planningIdMemberAccessor.executeGetter(externalObject); if (planningId == null) { throw new IllegalArgumentException("The planningId (" + planningId + ") of the member (" + planningIdMemberAccessor + ") of the class (" + externalObject.getClass() + ") on externalObject (" + externalObject + ") must not be null.\n" + "Maybe initialize the planningId of the original object before solving" + " or remove the " + PlanningId.class.getSimpleName() + " annotation" + " or change the " + PlanningSolution.class.getSimpleName() + " annotation's " + LocationStrategyType.class.getSimpleName() + "."); } return Pair.of(externalObject.getClass(), planningId); }
Source:
<code>@Override public void close() throws IOException { try { for ( ResultSet rs : otherResultSets ) { <START> resultSet.close(); <END> } for ( Statement s : otherStatements ) { s.close(); } resultSet.close(); statement.close(); connection.close(); open = false; } catch ( SQLException e ) { throw new IOException( "Unable to close sql objects", e ); } }</code><technical_language>This rs, I guess</technical_language>

Target:
@Override public void close() throws IOException { try { for ( ResultSet rs : otherResultSets ) { rs.close(); } for ( Statement s : otherStatements ) { s.close(); } resultSet.close(); statement.close(); connection.close(); open = false; } catch ( SQLException e ) { throw new IOException( "Unable to close sql objects", e ); } }
Source:
<code>private void setControlEnabled(Composite composite, boolean enabled){ composite.setEnabled(enabled); for (Control child : composite.getChildren()) { if (child == removeGraphButton || child == copyGraphButton) { child.setEnabled(false); <START> } <END> if(child instanceof Composite){ setControlEnabled((Composite)child, enabled); } } }</code><technical_language>While this code sense. agree idea of function. In addition this called for child in tree. setting enablement for composite add a call removeGraphButton.setEnabled(false); copyGraphButton.setEnabled(false);</technical_language>

Target:
private void setControlEnabled(Composite composite, boolean enabled){ composite.setEnabled(enabled); for (Control child : composite.getChildren()) { child.setEnabled(enabled); if(child instanceof Composite){ setControlEnabled((Composite)child, enabled); } } }
Source:
<code>public boolean updateConsoleLog(File dest, InputStream in) throws IOException { File parentFile = dest.getParentFile(); parentFile.mkdirs(); LOGGER.trace("Updating console log [" + dest.getAbsolutePath() + "]"); try (BufferedWriter writer = new BufferedWriter(new FileWriter(dest, dest.exists()))) { <START> IOUtils.copy(in, writer, Charset.defaultCharset()); <END> } catch (IOException e) { LOGGER.error("Failed to update console log at : [" + dest.getAbsolutePath() + "]", e); return false; } if (LOGGER.isTraceEnabled()) { LOGGER.trace("Console log [" + dest.getAbsolutePath() + "] saved."); } return true; }</code><technical_language>This assumes Charset.defaultCharset() agent server is identical, other issues encodings identical (or compatible) Instead of a Writer write out InputStream, if open dest a (buffered) FileOutputStream write instead, do gotchas encodings. java try (OutputStream out = new BufferedOutputStream(new FileOutputStream(dest, dest.exists()))) { IOUtils.copy(in, out); }</technical_language>

Target:
public boolean updateConsoleLog(File dest, InputStream in) throws IOException { File parentFile = dest.getParentFile(); parentFile.mkdirs(); LOGGER.trace("Updating console log [" + dest.getAbsolutePath() + "]"); try (OutputStream out = new BufferedOutputStream(new FileOutputStream(dest, dest.exists()))) { IOUtils.copy(in, out); } catch (IOException e) { LOGGER.error("Failed to update console log at : [" + dest.getAbsolutePath() + "]", e); return false; } if (LOGGER.isTraceEnabled()) { LOGGER.trace("Console log [" + dest.getAbsolutePath() + "] saved."); } return true; }
Source:
<code>public CoalesceUnitPanel(ColumnListMultipleCoalesceUnitPropertyWidget parent, CoalesceUnit unit) { _parent = parent; _inputColumns = new ArrayList<>(); _inputColumnPanels = new IdentityHashMap<>(); _comboBox = new DCComboBox<>(); SchemaStructureComboBoxListRenderer renderer = new SchemaStructureComboBoxListRenderer(); renderer.setNullText("- Add input column -"); _comboBox.setRenderer(renderer); _comboBox.addListener(new DCComboBox.Listener<InputColumn<?>>() { @Override public void onItemSelected(InputColumn<?> item) { if (item == null) { return; } addInputColumn(item); } }); _columnListPanel = new DCPanel(); _columnListPanel.setLayout(new VerticalLayout(2)); _columnListPanel.setBorder(new EmptyBorder(4, 4, 4, 4)); final DCPanel comboBoxPanel = DCPanel.around(_comboBox); comboBoxPanel.setBorder(new EmptyBorder(4, 4, 4, 4)); _outerPanel = new DCPanel(); _outerPanel.setLayout(new BorderLayout()); _outerPanel.add(_columnListPanel, BorderLayout.CENTER); _outerPanel.add(comboBoxPanel, BorderLayout.SOUTH); setLayout(new BorderLayout()); add(WidgetUtils.decorateWithShadow(_outerPanel), BorderLayout.CENTER); List<InputColumn<?>> availableInputColumns = _parent.getAvailableInputColumns(); setAvailableInputColumns(availableInputColumns); if (unit != null) { InputColumn<?>[] updatedInputColumns = unit.getUpdatedInputColumns(availableInputColumns <START> .toArray(new InputColumn[availableInputColumns.size()]), false); <END> for (InputColumn<?> inputColumn : updatedInputColumns) { addInputColumn(inputColumn); } } }</code><technical_language>updatedInputColumns final</technical_language>

Target:
public CoalesceUnitPanel(ColumnListMultipleCoalesceUnitPropertyWidget parent, CoalesceUnit unit) { _parent = parent; _inputColumns = new ArrayList<>(); _inputColumnPanels = new IdentityHashMap<>(); _comboBox = new DCComboBox<>(); SchemaStructureComboBoxListRenderer renderer = new SchemaStructureComboBoxListRenderer(); renderer.setNullText("- Add input column -"); _comboBox.setRenderer(renderer); _comboBox.addListener(new DCComboBox.Listener<InputColumn<?>>() { @Override public void onItemSelected(InputColumn<?> item) { if (item == null) { return; } addInputColumn(item); } }); _columnListPanel = new DCPanel(); _columnListPanel.setLayout(new VerticalLayout(2)); _columnListPanel.setBorder(new EmptyBorder(4, 4, 4, 4)); final DCPanel comboBoxPanel = DCPanel.around(_comboBox); comboBoxPanel.setBorder(new EmptyBorder(4, 4, 4, 4)); _outerPanel = new DCPanel(); _outerPanel.setLayout(new BorderLayout()); _outerPanel.add(_columnListPanel, BorderLayout.CENTER); _outerPanel.add(comboBoxPanel, BorderLayout.SOUTH); setLayout(new BorderLayout()); add(WidgetUtils.decorateWithShadow(_outerPanel), BorderLayout.CENTER); List<InputColumn<?>> availableInputColumns = _parent.getAvailableInputColumns(); setAvailableInputColumns(availableInputColumns); if (unit != null) { final InputColumn<?>[] updatedInputColumns = unit.getUpdatedInputColumns(availableInputColumns .toArray(new InputColumn[availableInputColumns.size()]), false); for (InputColumn<?> inputColumn : updatedInputColumns) { addInputColumn(inputColumn); } } }
Source:
<code>public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case FILE_SELECT_CODE: if (resultCode == RESULT_OK) { Uri uri = data.getData(); <START> Log.d("Get file", "File Uri: " + uri.toString()); <END> ContentResolver cR = getContentResolver(); Log.d("file type", cR.getType(uri)); addAttachment(uri); } break; } super.onActivityResult(requestCode, resultCode, data); }</code><technical_language>is a Log class for project (Log.java utils package)</technical_language>

Target:
public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case FILE_SELECT_CODE: if (resultCode == RESULT_OK) { Uri uri = data.getData(); ContentResolver cR = getContentResolver(); addAttachment(uri); } break; } super.onActivityResult(requestCode, resultCode, data); }
Source:
<code>private boolean isPatch(Feature feature) { FeatureEntry[] entries = feature.getEntries(); for (FeatureEntry <START> entrie : <END> entries) { if (entrie.isPatch()) { return true; } } return false; }</code><technical_language>entry</technical_language>

Target:
private boolean isPatch(Feature feature) { FeatureEntry[] entries = feature.getEntries(); for (FeatureEntry entry : entries) { if (entry.isPatch()) { return true; } } return false; }
Source:
<code>private int resolveDecodedLength(int lengthByte) throws PatchApplyException { if (lengthByte <= 122 && lengthByte >= 97) { return lengthByte - 70; } else if (lengthByte <= 90 && lengthByte >= 65) { return lengthByte - 64; } else { throw new PatchApplyException( <START> "Invalid length found: " + lengthByte); <END> } }</code><technical_language>a MessageFormat JGitText</technical_language>

Target:
private int resolveDecodedLength(int lengthByte) throws PatchApplyException { if (lengthByte <= 122 && lengthByte >= 97) { return lengthByte - 70; } else if (lengthByte <= 90 && lengthByte >= 65) { return lengthByte - 64; } else { throw new PatchApplyException(MessageFormat.format( JGitText.get().invalidBinaryStreamLength, (char) lengthByte)); } }
Source:
<code>private boolean cacheReadRequest(ReadOptions options) { if (runtime.getParameters().isCacheDisabled() && options.isClientCacheable()) { <START> if (runtime.getParameters().getPriorityLevel() != PriorityLevel.HIGH) { <END> log.warn("read: Runtime cache is disabled, but read request is requesting to cache"); } } return !runtime.getParameters().isCacheDisabled() && options.isClientCacheable(); }</code><technical_language>review suggested this log line, I vote for removing making this distinction</technical_language>

Target:
private boolean cacheReadRequest(ReadOptions options) { return !runtime.getParameters().isCacheDisabled() && options.isClientCacheable(); }
Source:
<code><START> public Image stereotypeIconToDisplay() { <END> String stereotypespresentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind((View) getHost().getModel()); if (stereotypespresentationKind == null) { return null; } if (stereotypespresentationKind.equals(UMLVisualInformationPapyrusConstant.ICON_STEREOTYPE_PRESENTATION) || stereotypespresentationKind.equals(UMLVisualInformationPapyrusConstant.TEXT_ICON_STEREOTYPE_PRESENTATION)) { String stereotypesToDisplay = AppliedStereotypeHelper.getStereotypesToDisplay((View) getHost().getModel()); StringTokenizer tokenizer = new StringTokenizer(stereotypesToDisplay, ","); if (tokenizer.hasMoreTokens()) { String firstStereotypeName = tokenizer.nextToken(); Stereotype stereotype = getUMLElement().getAppliedStereotype(firstStereotypeName); return Activator.getIconElement(getUMLElement(), stereotype, false); } } return null; }</code><technical_language>A local variable for returned used. Multiple returns avoided</technical_language>

Target:
public Image stereotypeIconToDisplay() { Image icon = null; String stereotypespresentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind((View) getHost().getModel()); if (stereotypespresentationKind == null) { icon = null; } if (stereotypespresentationKind.equals(UMLVisualInformationPapyrusConstant.ICON_STEREOTYPE_PRESENTATION) || stereotypespresentationKind.equals(UMLVisualInformationPapyrusConstant.TEXT_ICON_STEREOTYPE_PRESENTATION)) { String stereotypesToDisplay = AppliedStereotypeHelper.getStereotypesToDisplay((View) getHost().getModel()); StringTokenizer tokenizer = new StringTokenizer(stereotypesToDisplay, ","); if (tokenizer.hasMoreTokens()) { String firstStereotypeName = tokenizer.nextToken(); Stereotype stereotype = getUMLElement().getAppliedStereotype(firstStereotypeName); icon = Activator.getIconElement(getUMLElement(), stereotype, false); } } return icon; }
Source:
<code>public void provideCompletedRunData(Run run, JSONObject json) { FailureCauseBuildAction action = run.getAction(FailureCauseBuildAction.class); if (action != null) { List<FoundFailureCause> foundFailureCauses = action.getFoundFailureCauses(); JSONArray failureCausesJSON = new JSONArray(); for (FoundFailureCause foundFailureCause : foundFailureCauses) { JSONObject failureCauseJSON = new JSONObject(); failureCauseJSON.put("id", foundFailureCause.getId()); failureCauseJSON.put("name", foundFailureCause.getName()); failureCauseJSON.put("description", foundFailureCause.getDescription()); failureCauseJSON.put("categories", foundFailureCause.getCategories()); JSONArray foundIndicationsJSON = new JSONArray(); for (FoundIndication ind : foundFailureCause.getIndications()) { <START> JSONObject foundIndicationJSON = new JSONObject(); <END> foundIndicationJSON.put("pattern", ind.getPattern()); foundIndicationJSON.put("matchingString", ind.getMatchingString()); foundIndicationsJSON.add(foundIndicationJSON); } failureCauseJSON.put("indications", foundIndicationsJSON); failureCausesJSON.add(failureCauseJSON); } json.put("failurecauses", failureCausesJSON); } }</code><technical_language>_nit_ difference of s in variable name a bit hard read</technical_language>

Target:
public void provideCompletedRunData(Run run, JSONObject json) { FailureCauseBuildAction action = run.getAction(FailureCauseBuildAction.class); if (action != null) { List<FoundFailureCause> foundFailureCausesList = action.getFoundFailureCauses(); JSONArray failureCausesJSONArray = new JSONArray(); for (FoundFailureCause foundFailureCause : foundFailureCausesList) { JSONObject failureCauseJSONObject = new JSONObject(); failureCauseJSONObject.put("id", foundFailureCause.getId()); failureCauseJSONObject.put("name", foundFailureCause.getName()); failureCauseJSONObject.put("description", foundFailureCause.getDescription()); failureCauseJSONObject.put("categories", foundFailureCause.getCategories()); JSONArray foundIndicationsJSONArray = new JSONArray(); for (FoundIndication indication : foundFailureCause.getIndications()) { JSONObject foundIndicationJSONObject = new JSONObject(); foundIndicationJSONObject.put("pattern", indication.getPattern()); foundIndicationJSONObject.put("matchingString", indication.getMatchingString()); foundIndicationsJSONArray.add(foundIndicationJSONObject); } failureCauseJSONObject.put("indications", foundIndicationsJSONArray); failureCausesJSONArray.add(failureCauseJSONObject); } json.put("failurecauses", failureCausesJSONArray); } }
Source:
<code>public String getContainerHostForModulePrefix(String streamName, ModuleType moduleType) { Assert.hasText(streamName, "stream name can not be empty nor null"); String moduleIdPrefix = streamName + "." + moduleType + "."; Iterator<ModuleMetadataResource> resourceIter = StreamUtils.getRuntimeModules(adminServer).iterator(); ArrayList<String> containerIds = new ArrayList<String>(); while (resourceIter.hasNext()) { ModuleMetadataResource resource = resourceIter.next(); <START> if (resource.getName().startsWith(moduleIdPrefix)) { <END> containerIds.add(resource.getContainerId()); } } Assert.isTrue( containerIds.size() == 1, "Test require that module to be deployed to only one container. It was deployed to " + containerIds.size() + " containers"); return containers.get(containerIds.get(0)); }</code><technical_language>this before, I foresee problems name</technical_language>

Target:
public String getContainerHostForModulePrefix(String streamName, ModuleType moduleType) { Assert.hasText(streamName, "stream name can not be empty nor null"); String moduleIdPrefix = streamName + "." + moduleType + "."; Iterator<ModuleMetadataResource> resourceIter = StreamUtils.getRuntimeModules(adminServer).iterator(); ArrayList<String> containerIds = new ArrayList<String>(); while (resourceIter.hasNext()) { ModuleMetadataResource resource = resourceIter.next(); if (resource.getModuleId().startsWith(moduleIdPrefix)) { containerIds.add(resource.getContainerId()); } } Assert.isTrue( containerIds.size() == 1, "Test require that module to be deployed to only one container. It was deployed to " + containerIds.size() + " containers"); return containers.get(containerIds.get(0)); }
Source:
<code>private void cleanupDataSets(FileSystem oldDatasetsFS) { Path oldDatasetsRoot = getRoot(oldDatasetsFS); if (oldDatasetsRoot != null) { if (oldDatasetsFS instanceof JGitFileSystem) { try { Path fsPath = oldDatasetsFS.getPath(""); Files.delete(fsPath); } catch (Exception e) { <START> LOGGER.error("Failed to remove the datasets git repository."); <END> } } } }</code><technical_language>before: I print original exception stack trace in debug mode</technical_language>

Target:
private void cleanupDataSets(FileSystem oldDatasetsFS) { Path oldDatasetsRoot = getRoot(oldDatasetsFS); if (oldDatasetsRoot != null) { if (oldDatasetsFS instanceof JGitFileSystem) { try { Path fsPath = oldDatasetsFS.getPath(""); Files.delete(fsPath); } catch (Exception e) { LOGGER.error("Failed to remove the datasets git repository."); LOGGER.debug("Error during dashbuilder migration", e); } } } }
Source:
<code>public void writeObject(Object obj) throws IOException { <START> LinkedBuffer buffer = LinkedBuffer.allocate(); <END> byte[] bytes; byte[] classNameBytes; if (Utils.WRAPPER_SET.contains(obj.getClass()) || obj.getClass().isArray() || obj instanceof Enum) { Schema<Wrapper> schema = RuntimeSchema.getSchema(Wrapper.class); Wrapper wrapper = new Wrapper(obj); bytes = ProtobufIOUtil.toByteArray(wrapper, schema, buffer); classNameBytes = Wrapper.class.getName().getBytes(); } else { Schema schema = RuntimeSchema.getSchema(obj.getClass()); bytes = ProtobufIOUtil.toByteArray(obj, schema, buffer); classNameBytes = obj.getClass().getName().getBytes(); } dos.writeInt(classNameBytes.length); dos.writeInt(bytes.length); dos.write(classNameBytes); dos.write(bytes); }</code><technical_language>buffer's purpose is for performance caching. is created everytime. is a good sample. // Re-use (manage) this buffer avoid allocating serialization LinkedBuffer buffer = LinkedBuffer.allocate(512); // ser final byte[] protostuff; try { protostuff = ProtostuffIOUtil.toByteArray(foo, schema, buffer); } finally { buffer.clear(); }</technical_language>

Target:
public void writeObject(Object obj) throws IOException { LinkedBuffer buffer = LinkedBuffer.allocate(); byte[] bytes; byte[] classNameBytes; if (WrapperUtils.needWrapper(obj)) { Schema<Wrapper> schema = RuntimeSchema.getSchema(Wrapper.class); Wrapper wrapper = new Wrapper(obj); bytes = ProtobufIOUtil.toByteArray(wrapper, schema, buffer); classNameBytes = Wrapper.class.getName().getBytes(); } else { Schema schema = RuntimeSchema.getSchema(obj.getClass()); bytes = ProtobufIOUtil.toByteArray(obj, schema, buffer); classNameBytes = obj.getClass().getName().getBytes(); } dos.writeInt(classNameBytes.length); dos.writeInt(bytes.length); dos.write(classNameBytes); dos.write(bytes); }
Source:
<code>public String toString() { <START> final String lineSeparator = System.getProperty("line.separator"); <END> StringBuilder output = new StringBuilder(); output.append(StringUtils.format("Druid version - %s", version)).append(lineSeparator).append(lineSeparator); if (modules.size() > 0) { output.append("Registered Druid Modules").append(lineSeparator); } else { output.append("No Druid Modules loaded !"); } for (ModuleVersion moduleVersion : modules) { output.append(moduleVersion).append(lineSeparator); } return output.toString(); }</code><technical_language>Please extract a constant, StringUtils a good place for it</technical_language>

Target:
public String toString() { StringBuilder output = new StringBuilder(); String lineSeparator = System.lineSeparator(); output.append(StringUtils.format("Druid version - %s", version)).append(lineSeparator).append(lineSeparator); if (modules.size() > 0) { output.append("Registered Druid Modules").append(lineSeparator); } else { output.append("No Druid Modules loaded !"); } for (ModuleVersion moduleVersion : modules) { output.append(moduleVersion).append(lineSeparator); } return output.toString(); }
Source:
<code>public KRunState rewrite(ConstrainedTerm constrainedTerm, int bound, boolean computeGraph) { stopwatch.start(); Context context = definition.context(); <START> KRunState initialState = new JavaKRunState(constrainedTerm.term(), <END> context, counter); if (computeGraph) { executionGraph = new KRunGraph(); executionGraph.addVertex(initialState); } for (step = 0; step != bound; ++step) { computeRewriteStep(constrainedTerm, 1); ConstrainedTerm result = getTransition(0); if (result != null) { KRunState finalState = new JavaKRunState(result.term(), context, counter); if (computeGraph) { JavaTransition javaTransition = new JavaTransition( getRule(0), getSubstitution(0), context); executionGraph.addEdge(javaTransition, initialState, finalState); } constrainedTerm = result; initialState = finalState; } else { break; } } stopwatch.stop(); if (definition.context().krunOptions.experimental.statistics) { System.err.println("[" + step + ", " + stopwatch + "]"); } return initialState; }</code><technical_language>this run fast possible, declare this if, initialize null, initialize if</technical_language>

Target:
public KRunState rewrite(ConstrainedTerm constrainedTerm, int bound, boolean computeGraph) { stopwatch.start(); Context context = definition.context(); KRunState initialState = null; if (computeGraph) { executionGraph = new KRunGraph(); initialState = new JavaKRunState(constrainedTerm.term(), context, counter); executionGraph.addVertex(initialState); } for (step = 0; step != bound; ++step) { computeRewriteStep(constrainedTerm, 1); ConstrainedTerm result = getTransition(0); KRunState finalState = null; if (result != null) { if (computeGraph) { finalState = new JavaKRunState(result.term(), context, counter); JavaTransition javaTransition = new JavaTransition( getRule(0), getSubstitution(0), context); executionGraph.addEdge(javaTransition, initialState, finalState); } constrainedTerm = result; } else { if (computeGraph) { initialState = finalState; } break; } } stopwatch.stop(); if (definition.context().krunOptions.experimental.statistics) { System.err.println("[" + step + ", " + stopwatch + "]"); } if (initialState == null) { initialState = new JavaKRunState(constrainedTerm.term(), context, counter); } return initialState; }
Source:
<code>private static Multimap<String, String> toStringMap(JSONObject object) { if (object != null) { Multimap<String, String> map = HashMultimap.create(); Iterator<String> keys = object.keys(); while (keys.hasNext()) { String key = keys.next(); if (key != null) { map.put(key, object.optString(key)); } } return map; } <START> return null; <END> }</code><technical_language>actually, add a null check ServerRequestImpl</technical_language>

Target:
private static Multimap<String, String> toStringMap(JSONObject object) { if (object != null) { Multimap<String, String> map = HashMultimap.create(); Iterator<String> keys = object.keys(); while (keys.hasNext()) { String key = keys.next(); if (key != null) { map.put(key, object.optString(key, null)); } } return map; } return null; }
Source:
<code>public StreamlineHiveMapper(List<String> fields, List<String> partitionFields) { Objects.requireNonNull(fields, "Empty fields"); Objects.requireNonNull(partitionFields, "Empty partitionFields"); <START> this.fields = fields.stream().map(field -> field.substring(field.indexOf(":") + 1, field.length())).collect(Collectors.toList()); <END> this.partitionFields = partitionFields.stream().map(field -> field.substring(field.indexOf(":") + 1, field.length())).collect(Collectors.toList()); }</code><technical_language>need endIndex field.length() field.substring(startIndex) is sufficient. want do change for next line</technical_language>

Target:
public StreamlineHiveMapper(List<String> fields, List<String> partitionFields) { Objects.requireNonNull(fields, "Empty fields"); Objects.requireNonNull(partitionFields, "Empty partitionFields"); this.fields = fields.stream().map(field -> field.substring(field.indexOf(":") + 1)).collect(Collectors.toList()); this.partitionFields = partitionFields.stream().map(field -> field.substring(field.indexOf(":") + 1)).collect(Collectors.toList()); }
Source:
<code>public AttributeDefinition getAttributeDefinition() { AttributeDefinition attr = new AttributeDefinition(); attr.setNamespace(AttributesManager.NS_RESOURCE_ATTR_DEF); attr.setFriendlyName("maxUserDataQuotas"); <START> attr.setDisplayName("Maximum of data quotas of User on any volumes."); <END> attr.setType(LinkedHashMap.class.getName()); attr.setDescription("This is Facility manager maximum set for Resource on defined volumes. " + "Every record is the path (to volume) and the quota in format 'SoftQuota:HardQuota' in (M, G, T, ...), G is default. Example: '10G:20T'."); return attr; }</code><technical_language>user lowercase 'u'</technical_language>

Target:
public AttributeDefinition getAttributeDefinition() { AttributeDefinition attr = new AttributeDefinition(); attr.setNamespace(AttributesManager.NS_RESOURCE_ATTR_DEF); attr.setFriendlyName("maxUserDataQuotas"); attr.setDisplayName("Maximum of data quotas of user on any volumes."); attr.setType(LinkedHashMap.class.getName()); attr.setDescription("Maximum data quota for each user on this resource. " + "Every record is the path (to volume) and the quota in format 'SoftQuota:HardQuota' in (M, G, T, ...), G is default. Example: '10G:20T'."); return attr; }
Source:
<code>public void shouldAlwaysPull() { try ( GenericContainer<?> container = new GenericContainer<>(imageName) .withStartupCheckStrategy(new OneShotStartupCheckStrategy()) ) { container.start(); } <START> DockerClientFactory.instance().client() .removeImageCmd(imageName.asCanonicalNameString()) .withForce(true) .exec(); <END> try ( GenericContainer<?> container = new GenericContainer<>(imageName) .withStartupCheckStrategy(new OneShotStartupCheckStrategy()) ) { expectToFailWithNotFoundException(container); } try ( GenericContainer<?> container = new GenericContainer<>(imageName) .withImagePullPolicy(PullPolicy.alwaysPull()) ) { container.withStartupCheckStrategy(new OneShotStartupCheckStrategy()); container.start(); } }</code><technical_language>suggestion removeImage();</technical_language>

Target:
public void shouldAlwaysPull() { try ( GenericContainer<?> container = new GenericContainer<>(imageName) .withStartupCheckStrategy(new OneShotStartupCheckStrategy()) ) { container.start(); } removeImage(); try ( GenericContainer<?> container = new GenericContainer<>(imageName) .withStartupCheckStrategy(new OneShotStartupCheckStrategy()) ) { expectToFailWithNotFoundException(container); } try ( GenericContainer<?> container = new GenericContainer<>(imageName) .withImagePullPolicy(PullPolicy.alwaysPull()) ) { container.withStartupCheckStrategy(new OneShotStartupCheckStrategy()); container.start(); } }
Source:
<code>public boolean await(Duration duration) throws InterruptedException { <START> KeyValueStoreProvider kv = (KeyValueStoreProvider) getKvStore(); <END> Set<String> commandIds = kv.keyStream() .filter(k -> k.endsWith(STATUS)) .map(k -> k.replaceFirst(STATUS, "")) .collect(Collectors.toSet()); for (String id : commandIds) { while (getStatus(id).getState() != State.COMPLETED) { Thread.sleep(100); } } return true; }</code><technical_language>duration is anymore. I this is right</technical_language>

Target:
public boolean await(Duration duration) throws InterruptedException { KeyValueStoreProvider kv = (KeyValueStoreProvider) getKvStore(); Set<String> commandIds = kv.keyStream() .filter(k -> k.endsWith(STATUS)) .map(k -> k.replaceFirst(STATUS, "")) .collect(Collectors.toSet()); for (String id : commandIds) { while (getStatus(id).getState() != State.COMPLETED) { Thread.sleep(100); long deadline = System.nanoTime() + duration.toNanos(); for (String commandId : commandIds) { while (getStatus(commandId).getState() != COMPLETED) { Thread.sleep(100); if (deadline < System.nanoTime()) { return false; } } } } } return true; }
Source:
<code>public void perform(final UiController uiController, final View view) { Screenshot.snap(view) <START> .record(); <END> }</code><technical_language>record line please</technical_language>

Target:
public void perform(final UiController uiController, final View view) { Screenshot.snap(view).setName(name).record(); }
Source:
<code>public void setup() { doReturn(dbFacade).when(cmd).getDbFacade(); when(dbFacade.getStoragePoolDao()).thenReturn(storagePoolDAO); when(dbFacade.getStorageDomainDao()).thenReturn(storageDomainDAO); <START> when(cmd.getTransactionSupport()).thenReturn(transactionSupport); <END> }</code><technical_language>This code repeat in command test... please a util do this</technical_language>

Target:
public void setup() { CommandMocks.mockDbFacade(cmd, dbFacade); when(dbFacade.getStoragePoolDao()).thenReturn(storagePoolDAO); when(dbFacade.getStorageDomainDao()).thenReturn(storageDomainDAO); CommandMocks.mockTxSupport(cmd); }
Source:
<code>String getSubscribingDeviceId() { String subscribingDeviceId = DEFAULT_DEVICE_ID_TOPIC; final Object deviceId = this.properties.get(CONF_DEVICE_ID_TOPIC); <START> if ((this.properties != null) && this.properties.containsKey(CONF_APP_TOPIC) && (deviceId != null) <END> && (deviceId instanceof String)) { subscribingDeviceId = String.valueOf(deviceId); } return subscribingDeviceId; }</code><technical_language>CONF_DEVICE_ID_TOPIC</technical_language>

Target:
String getSubscribingDeviceId() { String subscribingDeviceId = DEFAULT_DEVICE_ID_TOPIC; final Object deviceId = this.properties.get(CONF_DEVICE_ID_TOPIC); if (deviceId != null && deviceId instanceof String) { subscribingDeviceId = String.valueOf(deviceId); } return subscribingDeviceId; }
Source:
<code>public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) { title = null; if (view instanceof WebView) { WebView.HitTestResult result = ((WebView) view).getHitTestResult(); <START> String foo = result.getExtra(); Log.d("foo", foo); <END> if (result.getType() == WebView.HitTestResult.SRC_ANCHOR_TYPE) { Uri uri = Uri.parse(result.getExtra()); if (isValidPageLink(uri)) { title = ((WebViewContextMenuListener) contextMenuListener).getWikiSite() .titleForInternalLink(uri.getPath()); } else if (OfflineManager.hasCompilation() && isValidOfflinePageLink(uri)) { title = ((WebViewContextMenuListener) contextMenuListener).getWikiSite() .titleForInternalLink(uri.getLastPathSegment().replace(".html", "")); } } } else if (view instanceof ListView) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; title = ((ListViewContextMenuListener) contextMenuListener) .getTitleForListPosition(info.position); } if (title != null && !title.isSpecial()) { hideSoftKeyboard(view); entry = new HistoryEntry(title, historySource); new MenuInflater(view.getContext()).inflate(R.menu.menu_page_long_press, menu); menu.setHeaderTitle(title.getDisplayText()); for (int i = 0; i < menu.size(); i++) { menu.getItem(i).setOnMenuItemClickListener(this); } } }</code><technical_language>leftover debug logging</technical_language>

Target:
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) { title = null; if (view instanceof WebView) { WebView.HitTestResult result = ((WebView) view).getHitTestResult(); if (result.getType() == WebView.HitTestResult.SRC_ANCHOR_TYPE) { Uri uri = Uri.parse(result.getExtra()); if (isValidPageLink(uri)) { title = ((WebViewContextMenuListener) contextMenuListener).getWikiSite() .titleForInternalLink(uri.getPath()); } else if (OfflineManager.hasCompilation() && isValidOfflinePageLink(uri)) { title = ((WebViewContextMenuListener) contextMenuListener).getWikiSite() .titleForInternalLink(uri.getLastPathSegment().replace(".html", "")); } } } else if (view instanceof ListView) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; title = ((ListViewContextMenuListener) contextMenuListener) .getTitleForListPosition(info.position); } if (title != null && !title.isSpecial()) { hideSoftKeyboard(view); entry = new HistoryEntry(title, historySource); new MenuInflater(view.getContext()).inflate(R.menu.menu_page_long_press, menu); menu.setHeaderTitle(title.getDisplayText()); for (int i = 0; i < menu.size(); i++) { menu.getItem(i).setOnMenuItemClickListener(this); } } }
Source:
<code>private CompletionStage<Void> doNotifyCreated(K key, V value, Metadata metadata, boolean pre, InvocationContext ctx, FlagAffectedCommand command) { if (clusteringDependentLogic.running().commitType(command, ctx, extractSegment(command, key), false).isLocal() && (command == null || !command.hasAnyFlag(FlagBitSets.PUT_FOR_STATE_TRANSFER))) { EventImpl<K, V> e = EventImpl.createEvent(cache.wired(), CACHE_ENTRY_CREATED); boolean isLocalNodePrimaryOwner = isLocalNodePrimaryOwner(key); <START> Object eventIdentifier = ctx.isInTxScope() ? null : Thread.currentThread(); <END> try { AggregateCompletionStage<Void> aggregateCompletionStage = null; for (CacheEntryListenerInvocation<K, V> listener : cacheEntryCreatedListeners) { configureEvent(listener, e, key, value, metadata, pre, ctx, command, null, null); aggregateCompletionStage = composeStageIfNeeded(aggregateCompletionStage, listener.invoke(new EventWrapper<>(key, e), isLocalNodePrimaryOwner)); } if (eventIdentifier != null) { return sendEvents(eventIdentifier, aggregateCompletionStage); } else if (aggregateCompletionStage != null) { return aggregateCompletionStage.freeze(); } } finally { if (eventIdentifier != null) { eventManager.dropEvents(eventIdentifier); } } } return CompletableFutures.completedNull(); }</code><technical_language>name, identifier of a single event. batchIdentifier is better? in other methods, in ClusterEventManager implementations</technical_language>

Target:
private CompletionStage<Void> doNotifyCreated(K key, V value, Metadata metadata, boolean pre, InvocationContext ctx, FlagAffectedCommand command) { if (clusteringDependentLogic.running().commitType(command, ctx, extractSegment(command, key), false).isLocal() && (command == null || !command.hasAnyFlag(FlagBitSets.PUT_FOR_STATE_TRANSFER))) { EventImpl<K, V> e = EventImpl.createEvent(cache.wired(), CACHE_ENTRY_CREATED); boolean isLocalNodePrimaryOwner = isLocalNodePrimaryOwner(key); Object batchIdentifier = ctx.isInTxScope() ? null : Thread.currentThread(); try { AggregateCompletionStage<Void> aggregateCompletionStage = null; for (CacheEntryListenerInvocation<K, V> listener : cacheEntryCreatedListeners) { configureEvent(listener, e, key, value, metadata, pre, ctx, command, null, null); aggregateCompletionStage = composeStageIfNeeded(aggregateCompletionStage, listener.invoke(new EventWrapper<>(key, e), isLocalNodePrimaryOwner)); } if (batchIdentifier != null) { return sendEvents(batchIdentifier, aggregateCompletionStage); } else if (aggregateCompletionStage != null) { return aggregateCompletionStage.freeze(); } } finally { if (batchIdentifier != null) { eventManager.dropEvents(batchIdentifier); } } } return CompletableFutures.completedNull(); }
Source:
<code>public void testRemoveCache() { ConfigurationBuilder cb = TestCacheManagerFactory.getDefaultCacheConfiguration(false); createCacheStoreConfig(cb.persistence(), true); EmbeddedCacheManager local = TestCacheManagerFactory.createCacheManager(cb); try { final String cacheName = "to-be-removed"; Cache<Integer, String> cache = local.getCache(cacheName); assertTrue(local.isRunning(cacheName)); <START> cache.put(1, "v1"); <END> assertEquals("v1", cache.get(1)); local.removeCache(cacheName); assertFalse(local.isRunning(cacheName)); } finally { TestingUtil.killCacheManagers(local); } }</code><technical_language>this test is failing in JpaStoreFunctionalTest. I String in keys wrap wrap("k1", "v1")</technical_language>

Target:
public void testRemoveCache() { ConfigurationBuilder cb = TestCacheManagerFactory.getDefaultCacheConfiguration(false); createCacheStoreConfig(cb.persistence(), true); EmbeddedCacheManager local = TestCacheManagerFactory.createCacheManager(cb); try { final String cacheName = "to-be-removed"; Cache<String, Object> cache = local.getCache(cacheName); assertTrue(local.isRunning(cacheName)); cache.put("1", wrap("1", "v1")); assertCacheEntry(cache, "1", "v1", -1, -1); local.removeCache(cacheName); assertFalse(local.isRunning(cacheName)); } finally { TestingUtil.killCacheManagers(local); } }
Source:
<code>public boolean isSubtypeOfBound(JavaType type) { switch (boundType) { case SUPER: <START> if(bound.isTagged(TYPEVAR) && !type.isTagged(TYPEVAR) && bound != type) { <END> return false; } return bound.isSubtypeOf(type); case EXTENDS: if(bound.isTagged(TYPEVAR) && !type.isTagged(TYPEVAR) && bound != type) { return false; } return type.isSubtypeOf(bound); case UNBOUNDED: default: return true; } }</code><technical_language>3rd Boolean expression is useless, if bound is a TypeVar type is not, necessarily different. Moreover, this if statement extracted a method, in order a single return statement boundType. remark is valid for next case</technical_language>

Target:
public boolean isSubtypeOfBound(JavaType type) { switch (boundType) { case SUPER: return !boundIsTypeVarAndNotType(type) && bound.isSubtypeOf(type); case EXTENDS: return !boundIsTypeVarAndNotType(type) && type.isSubtypeOf(bound); case UNBOUNDED: default: return true; } }
Source:
<code>protected void map(FilesFacade ff, LPSZ name, long size) { this.size = size; if (size > 0) { this.page = ff.mmap(fd, size, 0, Files.MAP_RO); if (page == FilesFacade.MAP_FAILED) { close(); <START> throw CairoException.instance(ff.errno()).put("Cannot mmap ").put(name).put(" [size=").put(size).put(", fd=").put(fd).put(']'); <END> } this.absolutePointer = page; } else { this.page = -1; this.absolutePointer = -1; } LOG.info().$("open ").$(name).$(" [fd=").$(fd).$(", pageSize=").$(size).$(", size=").$(this.size).$(']').$(); }</code><technical_language>exception "could not" "cannot"</technical_language>

Target:
protected void map(FilesFacade ff, LPSZ name, long size) { this.size = size; if (size > 0) { this.page = ff.mmap(fd, size, 0, Files.MAP_RO); if (page == FilesFacade.MAP_FAILED) { close(); throw CairoException.instance(ff.errno()).put("Could not mmap ").put(name).put(" [size=").put(size).put(", fd=").put(fd).put(']'); } this.absolutePointer = page; } else { this.page = -1; this.absolutePointer = -1; } LOG.info().$("open ").$(name).$(" [fd=").$(fd).$(", pageSize=").$(size).$(", size=").$(this.size).$(']').$(); }
Source:
<code><START> public JPACommit getEndCommit() { <END> return commitB; }</code><technical_language>e.g. names instead of a b :)</technical_language>

Target:
public JPACommit getEndCommit() { return endCommit; }
Source:
<code>public void initMapGenRTG(InitMapGenEvent event) { Logger.debug("event type = %s", event.getType().toString()); Logger.debug("event originalGen = %s", event.getOriginalGen().toString()); if (event.getType() == InitMapGenEvent.EventType.SCATTERED_FEATURE) { event.setNewGen(new MapGenScatteredFeatureRTG()); } else if (event.getType() == InitMapGenEvent.EventType.VILLAGE) { if (Mods.RTG.config.ENABLE_VILLAGE_MODIFICATIONS.get()) { event.setNewGen(new MapGenVillageRTG()); } } else if (event.getType() == InitMapGenEvent.EventType.CAVE) { if (Mods.RTG.config.ENABLE_CAVE_MODIFICATIONS.get()) { event.setNewGen(new MapGenCavesRTG()); } } else if (event.getType() == InitMapGenEvent.EventType.RAVINE) { if (Mods.RTG.config.ENABLE_RAVINE_MODIFICATIONS.get()) { event.setNewGen(new MapGenRavineRTG()); } } else if (event.getType() == InitMapGenEvent.EventType.OCEAN_MONUMENT) { event.setNewGen(new StructureOceanMonumentRTG()); <START> } <END> Logger.debug("event newGen = %s", event.getNewGen().toString()); }</code><technical_language>This organised more efficient a switch statement I in 1.7.10: [EventManagerRTG.java#L148-L173](<LINK_0> Note: missing cases added left blank for future reference if need do other InitMapGenEvent events</technical_language>

Target:
public void initMapGenRTG(InitMapGenEvent event) { Logger.debug("event type = %s", event.getType().toString()); Logger.debug("event originalGen = %s", event.getOriginalGen().toString()); switch (event.getType()) { case SCATTERED_FEATURE: event.setNewGen(new MapGenScatteredFeatureRTG()); break; case VILLAGE: if (Mods.RTG.config.ENABLE_VILLAGE_MODIFICATIONS.get()) { event.setNewGen(new MapGenVillageRTG()); } break; case CAVE: if (Mods.RTG.config.ENABLE_CAVE_MODIFICATIONS.get()) { event.setNewGen(new MapGenCavesRTG()); } break; case RAVINE: if (Mods.RTG.config.ENABLE_RAVINE_MODIFICATIONS.get()) { event.setNewGen(new MapGenRavineRTG()); } break; case OCEAN_MONUMENT: event.setNewGen(new StructureOceanMonumentRTG()); break; default: break; } Logger.debug("event newGen = %s", event.getNewGen().toString()); }
Source:
<code>private FormItem createUploadItemDisabled(PluginDescriptor plugin, PluginDescriptor.Field pluginField) { <START> FormItem chooseCredentialsFormItem; <END> chooseCredentialsFormItem = new UploadItem(plugin.getPluginName() + pluginField.getName(), ""); chooseCredentialsFormItem.disable(); return chooseCredentialsFormItem; }</code><technical_language>declaring empty after</technical_language>

Target:
private FormItem createUploadItemDisabled(PluginDescriptor plugin, PluginDescriptor.Field pluginField) { FormItem chooseCredentialsFormItem = new UploadItem(plugin.getPluginName() + pluginField.getName(), ""); chooseCredentialsFormItem.disable(); return chooseCredentialsFormItem; }