auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private DistStageAck executeStreamTask(Statistics stats) { long durationNanos; long start; configureStreamTask(); StreamStageAck ack = new StreamStageAck(slaveState); try { start = TimeService.nanoTime(); streamTaskResult = function.apply(streamable.stream(cacheName)); durationNanos = TimeService.nanoTime() - start; stats.registerRequest(durationNanos, Streamable.STREAMABLE); log.info("Stream task completed in " + Utils.prettyPrintTime(durationNanos, TimeUnit.NANOSECONDS)); long resultCount = function.getResultCount(); log.info("Result map contains '" + resultCount + "' keys."); ack.setNumberOfResultKeys(resultCount); ack.setStats(stats); <START> String printableResult = function.getPrintableResult(); <END> if (printResult && printableResult != null) { log.info("Stream task result:"); log.info(printableResult); } } catch (Exception e) { ack.error("executeStreamTask() threw an exception", e); log.error("executeStreamTask() returned an exception", e); } log.infof("%d nodes were used. %d entries on this node", clustered.getMembers().size(), cacheInformation .getCache(cacheName).getLocallyStoredSize()); log.info("--------------------"); return ack; }</code><technical_language>function.getPrintableResult() invocation skipped if printResult is false</technical_language>

Target:
private DistStageAck executeStreamTask(Statistics stats) { long durationNanos; long start; configureStreamTask(); StreamStageAck ack = new StreamStageAck(slaveState); start = TimeService.nanoTime(); try { if (parallelStream) { streamTaskResult = function.apply(streamable.parallelStream(cacheName)); } else { streamTaskResult = function.apply(streamable.stream(cacheName)); } durationNanos = TimeService.nanoTime() - start; stats.registerRequest(durationNanos, Streamable.STREAMABLE); log.info("Stream task completed in " + Utils.prettyPrintTime(durationNanos, TimeUnit.NANOSECONDS)); long resultCount = function.getResultCount(); log.info("Result map contains '" + resultCount + "' keys."); ack.setNumberOfResultKeys(resultCount); ack.setStats(stats); if (printResult) { String printableResult = function.getPrintableResult(); if (printableResult != null) { log.info("Stream task result:" + printableResult); } } } catch (Exception e) { durationNanos = TimeService.nanoTime() - start; stats.registerError(durationNanos, Streamable.STREAMABLE); ack.error("executeStreamTask() threw an exception", e); log.error("executeStreamTask() returned an exception", e); } if (clustered != null && cacheInformation != null){ log.infof("%d nodes were used. %d entries on this node", clustered.getMembers().size(), cacheInformation .getCache(cacheName).getLocallyStoredSize()); } log.info("--------------------"); return ack; }
Source:
<code>private static String getGerritHost(String canonicalWebUrl) { String host = null; if (canonicalWebUrl != null) { try { host = new URL(canonicalWebUrl).getHost(); } catch (MalformedURLException e) { } } if (host == null) { host = SystemReader.getInstance().getHostname(); } <START> return trimTrailingSlashes(host); <END> }</code><technical_language>host, especially if extracted a URL object, a trailing slash</technical_language>

Target:
private static String getGerritHost(String canonicalWebUrl) { String host; if (canonicalWebUrl != null) { try { host = new URL(canonicalWebUrl).getHost(); } catch (MalformedURLException e) { host = SystemReader.getInstance().getHostname(); } } else { host = SystemReader.getInstance().getHostname(); } return host; }
Source:
<code>public void testIndivisibleMiniBatchSize() { final Random generator = new Random(); final int numTotalMiniBatches = 5; final int numRemainderForLastMiniBatch = (MINI_BATCH_SIZE - 2); final int numTotalInstances = MINI_BATCH_SIZE * (numTotalMiniBatches - 1) + numRemainderForLastMiniBatch; for (int i = 0; i < numTotalInstances; i++) { final int value = generator.nextInt(); values.put(i, value); } trainingDataProvider.prepareDataForEpoch(); assertTrue(numTotalInstances % MINI_BATCH_SIZE != 0); <START> int miniBatchCount = 0; <END> Map<Integer, Integer> trainingData = trainingDataProvider.getNextTrainingData(); while (!trainingData.isEmpty()) { miniBatchCount++; for (final Integer key : trainingData.keySet()) { assertEquals(values.get(key), trainingData.get(key)); } if (miniBatchCount < numTotalMiniBatches) { assertEquals("Should process MINI_BATCH_SIZE instances", MINI_BATCH_SIZE, trainingData.size()); } else { assertEquals("The last mini-batch should process remaining instances", numRemainderForLastMiniBatch, trainingData.size()); } trainingData = trainingDataProvider.getNextTrainingData(); } assertEquals("The total number of mini-batches is different from expectation", numTotalMiniBatches, miniBatchCount); }</code><technical_language>miniBatchIdx miniBatchCount</technical_language>

Target:
public void testIndivisibleMiniBatchSize() { final int numTotalInstances = 23; createMockTrainingData(numTotalInstances); trainingDataProvider.prepareDataForEpoch(); testGetNextTrainingData(numTotalInstances); assertTrue("Data should be exhausted", trainingDataProvider.getNextTrainingData().isEmpty()); trainingDataProvider.prepareDataForEpoch(); testGetNextTrainingData(numTotalInstances); assertTrue("Data should be exhausted", trainingDataProvider.getNextTrainingData().isEmpty()); }
Source:
<code>public void testFullByonLocationDescription() { String templateUrl = getClasspathUrlForResource("templates/full-location.byon.tosca.yaml"); EntitySpec<? extends Application> app = transformer.createApplicationSpec( new ResourceUtils(mgmt).getResourceAsString(templateUrl)); assertNotNull(app); assertEquals(app.getChildren().size(), 1); EntitySpec<VanillaSoftwareProcess> vanillaEntity = (EntitySpec<VanillaSoftwareProcess>) Iterables.getOnlyElement(app.getChildren()); assertEquals(vanillaEntity.getLocations().size(), 1); assertTrue(Iterables.getOnlyElement(vanillaEntity.getLocations()) instanceof FixedListMachineProvisioningLocation); FixedListMachineProvisioningLocation location = (FixedListMachineProvisioningLocation) Iterables .getOnlyElement(vanillaEntity.getLocations()); Map<String, Object> configByon = location.getLocalConfigBag().getAllConfig(); assertEquals(configByon.get("user"), "brooklyn"); assertEquals(configByon.get("provider"), "byon"); <START> assertEquals(configByon.get("provider"), "byon"); <END> assertEquals(((List)configByon.get("machines")).size(), 1); List<SshMachineLocation> machines = (List<SshMachineLocation>) configByon.get("machines"); assertEquals(machines.get(0).getAddress().getHostAddress(), "192.168.0.18"); }</code><technical_language>Duplicate assertion</technical_language>

Target:
public void testFullByonLocationDescription() { String templateUrl = getClasspathUrlForResource("templates/full-location.byon.tosca.yaml"); EntitySpec<? extends Application> app = transformer.createApplicationSpec( new ResourceUtils(mgmt).getResourceAsString(templateUrl)); assertNotNull(app); assertEquals(app.getChildren().size(), 1); EntitySpec<VanillaSoftwareProcess> vanillaEntity = (EntitySpec<VanillaSoftwareProcess>) Iterables.getOnlyElement(app.getChildren()); assertEquals(vanillaEntity.getLocations().size(), 1); assertTrue(Iterables.getOnlyElement(vanillaEntity.getLocations()) instanceof FixedListMachineProvisioningLocation); FixedListMachineProvisioningLocation location = (FixedListMachineProvisioningLocation) Iterables .getOnlyElement(vanillaEntity.getLocations()); Map<String, Object> configByon = location.getLocalConfigBag().getAllConfig(); assertEquals(configByon.get("user"), "brooklyn"); assertEquals(configByon.get("provider"), "byon"); assertTrue(configByon.get("machines") instanceof Collection); assertEquals(((Collection)configByon.get("machines")).size(), 1); List<SshMachineLocation> machines = (List<SshMachineLocation>) configByon.get("machines"); assertEquals(machines.get(0).getAddress().getHostAddress(), "192.168.0.18"); }
Source:
<code>public ExpirationManager getExpirationManager() { <START> return this.expirationManager; <END> }</code><technical_language>Superfluous this</technical_language>

Target:
public ExpirationManager getExpirationManager() { return expirationManager; }
Source:
<code>public void in(String in) { <START> this.latch.countDown(); <END> if ("nackIt".equals(in)) { throw new RuntimeException("testing auto nack"); } else { this.received = in; } }</code><technical_language>I this finally block, this.received = in;. race condition</technical_language>

Target:
public void in(String in) { try { if ("nackIt".equals(in)) { throw new RuntimeException("testing auto nack"); } else { this.received = in; } } finally { this.latch.countDown(); } }
Source:
<code>public void activateHoverHelp(final Control control) { control.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { if (fTipShell != null && !fTipShell.isDisposed()) { fTipShell.dispose(); } } }); control.addMouseMoveListener(e -> { if (fTipShell != null && !fTipShell.isDisposed()) { fTipShell.dispose(); } }); control.addMouseTrackListener(new MouseTrackAdapter() { @Override public void mouseExit(MouseEvent e) { Point pt = control.toDisplay(e.x, e.y); if (fTipShell != null && !fTipShell.isDisposed() && !fTipShell.getBounds().contains(pt)) { fTipShell.dispose(); } } @Override public void mouseHover(MouseEvent event) { if ((event.stateMask & SWT.BUTTON_MASK) != 0) { return; } Point pt = new Point(event.x, event.y); Control timeGraphControl = (Control) event.widget; createTooltipShell(timeGraphControl.getShell()); for (Control child : fTipComposite.getChildren()) { child.dispose(); } <START> fill(control, event, pt); <END> fTipShell.pack(); Point tipPosition = control.toDisplay(pt); fTipShell.pack(); setHoverLocation(fTipShell, tipPosition); if (fTipComposite.getChildren().length > 0) { fTipShell.setVisible(true); } } }); }</code><technical_language>early return if children</technical_language>

Target:
public void activateHoverHelp(final Control control) { control.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { if (fTipShell != null && !fTipShell.isDisposed()) { fTipShell.dispose(); } } }); control.addMouseMoveListener(e -> { if (fTipShell != null && !fTipShell.isDisposed()) { fTipShell.dispose(); } }); control.addMouseTrackListener(new MouseTrackAdapter() { @Override public void mouseExit(MouseEvent e) { Point pt = control.toDisplay(e.x, e.y); if (fTipShell != null && !fTipShell.isDisposed() && !fTipShell.getBounds().contains(pt)) { fTipShell.dispose(); } } @Override public void mouseHover(MouseEvent event) { if ((event.stateMask & SWT.BUTTON_MASK) != 0) { return; } Point pt = new Point(event.x, event.y); Control timeGraphControl = (Control) event.widget; createTooltipShell(timeGraphControl.getShell()); for (Control child : fTipComposite.getChildren()) { child.dispose(); } fill(control, event, pt); if (fTipComposite.getChildren().length == 0) { return; } fTipShell.pack(); Point tipPosition = control.toDisplay(pt); setHoverLocation(fTipShell, tipPosition); fTipShell.setVisible(true); } }); }
Source:
<code>public boolean start() throws IOException { connection = source.connect(container); result = new Result(); Schema schema = rowProperties.schemaFlow.schema.getValue(); if (AvroUtils.isIncludeAllFields(schema)) { schema = source.getEndpointSchema(container, rowProperties.table.tableName.getValue()); <START> } <END> factory.setSchema(schema); try { if (rowProperties.usePreparedStatement.getValue()) { statement = connection.prepareStatement(rowProperties.query.getValue()); PreparedStatement pstmt = (PreparedStatement) statement; SnowflakePreparedStatementUtils.fillPreparedStatement(pstmt, rowProperties.preparedStatementTable); pstmt.execute(); rs = pstmt.getResultSet(); pstmt.clearParameters(); } else { statement = connection.createStatement(); rs = statement.executeQuery(rowProperties.query.getValue()); } } catch (SQLException e) { throw new IOException(e); } return advance(); }</code><technical_language>I suggest add methods for retrieving property in Source (or in RowProperties) class: Schema getRuntimeSchema(RuntimeContainer container) { Schema schema = rowProperties.schemaFlow.schema.getValue(); if (AvroUtils.isIncludeAllFields(schema)) { schema = getEndpointSchema(container, rowProperties.table.tableName.getValue()); } } String getPreparedStatementQuery() { return rowProperties.query.getValue(); }</technical_language>

Target:
public boolean start() throws IOException { connection = source.createConnection(container); result = new Result(); Schema schema = source.getRuntimeSchema(container); converter.setSchema(schema); try { if (source.usePreparedStatement()) { statement = connection.prepareStatement(source.getQuery()); PreparedStatement pstmt = (PreparedStatement) statement; SnowflakePreparedStatementUtils.fillPreparedStatement(pstmt, source.getRowProperties().preparedStatementTable); pstmt.execute(); rs = pstmt.getResultSet(); pstmt.clearParameters(); } else { statement = connection.createStatement(); rs = statement.executeQuery(source.getQuery()); } } catch (SQLException e) { throw new IOException(e); } return advance(); }
Source:
<code>public String createStyledText() { if (!StringUtility.hasText(getText())) { setText("<!-- -->"); } String styledText = getText().trim(); boolean originalTextIsHTML = false; if (HTML_PATTERN.matcher(styledText).matches()) { styledText = StringUtility.getTag(styledText, "html"); originalTextIsHTML = true; } if (BODY_PATTERN.matcher(styledText).matches()) { styledText = StringUtility.getTag(styledText, "body"); } <START> String align = "left"; <END> String valign = "top"; if (getHorizontalAlignment() == SwingConstants.HORIZONTAL) { align = "center"; } else if (getHorizontalAlignment() == SwingConstants.RIGHT) { align = "right"; } if (getVerticalAlignment() == SwingConstants.CENTER) { valign = "middle"; } else if (getVerticalAlignment() == SwingConstants.BOTTOM) { valign = "bottom"; } String wrapText = "normal"; if (!isTextWrap()) { wrapText = "nowrap"; } String bodyStyle = ""; if (StringUtility.hasText(ColorUtility.createStringFromColor(getBackgroundColor()))) { bodyStyle += "background-color: " + ColorUtility.createStringFromColor(getBackgroundColor()) + ";"; } if (StringUtility.hasText(ColorUtility.createStringFromColor(getForegroundColor()))) { bodyStyle += "color: " + ColorUtility.createStringFromColor(getForegroundColor()) + ";"; } if (!originalTextIsHTML) { styledText = StringUtility.replaceNewLines(styledText, "<br>"); } styledText = "<html><body style=\"" + bodyStyle + "\"><div align=\"" + align + "\"><table cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"" + valign + "\" height=\"" + getHeight() + "px\" style=\"white-space:" + wrapText + ";\">" + styledText + "</td></tr></table></div></body></html>"; return styledText; }</code><technical_language>please break this method smaller methods more readable. E.g.: private String getValign() { if (getVerticalAlignment() == SwingConstants.CENTER) { return "middle"; } else if (getVerticalAlignment() == SwingConstants.BOTTOM) { return "bottom"; } return "top"; }</technical_language>

Target:
public String createStyledText() { if (!StringUtility.hasText(getText())) { setText("<!-- -->"); } String styledText = getText().trim(); boolean originalTextIsHTML = false; if (HTML_PATTERN.matcher(styledText).matches()) { styledText = StringUtility.getTag(styledText, "html"); originalTextIsHTML = true; } if (BODY_PATTERN.matcher(styledText).matches()) { styledText = StringUtility.getTag(styledText, "body"); } if (!originalTextIsHTML) { styledText = StringUtility.replaceNewLines(styledText, "<br>"); } styledText = "<html><body style=\"" + getBodyStyle() + "\"><div align=\"" + getAlign() + "\"><table cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"" + getValign() + "\" height=\"" + getHeight() + "px\" style=\"white-space:" + getWrapText() + ";\">" + styledText + "</td></tr></table></div></body></html>"; return styledText; }
Source:
<code><START> public static Container fromJson(JSONObject json, short parentAccountId) throws JSONException { <END> return new Container(json, parentAccountId); }</code><technical_language>this need public</technical_language>

Target:
static Container fromJson(JSONObject json, short parentAccountId) throws JSONException { return new Container(json, parentAccountId); }
Source:
<code>private static <T> Publisher<Message<T>> adaptSubscribableChannelToPublisher(SubscribableChannel inputChannel) { <START> EmitterProcessor<Message<T>> publisher = EmitterProcessor.create(1); @SuppressWarnings("unchecked") MessageHandler messageHandler = (message) -> publisher.onNext((Message<T>) message); return publisher .doOnSubscribe((sub) -> inputChannel.subscribe(messageHandler)) .doOnCancel(() -> inputChannel.unsubscribe(messageHandler)); <END> }</code><technical_language>Consider Flux.defer, return a cold Publisher subscribed multiple times</technical_language>

Target:
private static <T> Publisher<Message<T>> adaptSubscribableChannelToPublisher(SubscribableChannel inputChannel) { return Flux.defer(() -> { EmitterProcessor<Message<T>> publisher = EmitterProcessor.create(1); @SuppressWarnings("unchecked") MessageHandler messageHandler = (message) -> publisher.onNext((Message<T>) message); inputChannel.subscribe(messageHandler); return publisher .doOnCancel(() -> inputChannel.unsubscribe(messageHandler)); }); }
Source:
<code>private List<YamlPreference> jsonToYamlPreference(String jsonStr) { ArrayList yamlPreferences = new ArrayList<YamlPreference>(); JsonObject parsedJson = Json.parse(jsonStr); for (String glob : parsedJson.keys()) { try { JsonArray jsonArray = parsedJson.getArray(glob); for (int arrNum = 0; arrNum < jsonArray.length(); arrNum++) { YamlPreference newYamlPref = new YamlPreference(jsonArray.getString(arrNum), glob); yamlPreferences.add(newYamlPref); } } catch (Exception e) { <START> System.out.println(e); <END> } } return yamlPreferences; }</code><technical_language>logger pls</technical_language>

Target:
private List<YamlPreference> jsonToYamlPreference(String jsonStr) { ArrayList yamlPreferences = new ArrayList<YamlPreference>(); JsonObject parsedJson = Json.parse(jsonStr); for (String glob : parsedJson.keys()) { try { JsonArray jsonArray = parsedJson.getArray(glob); for (int arrNum = 0; arrNum < jsonArray.length(); arrNum++) { YamlPreference newYamlPref = new YamlPreference(jsonArray.getString(arrNum), glob); yamlPreferences.add(newYamlPref); } } catch (Exception e) { LOG.debug(e.getMessage(), e); } } return yamlPreferences; }
Source:
<code>public MqttConnectOptions getConnectionInfo() { MqttConnectOptions options = this.clientFactory.getConnectionOptions(); if (options.getServerURIs() == null && getUrl() != null) { options = MqttUtils.cloneConnectOptions(options); <START> options.setServerURIs(new String[] { getUrl() }); <END> } return options; }</code><technical_language>extract local variable for URL avoid noise Sonar defer NPE calling method times</technical_language>

Target:
public MqttConnectOptions getConnectionInfo() { MqttConnectOptions options = this.clientFactory.getConnectionOptions(); if (options.getServerURIs() == null) { String url = getUrl(); if (url != null) { options = MqttUtils.cloneConnectOptions(options); options.setServerURIs(new String[] { url }); } } return options; }
Source:
<code>public void dispose() { refreshable = false; <START> refreshTask.cancel(false); <END> }</code><technical_language>Please check if is null running cancel it</technical_language>

Target:
public void dispose() { refreshable = false; if (!refreshTask.isCancelled()) { refreshTask.cancel(false); } }
Source:
<code>private String encryptDecryptPassword( String source, EncryptDirection direction ) { try { URI uri = new URI( source ); String userInfo = uri.getUserInfo(); if ( userInfo != null ) { String[] userInfoArray = userInfo.split( ":", 2 ); String password = userInfoArray[ 1 ]; String processedPassword = password; <START> if ( direction == EncryptDirection.ENCRYPT ) { <END> processedPassword = Encr.encryptPassword( password ); } else if ( direction == EncryptDirection.DECRYPT ) { processedPassword = Encr.decryptPassword( password ); } URI encryptedUri = new URI( uri.getScheme(), userInfoArray[ 0 ] + ":" + processedPassword, uri.getHost(), uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment() ); return encryptedUri.toString(); } } catch ( Exception e ) { return source; } return source; }</code><technical_language>replace this a switch w/ a default fallthrough throwing invalidparameterexception that</technical_language>

Target:
private String encryptDecryptPassword( String source, EncryptDirection direction ) { Validate.notNull( direction, "'direction' must not be null" ); try { URI uri = new URI( source ); String userInfo = uri.getUserInfo(); if ( userInfo != null ) { String[] userInfoArray = userInfo.split( ":", 2 ); String password = userInfoArray[ 1 ]; String processedPassword = password; switch ( direction ) { case ENCRYPT: processedPassword = Encr.encryptPassword( password ); break; case DECRYPT: processedPassword = Encr.decryptPassword( password ); break; default: throw new InvalidParameterException( "direction must be 'ENCODE' or 'DECODE'" ); } URI encryptedUri = new URI( uri.getScheme(), userInfoArray[ 0 ] + ":" + processedPassword, uri.getHost(), uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment() ); return encryptedUri.toString(); } } catch ( URISyntaxException e ) { return source; } return source; }
Source:
<code>public String toString() { StringBuilder sb = new StringBuilder(); sb.append("dr=").append(region.getDiskRegion().getId()); sb.append(" versionOnly=").append(this.versionOnly); if (this.versionOnly) { sb.append(" versionTag=").append(this.tag); } if (de != null) { sb.append(" key=").append(de.getKey()); } else { <START> sb.append(" <END CLEAR_REGION>"); <END> } return sb.toString(); }</code><technical_language>Accidental rename</technical_language>

Target:
public String toString() { StringBuilder sb = new StringBuilder(); sb.append("dr=").append(region.getDiskRegion().getId()); sb.append(" versionOnly=").append(this.versionOnly); if (this.versionOnly) { sb.append(" versionTag=").append(this.tag); } if (de != null) { sb.append(" key=").append(de.getKey()); } else { sb.append(" <END CLEAR>"); } return sb.toString(); }
Source:
<code>public IStyledString.IComposedStyledString getStyledText(Object object) { Conflict conflict = (Conflict)object; ComposedStyledString ret = new ComposedStyledString(); boolean unresolvedConflict = any(conflict.getDifferences(), EMFComparePredicates <START> .hasState(DifferenceState.UNRESOLVED)); <END> if (unresolvedConflict) { ret.append("> ", Style.DECORATIONS_STYLER); } if (conflict.getKind() == ConflictKind.PSEUDO) { ret.append(EMFCompareEditMessages.getString("pseudoconflict")); } else { ret.append(EMFCompareEditMessages.getString("conflict")); } if (unresolvedConflict) { final int differencesToMerge = size(Iterables.filter(conflict.getDifferences(), hasState(DifferenceState.UNRESOLVED))); ret.append( " [" + EMFCompareEditMessages.getString("unresolved", differencesToMerge, conflict.getDifferences().size()) + "]", Style.DECORATIONS_STYLER); } else { ret.append(" [" + EMFCompareEditMessages.getString("resolved") + "]", Style.DECORATIONS_STYLER); } return ret; }</code><technical_language>need size. Instead of iterating twice, compute size right start. This int unresolvedDiffCount = size(Iterables.filter(conflict.getDifferences (), hasState(DifferenceState.UNRESOLVED)));</technical_language>

Target:
public IStyledString.IComposedStyledString getStyledText(Object object) { Conflict conflict = (Conflict)object; ComposedStyledString ret = new ComposedStyledString(); int unresolvedDiffCount = size(Iterables.filter(conflict.getDifferences(), hasState(DifferenceState.UNRESOLVED))); if (unresolvedDiffCount > 0) { ret.append("> ", Style.DECORATIONS_STYLER); } if (conflict.getKind() == ConflictKind.PSEUDO) { ret.append(EMFCompareEditMessages.getString("pseudoconflict")); } else { ret.append(EMFCompareEditMessages.getString("conflict")); } if (unresolvedDiffCount > 0) { ret.append( " [" + EMFCompareEditMessages.getString("unresolved", unresolvedDiffCount, conflict.getDifferences().size()) + "]", Style.DECORATIONS_STYLER); } else { ret.append(" [" + EMFCompareEditMessages.getString("resolved") + "]", Style.DECORATIONS_STYLER); } return ret; }
Source:
<code>private void printUPNToResponse(HttpServletResponse response, String upn) { PrintWriter out; try { out = response.getWriter(); <START> out.print(upn); <END> } catch (IOException e) { log.error("IO Exception while writing user name: ", e); } }</code><technical_language>inlined response.getWriter().print(upn)</technical_language>

Target:
private void printUPNToResponse(HttpServletResponse response, String upn) { try { response.getWriter().print(upn); } catch (IOException e) { log.error("IO Exception while writing user name: ", e); } }
Source:
<code>public static void main(String[] args) { <START> Cli<Runnable> parser = Cli.<Runnable>builder("verifier") <END> .withDescription("Presto Verifier") .withDefaultCommand(Help.class) .withCommand(Help.class) .withCommand(GenerateReleaseNotesCommand.class) .build(); parser.parse(args).run(); }</code><technical_language>release</technical_language>

Target:
public static void main(String[] args) { Cli<Runnable> parser = Cli.<Runnable>builder("release") .withDescription("Presto Release") .withDefaultCommand(Help.class) .withCommand(Help.class) .withCommand(GenerateReleaseNotesCommand.class) .build(); parser.parse(args).run(); }
Source:
<code>public void testUpdateSchema() { DefaultTableSchemaUpdater schemaUpdater = new DefaultTableSchemaUpdater(); AssistantApp app = new AssistantApp(getInstrumentation().getTargetContext().getApplicationContext()); TestTable testTable = new TestTable(app, DATABASE_NAME, TABLE_NAME, TABLE_VERSION, Arrays.<com.sarality.app.datastore.Column> asList(Column.values()), null, null, schemaUpdater); TestOnlineHelper onlineHelper = new TestOnlineHelper(getInstrumentation().getTargetContext().getApplicationContext(), null, null, TABLE_VERSION); <START> SQLiteDatabase db = onlineHelper.getWritableDatabase(); <END> schemaUpdater.updateSchema(db, testTable); }</code><technical_language>I this is testing class. is creating a Mock class a MockDatabase juts making methods Table Database called. a unit test, worry called classes do expect do</technical_language>

Target:
public void testUpdateSchema() { DefaultTableSchemaUpdater schemaUpdater = new DefaultTableSchemaUpdater(); AssistantApp app = new AssistantApp(getInstrumentation().getTargetContext().getApplicationContext()); TestTable testTable = new TestTable(app, DATABASE_NAME, TABLE_NAME, TABLE_VERSION, Arrays.<com.sarality.app.datastore.Column> asList(Column.values()), null, null, schemaUpdater); TestOnlineHelper onlineHelper = new TestOnlineHelper(getInstrumentation().getTargetContext() .getApplicationContext(), null, null, TABLE_VERSION); SQLiteDatabase db = onlineHelper.getWritableDatabase(); schemaUpdater.updateSchema(db, testTable); assertEquals(true, TableExists(db)); }
Source:
<code>ContainerShutdownDescriptor(ImageConfiguration imageConfig, String containerId) { this.imageConfig = imageConfig; this.containerId = containerId; RunImageConfiguration runConfig = imageConfig.getRunConfiguration(); WaitConfiguration waitConfig = runConfig != null ? runConfig.getWaitConfiguration() : null; <START> this.shutdownGracePeriod = waitConfig != null ? waitConfig.shutdown() : 0; <END> this.killGracePeriod = waitConfig != null ? waitConfig.kill() : 0; if (waitConfig != null && waitConfig.getExec() != null) { this.preStop = waitConfig.getExec().getPreStop(); this.breakOnError = waitConfig.getExec().isBreakOnError(); } }</code><technical_language>getShutdown() null handling (to number of getters lower)</technical_language>

Target:
ContainerShutdownDescriptor(ImageConfiguration imageConfig, String containerId) { this.imageConfig = imageConfig; this.containerId = containerId; RunImageConfiguration runConfig = imageConfig.getRunConfiguration(); WaitConfiguration waitConfig = runConfig != null ? runConfig.getWaitConfiguration() : null; this.shutdownGracePeriod = waitConfig != null && waitConfig.getShutdown() != null ? waitConfig.getShutdown() : 0; this.killGracePeriod = waitConfig != null && waitConfig.getKill() != null ? waitConfig.getKill() : 0; if (waitConfig != null && waitConfig.getExec() != null) { this.preStop = waitConfig.getExec().getPreStop(); this.breakOnError = waitConfig.getExec().isBreakOnError(); } }
Source:
<code>public String toString() { <START> return "Response:" + request + "(" + (returnValue != null ? returnValue.getClass().getName() : exception != null ? exception.getClass().getName() : null) + ")"; <END> }</code><technical_language>generate a barely comprehensible output if request is null. sense do Response: [request=..., retval=...] so</technical_language>

Target:
public String toString() { return "Response" + (request != null ? ":" + request : "") + "(" + (returnValue != null ? returnValue.getClass().getName() : exception != null ? exception.getClass().getName() : null) + ")"; }
Source:
<code><START> public @NonNull String getName() { <END> return fTypeId; }</code><technical_language>super-method</technical_language>

Target:
public String getName() { return fTypeId; }
Source:
<code>protected void beforeExecute(Thread t, Runnable r) { Work work = WorkHolder.getWork(r); if (isShutdown()) { work.setWorkInstanceState(State.SCHEDULED); queuing.workReschedule(queueId, work); throw new RejectedExecutionException(queueId + " was shutdown, rescheduled " + work); } NuxeoBlockingQueue q = queuing.getQueue(queueId); if (!q.active) { work.setWorkInstanceState(State.SCHEDULED); queuing.workReschedule(queueId, work); <START> throw new RejectedExecutionException(queueId + " is not active, rescheduled " + work); <END> } work.setWorkInstanceState(State.RUNNING); queuing.workRunning(queueId, work); running.add(work); runningCount.inc(); }</code><technical_language>sounds infinite loop, I understand throw a rejected exception</technical_language>

Target:
protected void beforeExecute(Thread t, Runnable r) { Work work = WorkHolder.getWork(r); if (isShutdown()) { work.setWorkInstanceState(State.SCHEDULED); queuing.workReschedule(queueId, work); throw new RejectedExecutionException(queueId + " was shutdown, rescheduled " + work); } work.setWorkInstanceState(State.RUNNING); queuing.workRunning(queueId, work); running.add(work); runningCount.inc(); }
Source:
<code>protected String generateDestPath(VirtualMachineTO vmTO, VolumeVO srcVolume, Host destHost, StoragePoolVO destStoragePool, VolumeInfo destVolumeInfo) { DiskOfferingVO diskOffering = _diskOfferingDao.findById(srcVolume.getDiskOfferingId()); DiskProfile diskProfile = new DiskProfile(destVolumeInfo, diskOffering, HypervisorType.KVM); String templateUuid = getTemplateUuid(destVolumeInfo.getTemplateId()); CreateCommand rootImageProvisioningCommand = new CreateCommand(diskProfile, templateUuid, destStoragePool, true); Answer rootImageProvisioningAnswer = _agentMgr.easySend(destHost.getId(), rootImageProvisioningCommand); if (rootImageProvisioningAnswer == null) { throw new CloudRuntimeException(String.format("Migration with storage of vm [%s] failed while provisioning root image", vmTO.getName())); } if (!rootImageProvisioningAnswer.getResult()) { throw new CloudRuntimeException(String.format("Unable to modify target volume on the host [host id:%s, name:%s]", destHost.getId(), destHost.getName())); } String libvirtDestImgsPath = StringUtils.EMPTY; if (rootImageProvisioningAnswer instanceof CreateAnswer) { <START> libvirtDestImgsPath = ((CreateAnswer)rootImageProvisioningAnswer).getVolume().getName() + "/"; <END> } return libvirtDestImgsPath + destVolumeInfo.getUuid(); }</code><technical_language>use: <pre>File.separator</pre></technical_language>

Target:
protected String generateDestPath(VirtualMachineTO vmTO, VolumeVO srcVolume, Host destHost, StoragePoolVO destStoragePool, VolumeInfo destVolumeInfo) { DiskOfferingVO diskOffering = _diskOfferingDao.findById(srcVolume.getDiskOfferingId()); DiskProfile diskProfile = new DiskProfile(destVolumeInfo, diskOffering, HypervisorType.KVM); String templateUuid = getTemplateUuid(destVolumeInfo.getTemplateId()); CreateCommand rootImageProvisioningCommand = new CreateCommand(diskProfile, templateUuid, destStoragePool, true); Answer rootImageProvisioningAnswer = _agentMgr.easySend(destHost.getId(), rootImageProvisioningCommand); if (rootImageProvisioningAnswer == null) { throw new CloudRuntimeException(String.format("Migration with storage of vm [%s] failed while provisioning root image", vmTO.getName())); } if (!rootImageProvisioningAnswer.getResult()) { throw new CloudRuntimeException(String.format("Unable to modify target volume on the host [host id:%s, name:%s]", destHost.getId(), destHost.getName())); } String libvirtDestImgsPath = null; if (rootImageProvisioningAnswer instanceof CreateAnswer) { libvirtDestImgsPath = ((CreateAnswer)rootImageProvisioningAnswer).getVolume().getName(); } return new File(libvirtDestImgsPath, destVolumeInfo.getUuid()).getAbsolutePath(); }
Source:
<code>public static Package getBaseProtocol(Element anElement) { if (anElement != null) { IDefaultLanguage language = null; try { IDefaultLanguageService service = ServiceUtilsForEObject.getInstance().getService(IDefaultLanguageService.class, anElement); language = service.getActiveDefaultLanguage(anElement); } catch (ServiceException e) { Activator.log.error(e); } TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(anElement); Collaboration baseProtocol = <START> language.getBaseProtocol(domain.getResourceSet()); <END> if (baseProtocol != null) { return getProtocolContainer(baseProtocol); } } return null; }</code><technical_language>But, if a service registry, this null? logged exception, proceeded this point anyways. language null, way, NPE. I need a guard of this case of language turning out null (even if is a language service, default language)</technical_language>

Target:
public static Package getBaseProtocol(Element anElement) { if (anElement != null) { IDefaultLanguage language = null; try { IDefaultLanguageService service = ServiceUtilsForEObject.getInstance().getService(IDefaultLanguageService.class, anElement); language = service.getActiveDefaultLanguage(anElement); } catch (ServiceException e) { Activator.log.error(e); } if (language != null) { TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(anElement); Collaboration baseProtocol = language.getBaseProtocol(domain.getResourceSet()); if (baseProtocol != null) { return getProtocolContainer(baseProtocol); } } } return null; }
Source:
<code>protected void render0(FunctionRenderContext context) { <START> Object[] jsonPathElements = new Object[context.getArgumentsSize() - 1]; <END> for (int i = 1; i < context.getArgumentsSize(); i++) { try { jsonPathElements[i - 1] = Integer.parseInt(JpqlFunctionUtil.unquoteSingleQuotes(context.getArgument(i))); } catch (NumberFormatException e) { jsonPathElements[i - 1] = JpqlFunctionUtil.unquoteDoubleQuotes(JpqlFunctionUtil.unquoteSingleQuotes(context.getArgument(i))); } } String jsonPath = AbstractJsonGetFunction.toJsonPath(jsonPathElements, jsonPathElements.length, true); context.addChunk("json_unquote("); context.addChunk("nullif(json_extract("); context.addArgument(0); context.addChunk(",'"); context.addChunk(jsonPath); context.addChunk("')"); context.addChunk(",cast('null' as json)))"); }</code><technical_language>for JSON_SET. A utility method accepts FunctionRenderContext context, int offset more appropriate</technical_language>

Target:
protected void render0(FunctionRenderContext context) { List<Object> jsonPathElements = AbstractJsonGetFunction.retrieveJsonPathElements(context, 1); String jsonPath = AbstractJsonGetFunction.toJsonPath(jsonPathElements, jsonPathElements.size(), true); context.addChunk("json_unquote("); context.addChunk("nullif(json_extract("); context.addArgument(0); context.addChunk(",'"); context.addChunk(jsonPath); context.addChunk("')"); context.addChunk(",cast('null' as json)))"); }
Source:
<code>protected void onResume() { super.onResume(); if (!initComplete) { loaderManager.initLoader(ID_BLOCKCHAIN_STATE_LOADER, null, blockchainStateLoaderCallbacks); initComplete = true; } else { loaderManager.restartLoader(ID_BLOCKCHAIN_STATE_LOADER, null, blockchainStateLoaderCallbacks); } <START> <END> handler.postDelayed(new Runnable() { @Override public void run() { getWalletApplication().startBlockchainService(true); } }, 1000); checkLowStorageAlert(); detectUserCountry(); showBackupWalletDialogIfNeeded(); showHideSecureAction(); }</code><technical_language>is this code in here</technical_language>

Target:
protected void onResume() { super.onResume(); handler.postDelayed(new Runnable() { @Override public void run() { getWalletApplication().startBlockchainService(true); } }, 1000); checkLowStorageAlert(); detectUserCountry(); showBackupWalletDialogIfNeeded(); showHideSecureAction(); }
Source:
<code>public List<Ref> call() throws GitAPIException { checkCallable(); <START> List<Ref> refList; <END> List<Ref> tags = new ArrayList<>(); try (RevWalk revWalk = new RevWalk(repo)) { refList = repo.getRefDatabase().getRefsByPrefix(Constants.R_TAGS); for (Ref ref : refList) { tags.add(ref); } } catch (IOException e) { throw new JGitInternalException(e.getMessage(), e); } Collections.sort(tags, new Comparator<Ref>() { @Override public int compare(Ref o1, Ref o2) { return o1.getName().compareTo(o2.getName()); } }); setCallable(false); return tags; }</code><technical_language>optional: narrow scope</technical_language>

Target:
public List<Ref> call() throws GitAPIException { checkCallable(); List<Ref> tags = new ArrayList<>(); try (RevWalk revWalk = new RevWalk(repo)) { List<Ref> refList = repo.getRefDatabase() .getRefsByPrefix(Constants.R_TAGS); for (Ref ref : refList) { tags.add(ref); } } catch (IOException e) { throw new JGitInternalException(e.getMessage(), e); } Collections.sort(tags, new Comparator<Ref>() { @Override public int compare(Ref o1, Ref o2) { return o1.getName().compareTo(o2.getName()); } }); setCallable(false); return tags; }
Source:
<code><START> public void query(final Query query, final int chunkSize, final Consumer<QueryResult> consumer) { <END> if (version().startsWith("0.") || version().startsWith("1.0")) { throw new UnsupportedOperationException("chunking not supported"); } Call<ResponseBody> call = null; if (query instanceof BoundParameterQuery) { BoundParameterQuery boundParameterQuery = (BoundParameterQuery) query; call = this.influxDBService.query(this.username, this.password, query.getDatabase(), query.getCommandWithUrlEncoded(), chunkSize, boundParameterQuery.getParameterJsonWithUrlEncoded()); } else { call = this.influxDBService.query(this.username, this.password, query.getDatabase(), query.getCommandWithUrlEncoded(), chunkSize); } call.enqueue(new Callback<ResponseBody>() { @Override public void onResponse(final Call<ResponseBody> call, final Response<ResponseBody> response) { try { if (response.isSuccessful()) { ResponseBody chunkedBody = response.body(); chunkProccesor.process(chunkedBody, consumer); } else { ResponseBody errorBody = response.errorBody(); if (errorBody != null) { throw new InfluxDBException(errorBody.string()); } } } catch (IOException e) { QueryResult queryResult = new QueryResult(); queryResult.setError(e.toString()); consumer.accept(queryResult); } } @Override public void onFailure(final Call<ResponseBody> call, final Throwable t) { throw new InfluxDBException(t); } }); }</code><technical_language>formatting</technical_language>

Target:
public void query(final Query query, final int chunkSize, final Consumer<QueryResult> consumer) { Call<ResponseBody> call = null; if (query instanceof BoundParameterQuery) { BoundParameterQuery boundParameterQuery = (BoundParameterQuery) query; call = this.influxDBService.query(this.username, this.password, query.getDatabase(), query.getCommandWithUrlEncoded(), chunkSize, boundParameterQuery.getParameterJsonWithUrlEncoded()); } else { call = this.influxDBService.query(this.username, this.password, query.getDatabase(), query.getCommandWithUrlEncoded(), chunkSize); } call.enqueue(new Callback<ResponseBody>() { @Override public void onResponse(final Call<ResponseBody> call, final Response<ResponseBody> response) { try { if (response.isSuccessful()) { ResponseBody chunkedBody = response.body(); chunkProccesor.process(chunkedBody, consumer); } else { ResponseBody errorBody = response.errorBody(); if (errorBody != null) { throw new InfluxDBException(errorBody.string()); } } } catch (IOException e) { QueryResult queryResult = new QueryResult(); queryResult.setError(e.toString()); consumer.accept(queryResult); } } @Override public void onFailure(final Call<ResponseBody> call, final Throwable t) { throw new InfluxDBException(t); } }); }
Source:
<code>public RMInitialState getRMInitialState() { <START> Map<String, RMNodeEvent> nodeEvents = new HashMap<>(this.allNodes.size()); <END> for (RMNode rmnode : this.allNodes.values()) { final RMNodeEvent nodeEvent = rmnode.createNodeEvent(); nodeEvents.put(nodeEvent.getNodeUrl(), nodeEvent); } Map<String, RMNodeSourceEvent> nodeSourcesList = new HashMap<>(this.deployedNodeSources.size()); for (NodeSource nodeSource : this.definedNodeSources.values()) { nodeSourcesList.put(nodeSource.getName(), new RMNodeSourceEvent(nodeSource.getName(), nodeSource.getDescription(), nodeSource.getAdministrator().getName(), nodeSource.getStatus().toString())); if (this.deployedNodeSources.containsKey(nodeSource.getName())) { for (RMDeployingNode node : nodeSource.getDeployingAndLostNodes()) { final RMNodeEvent nodeEvent = node.createNodeEvent(); nodeEvents.put(nodeEvent.getNodeUrl(), nodeEvent); } } } return new RMInitialState(nodeEvents, nodeSourcesList); }</code><technical_language>This getRMInitialState streams this: final Map<String, RMNodeEvent> nodeEvents = this.allNodes .values() .stream() .map(rmNode -> rmNode.createNodeEvent()) .collect(Collectors.toMap(event -> event.getNodeUrl(), event -> event));</technical_language>

Target:
public RMInitialState getRMInitialState() { final Map<String, RMNodeEvent> nodeEvents = this.allNodes.values() .stream() .map(RMNode::createNodeEvent) .collect(Collectors.toMap(RMNodeEvent::getNodeUrl, event -> event)); for (NodeSource source : this.deployedNodeSources.values()) { for (RMDeployingNode node : source.getDeployingAndLostNodes()) { final RMNodeEvent nodeEvent = node.createNodeEvent(); nodeEvents.put(nodeEvent.getNodeUrl(), nodeEvent); } } final Map<String, RMNodeSourceEvent> nodeSourceEvents = this.definedNodeSources.values() .stream() .map(NodeSource::createNodeSourceEvent) .collect(Collectors.toMap(RMNodeSourceEvent::getSourceName, event -> event)); return new RMInitialState(nodeEvents, nodeSourceEvents); }
Source:
<code>public void getHardwareInfo(VDS vds) { Set<Version> hostVersions = null; Version clusterCompatibility = vds.getClusterCompatibilityVersion(); if ( <START> (hostVersions = vds.getSupportedClusterVersionsSet()) != <END> null && hostVersions.contains(clusterCompatibility)) { VDSReturnValue ret = resourceManager.runVdsCommand(VDSCommandType.GetHardwareInfo, new VdsIdAndVdsVDSCommandParametersBase(vds)); if (!ret.getSucceeded()) { AuditLogable logable = createAuditLogableForHost(vds); logable.updateCallStackFromThrowable(ret.getExceptionObject()); auditLogDirector.log(logable, AuditLogType.VDS_FAILED_TO_GET_HOST_HARDWARE_INFO); } } }</code><technical_language>pls pull initialization of hostVersions if statement (will a bit clearer read), i.e.: // Verify version capabilities Set<Version> hostVersions = vds.getSupportedClusterVersionsSet(); Version clusterCompatibility = vds.getClusterCompatibilityVersion(); // Verify this VDS // supports specific cluster level. getHardwareInfo API exist for // host exception raised VDSM. if (hostVersions != null && hostVersions.contains(clusterCompatibility)) {</technical_language>

Target:
public void getHardwareInfo(VDS vds) { Set<Version> hostVersions = vds.getSupportedClusterVersionsSet(); Version clusterCompatibility = vds.getClusterCompatibilityVersion(); if (hostVersions != null && hostVersions.contains(clusterCompatibility)) { VDSReturnValue ret = resourceManager.runVdsCommand(VDSCommandType.GetHardwareInfo, new VdsIdAndVdsVDSCommandParametersBase(vds)); if (!ret.getSucceeded()) { AuditLogable logable = createAuditLogableForHost(vds); logable.updateCallStackFromThrowable(ret.getExceptionObject()); auditLogDirector.log(logable, AuditLogType.VDS_FAILED_TO_GET_HOST_HARDWARE_INFO); } } }
Source:
<code>private void setAlpha(RoundedImageView view, float alpha) { <START> if (Build.VERSION.SDK_INT < 11) { <END> view.setAlpha((int) (255 * alpha)); } else { view.setAlpha(alpha); } }</code><technical_language>I suggest positive case for more scenarios SDK >= 11</technical_language>

Target:
private void setAlpha(RoundedImageView view, float alpha) { if (Build.VERSION.SDK_INT >= 11) { view.setAlpha(alpha); } else { view.setAlpha((int) (255 * alpha)); } }
Source:
<code>public void ensureEncrypted() { this.userName = StringUtils.stripToNull(this.userName); setPasswordIfNotBlank(password); <START> <END> if (encryptedPassword != null) { goCipher.maybeReEncrypt(encryptedPassword, new Consumer<String>() { @Override public void accept(String encryptedPassword) { setEncryptedPassword(encryptedPassword); } }); } }</code><technical_language>do StringUtils.stripToNull(encryptedPassword) != null</technical_language>

Target:
public void ensureEncrypted() { this.userName = StringUtils.stripToNull(this.userName); setPasswordIfNotBlank(password); if (encryptedPassword != null) { setEncryptedPassword(goCipher.maybeReEncryptForPostConstructWithoutExceptions(encryptedPassword)); } }
Source:
<code>public void enableGps() throws KuraException { <START> logger.warn("Modem GPS not supported"); <END> }</code><technical_language>throw UnsupportedOperationException</technical_language>

Target:
public void enableGps() throws KuraException { throw new UnsupportedOperationException("Modem GPS not supported"); }
Source:
<code>public int hashCode() { <START> return this.executionVertexID.hashCode() ^ this.attemptNumber; <END> }</code><technical_language>prefer this.executionVertexID.hashCode() * 31 + this.attemptNumber. This is attemptNumber == 0 is common result in hash code</technical_language>

Target:
public int hashCode() { return this.executionVertexId.hashCode() * 31 + this.attemptNumber; }
Source:
<code>private boolean shouldSkip() { if (cache.lastDocId != context.hitContext.docId()) { cache.lastMatched = false; cache.lastDocId = context.hitContext.docId(); } Boolean skipIfLastMatched = (Boolean)getOption("skip_if_last_matched"); if (skipIfLastMatched == null ? false : skipIfLastMatched && cache.lastMatched) { return true; } <START> return false; <END> }</code><technical_language>This block line 187 191 simplified return skipIfLastMatched != null && skipIfLastMatched && cache.lastMatched;</technical_language>

Target:
private boolean shouldSkip() { if (cache.lastDocId != context.hitContext.docId()) { cache.lastMatched = false; cache.lastDocId = context.hitContext.docId(); } Boolean skipIfLastMatched = (Boolean)getOption("skip_if_last_matched"); return skipIfLastMatched == null ? false : skipIfLastMatched && cache.lastMatched; }