auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void flush(int targetSubpartition) { <START> finishBroadcastBufferBuilder(); <END> finishSubpartitionBufferBuilder(targetSubpartition); super.flush(targetSubpartition); }</code><technical_language>double check: do want this default behavior in BufferWritingResultPartition, this finish partial buffers for streaming/pipelined cases well, want. I this logic confusing for future developers. do is following: - BufferWritingResultPartition leaves void flush(int) flushAll() methods abstract. - Instead offers protected void flushSubpartition(int partition, boolean finishProducers) protected void flushAllSubpartitions(boolean finishProducers). clear is a producer finished, caller aware of this behavior. - BoundedBlockingResultPartition implements flushAll() { flushAllSubpartitions(true); } PipelinedResultPartition implements flushAll() { flushAllSubpartitions(false); }</technical_language>

Target:
public void flush(int targetSubpartition) { flushSubpartition(targetSubpartition, true); }
Source:
<code>public UIButtonWebBrowser setUrl(String url) { boolean trustedUrl = false; boolean trustedHostName = false; if (webBrowserConfig != null) { <START> trustedUrl = webBrowserConfig.isUrlTrusted(url); <END> String hostname; try { hostname = (new URL(url)).getHost(); trustedHostName = webBrowserConfig.isHostNameTrusted(hostname); } catch (MalformedURLException e) { } } if (trustedHostName || trustedUrl) { confirmed.set(true); } else { confirmed.set(false); } this.url = url; return this; }</code><technical_language>If hostname is trusted longer need check for URL. I suggest remove this line here, add if statement right try/catch verify trustedHostName is true not, if is false call trustedUrl = webBrowserConfig.isUrlTrusted(url);. for performance prevents iterate in lists do need it</technical_language>

Target:
public UIButtonWebBrowser setUrl(String url) { boolean trustedUrl = false; if (webBrowserConfig != null) { trustedUrl = webBrowserConfig.isUrlTrusted(url); } confirmed.set(trustedUrl); this.url = url; return this; }
Source:
<code>public void testParseEncoding_Accept_Latin_One_AsISO8859_1() { Charset result = RawParseUtils.parseEncoding("encoding latin-1\n" .getBytes()); <START> assertNotNull(result); <END> }</code><technical_language>Please assert Charset is ISO-8859-1 charset</technical_language>

Target:
public void testParseEncoding_Accept_Latin_One_AsISO8859_1() { Charset result = RawParseUtils.parseEncoding("encoding latin-1\n" .getBytes()); assertNotNull(result); assertEquals("ISO-8859-1", result.name()); }
Source:
<code>ConfigurationBuilder getConfigBuilder() { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.clustering().cacheMode(CacheMode.LOCAL); configurationBuilder.indexing().index(Index.ALL) <START> .addProperty("default.directory_provider", "ram"); <END> return configurationBuilder; }</code><technical_language>s/ram/local-heap/</technical_language>

Target:
ConfigurationBuilder getConfigBuilder() { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.clustering().cacheMode(CacheMode.LOCAL); configurationBuilder.indexing().index(Index.ALL) .addProperty("default.directory_provider", "local-heap"); return configurationBuilder; }
Source:
<code>private static String getPatchedPathWithCurrentJavaBinLocation() { String currentJavaHome = System.getProperty("java.home"); String originPathVariable = System.getenv("PATH"); <START> return File.pathSeparator + currentJavaHome + File.separator + "bin" + File.separator + File.pathSeparator + originPathVariable; <END> }</code><technical_language>this need start File.pathSeparator</technical_language>

Target:
private static String getPatchedPathWithCurrentJavaBinLocation() { String currentJavaHome = System.getProperty("java.home"); String originPathVariable = System.getenv("PATH"); return currentJavaHome + File.separator + "bin" + File.separator + File.pathSeparator + originPathVariable; }
Source:
<code>private Map<String, Object> populateAttributes(final Map<String, Object> rowAttributes, final List<String> names) { <START> final Map<String, Object> newAttributes = new HashMap<>(); <END> for (final Map.Entry<String, Object> entry : rowAttributes.entrySet()) { final String name = entry.getKey(); if (names == null || names.contains(name)) { newAttributes.put(name, entry.getValue()); } } return newAttributes; }</code><technical_language>a bit more elegant Stream API do that? :)</technical_language>

Target:
private Map<String, Object> populateAttributes(final Map<String, Object> rowAttributes, final List<String> names) { return rowAttributes.entrySet().stream() .filter(p -> names == null || names.contains(p.getKey())) .collect(HashMap::new, (m,v)->m.put(v.getKey(), v.getValue()), HashMap::putAll); }
Source:
<code>public void testTotalCountValue() { TestFailJobCallback callback = new TestFailJobCallback(); CheckpointFailureManager failureManager = new CheckpointFailureManager(0, callback); for (CheckpointFailureReason reason : CheckpointFailureReason.values()) { failureManager.handleJobLevelCheckpointException(new CheckpointException(reason), -1); } <START> assertEquals(1, callback.getInvokeCounter()); <END> }</code><technical_language>This test fails running ce537ac0417ebb159a4589f028a024814e03d03f</technical_language>

Target:
public void testTotalCountValue() { TestFailJobCallback callback = new TestFailJobCallback(); CheckpointFailureManager failureManager = new CheckpointFailureManager(0, callback); for (CheckpointFailureReason reason : CheckpointFailureReason.values()) { failureManager.handleJobLevelCheckpointException(new CheckpointException(reason), -1); } assertEquals(2, callback.getInvokeCounter()); }
Source:
<code>public void testClientProxySettings() throws URISyntaxException, IOException { conf.setCurlLogging(true); final Map<String, String> headers = new HashMap<String, String>(); headers.put("key1", "value1"); headers.put("key2", "value2"); final HashSet<String> expectedCurlHeaders = new HashSet<String>(); for (final Map.Entry<String, String> entry : headers.entrySet()) { expectedCurlHeaders.add("\"" + entry.getKey() + ":" + entry.getValue() + "\""); } final HttpRequest request = new HttpRequest("POST", new URI("<LINK_0>"), headers, null ); conf.setProtocol(Protocol.HTTP); conf.setProxyHost(server.getListenAddress().getHostName()); conf.setProxyPort(server.getListenAddress().getPort()); try { client.execute(request); } catch (final UnknownHostException exception) { <START> return; <END> } assertNotNull(client.proxy); assertEquals(client.proxy.address(), server.getListenAddress()); assertTrue("Expected UnknownHostException. UnknownHostException not thrown while executing the request.", true); }</code><technical_language>This surface exception is a silent failure. throw</technical_language>

Target:
public void testClientProxySettings() throws URISyntaxException, IOException { HttpProxyServer server = DefaultHttpProxyServer.bootstrap() .withPort(8080) .start(); conf.setCurlLogging(true); final Map<String, String> headers = new HashMap<String, String>(); headers.put("key1", "value1"); headers.put("key2", "value2"); final HashSet<String> expectedCurlHeaders = new HashSet<String>(); for (final Map.Entry<String, String> entry : headers.entrySet()) { expectedCurlHeaders.add("\"" + entry.getKey() + ":" + entry.getValue() + "\""); } final HttpRequest request = new HttpRequest("POST", new URI("<LINK_0>"), headers, null ); conf.setProtocol(Protocol.HTTP); conf.setProxyHost(server.getListenAddress().getHostName()); conf.setProxyPort(server.getListenAddress().getPort()); client = new MockUrlHttpClient(conf); try { client.execute(request); } catch (final UnknownHostException exception) { throw exception; } assertNotNull(client.proxy); assertEquals(client.proxy.address(), server.getListenAddress()); assertTrue("Expected UnknownHostException. UnknownHostException not thrown while executing the request.", true); server.stop(); }
Source:
<code>private void clickPopup(final int buttonNo) { final AbstractScene scene = ShaftEscape.getScene(); <START> if (scene.getPopup() != null) { <END> ObservableList<Node> buttons; sleep(1); buttons = ((VBox) scene.getPopup().getContent().get(1)) .getChildren(); buttons = ((HBox) buttons.get(buttons.size() - 1)).getChildren(); try { clickOn(buttons.get(buttonNo), MouseButton.PRIMARY); } catch (ArrayIndexOutOfBoundsException e) { fail("ButtonNo " + buttonNo + " does not exist"); } sleep(SHORT); } }</code><technical_language>scene.getPopup() accessed in a static way. least, Eclipse says. I same. (this is line this warning is generated) <review,logic</technical_language>

Target:
private void clickPopup(final int buttonNo) { if (AbstractScene.getPopup() != null) { ObservableList<Node> buttons; sleep(1); buttons = ((VBox) AbstractScene.getPopup().getContent().get(1)) .getChildren(); buttons = ((HBox) buttons.get(buttons.size() - 1)).getChildren(); try { clickOn(buttons.get(buttonNo), MouseButton.PRIMARY); } catch (ArrayIndexOutOfBoundsException e) { fail("ButtonNo " + buttonNo + " does not exist"); } sleep(SHORT); } }
Source:
<code>protected void recoverFromException(final String curQueue, final Exception ex) { final RecoveryStrategy recoveryStrategy = this.exceptionHandlerRef.get().onException(this, ex, curQueue); switch (recoveryStrategy) { case RECONNECT: if (ex instanceof JedisNoScriptException) { <START> LOG.info("got JedisNoScriptException while reconnecting, reloading redis scripts"); <END> loadRedisScripts(); } else { LOG.info("waiting for pool to reconnect to redis", ex); try { Thread.sleep(RECONNECT_SLEEP_TIME); } catch (InterruptedException e) { } } break; case TERMINATE: LOG.warn("Terminating in response to exception", ex); end(false); break; case PROCEED: this.listenerDelegate.fireEvent(WORKER_ERROR, this, curQueue, null, null, null, ex); break; default: LOG.error("Unknown RecoveryStrategy: " + recoveryStrategy + " while attempting to recover from the following exception; worker proceeding...", ex); break; } }</code><technical_language>Nit: Capital 'G' for start of sentence. Also, Redis capitalized</technical_language>

Target:
protected void recoverFromException(final String curQueue, final Exception ex) { final RecoveryStrategy recoveryStrategy = this.exceptionHandlerRef.get().onException(this, ex, curQueue); switch (recoveryStrategy) { case RECONNECT: if (ex instanceof JedisNoScriptException) { LOG.info("Got JedisNoScriptException while reconnecting, reloading Redis scripts"); loadRedisScripts(); } else { LOG.info("Waiting " + RECONNECT_SLEEP_TIME + "ms for pool to reconnect to redis", ex); try { Thread.sleep(RECONNECT_SLEEP_TIME); } catch (InterruptedException e) { } } break; case TERMINATE: LOG.warn("Terminating in response to exception", ex); end(false); break; case PROCEED: this.listenerDelegate.fireEvent(WORKER_ERROR, this, curQueue, null, null, null, ex); break; default: LOG.error("Unknown RecoveryStrategy: " + recoveryStrategy + " while attempting to recover from the following exception; worker proceeding...", ex); break; } }
Source:
<code>private PullRequest getPullRequest(String payload, GitHub gh) throws IOException { <START> return gh.parseEventPayload(new StringReader(payload), PullRequest.class); <END> }</code><technical_language>I prefer variable line for debugging</technical_language>

Target:
private PullRequest getPullRequest(String payload, GitHub gh) throws IOException { @SuppressWarnings("UnnecessaryLocalVariable") PullRequest pr = gh.parseEventPayload(new StringReader(payload), PullRequest.class); return pr; }
Source:
<code>private MergingReport mergeManifests( File mainManifestFile, List<File> libraryManifestFiles, BuckEventAndroidLogger logger) { try { MergingReport mergingReport = ManifestMerger2 .newMerger(mainManifestFile, logger, ManifestMerger2.MergeType.APPLICATION) .withFeatures( ManifestMerger2.Invoker.Feature.NO_PLACEHOLDER_REPLACEMENT, ManifestMerger2.Invoker.Feature.REMOVE_TOOLS_DECLARATIONS, ManifestMerger2.Invoker.Feature.SKIP_BLAME) .addLibraryManifests(Iterables.toArray(libraryManifestFiles, File.class)) .merge(); if (mergingReport.getResult().isError()) { mergingReport.log(logger); <START> throw new HumanReadableException("Error generating manifest file"); <END> } return mergingReport; } catch (ManifestMerger2.MergeFailureException e) { throw new HumanReadableException(e, "Error generating manifest file"); } }</code><technical_language>This is showing indication of actual error is. I need display diagnostic info in console easier for engineers (and me) debug build failures</technical_language>

Target:
private MergingReport mergeManifests( File mainManifestFile, List<File> libraryManifestFiles, BuckEventAndroidLogger logger) { try { MergingReport mergingReport = ManifestMerger2 .newMerger(mainManifestFile, logger, ManifestMerger2.MergeType.APPLICATION) .withFeatures( ManifestMerger2.Invoker.Feature.NO_PLACEHOLDER_REPLACEMENT, ManifestMerger2.Invoker.Feature.REMOVE_TOOLS_DECLARATIONS, ManifestMerger2.Invoker.Feature.SKIP_BLAME) .addLibraryManifests(Iterables.toArray(libraryManifestFiles, File.class)) .merge(); if (mergingReport.getResult().isError()) { for (MergingReport.Record record : mergingReport.getLoggingRecords()) { logger.error(null, record.toString()); } throw new HumanReadableException("Error generating manifest file"); } return mergingReport; } catch (ManifestMerger2.MergeFailureException e) { throw new HumanReadableException(e, "Error generating manifest file"); } }
Source:
<code><START> public static boolean atHashCheckRequired(List<String> responseTypes) { <END> Set<String> types = Sets.newHashSet(); responseTypes.forEach((s) -> { if (s != null && !s.isEmpty()) { types.addAll(Lists.newArrayList(s.split(" "))); } }); if (types.contains("token") && types.contains("id_token")) return true; return false; }</code><technical_language>responseTypes.stream().anyMatch(s -> ResponseType.fromString(s, "").contains(TOKEN))</technical_language>

Target:
public static boolean atHashCheckRequired(List<String> responseTypes) { return responseTypes.stream().anyMatch(s -> ResponseType.fromString(s, " ").contains(ResponseType.TOKEN)); }
Source:
<code>public String readMonitoring() throws InterruptedException { String result = null; int retry = 0; do { try { result = receiveMonitorOPEN(monitorSk); } catch (IOException e) { try { MyHomeSocketFactory.disconnect(monitorSk); } catch (IOException e1) { } retry++; Thread.sleep(1000); System.err.println("Monitor connection problem retry temptative: " + retry); try { startMonitoring(); } catch (IOException e1) { } <START> continue; <END> } } while (result == null); return result; }</code><technical_language>This is needed</technical_language>

Target:
public String readMonitoring() throws InterruptedException { String result = null; int retry = 0; do { try { result = receiveMonitorOPEN(monitorSk); } catch (IOException e) { try { MyHomeSocketFactory.disconnect(monitorSk); } catch (IOException e1) { } retry++; Thread.sleep(1000); logger.warn("Monitor connection problem. Attempting retry {}.", retry); try { startMonitoring(); } catch (IOException e1) { } } } while (result == null); return result; }
Source:
<code>protected ExceptionHolder findZuulException(Throwable throwable) { if (throwable.getCause() instanceof ZuulRuntimeException) { <START> Throwable cause = throwable.getCause().getCause().getCause(); <END> if (cause instanceof ClientException && cause.getCause() != null && cause.getCause().getCause() instanceof SocketTimeoutException) { ZuulException zuulException = new ZuulException("", 504, ZuulException.class.getName() + ": Hystrix Readed time out"); return new ZuulExceptionHolder(zuulException); } return new ZuulExceptionHolder((ZuulException) throwable.getCause().getCause()); } if (throwable.getCause() instanceof ZuulException) { return new ZuulExceptionHolder((ZuulException) throwable.getCause()); } if (throwable instanceof ZuulException) { return new ZuulExceptionHolder((ZuulException) throwable); } return new DefaultExceptionHolder(throwable); }</code><technical_language>I fond of this type of code result in a NPE, I want some checks protect us</technical_language>

Target:
protected ExceptionHolder findZuulException(Throwable throwable) { if (throwable.getCause() instanceof ZuulRuntimeException) { Throwable cause = null; if (throwable.getCause().getCause() != null) { cause = throwable.getCause().getCause().getCause(); } if (cause instanceof ClientException && cause.getCause() != null && cause.getCause().getCause() instanceof SocketTimeoutException) { ZuulException zuulException = new ZuulException("", 504, ZuulException.class.getName() + ": Hystrix Readed time out"); return new ZuulExceptionHolder(zuulException); } return new ZuulExceptionHolder((ZuulException) throwable.getCause().getCause()); } if (throwable.getCause() instanceof ZuulException) { return new ZuulExceptionHolder((ZuulException) throwable.getCause()); } if (throwable instanceof ZuulException) { return new ZuulExceptionHolder((ZuulException) throwable); } return new DefaultExceptionHolder(throwable); }
Source:
<code>public FormValidation doCheckHookUrl(@QueryParameter String value) { try { HttpURLConnection con = (HttpURLConnection) new URL(value).openConnection(); con.setRequestMethod("POST"); con.setRequestProperty(GitHubWebHook.URL_VALIDATION_HEADER, "true"); con.connect(); if (con.getResponseCode()!=200) { return FormValidation.error("Got "+con.getResponseCode()+" from "+value); } String v = con.getHeaderField(GitHubWebHook.X_INSTANCE_IDENTITY); if (v == null) { return FormValidation.warning("It doesn't look like " + value + " is talking to any Jenkins. Are you running your own app?"); } RSAPublicKey key = identity.getPublic(); String expected = new String(Base64.encodeBase64(key.getEncoded()), "UTF-8" ); if (!expected.equals(v)) { return FormValidation.error(value+" is connecting to different Jenkins instances"); } return FormValidation.ok(); } catch (UnsupportedEncodingException ex) { <START> return FormValidation.error("Unsupported exception "+ex.getLocalizedMessage()); <END> } catch (IOException e) { return FormValidation.error(e,"Failed to test a connection to "+value); } }</code><technical_language>space +</technical_language>

Target:
public FormValidation doCheckHookUrl(@QueryParameter String value) { try { HttpURLConnection con = (HttpURLConnection) new URL(value).openConnection(); con.setRequestMethod("POST"); con.setRequestProperty(GitHubWebHook.URL_VALIDATION_HEADER, "true"); con.connect(); if (con.getResponseCode()!=200) { return FormValidation.error("Got "+con.getResponseCode()+" from "+value); } String v = con.getHeaderField(GitHubWebHook.X_INSTANCE_IDENTITY); if (v == null) { return FormValidation.warning("It doesn't look like " + value + " is talking to any Jenkins. Are you running your own app?"); } RSAPublicKey key = identity.getPublic(); String expected = new String(Base64.encodeBase64(key.getEncoded()), "UTF-8" ); if (!expected.equals(v)) { return FormValidation.error(value+" is connecting to different Jenkins instances"); } return FormValidation.ok(); } catch (UnsupportedEncodingException ex) { return FormValidation.error("Unsupported exception {0}", ex.getLocalizedMessage()); } catch (IOException e) { return FormValidation.error(e,"Failed to test a connection to "+value); } }
Source:
<code>private void lookupCoordinatorAndRetry(TransactionManager.TxnRequestHandler nextRequestHandler) { if (!nextRequestHandler.needsCoordinator()) { time.sleep(retryBackoffMs); metadata.requestUpdate(); } <START> transactionManager.lookupCoordinator(nextRequestHandler); <END> transactionManager.retry(nextRequestHandler); }</code><technical_language>reads a bit strange fall lookupCoordinator if request need coordinator. clearer a slight restructure: java transactionManager.retry(nextRequestHandler); if (nextRequestHandler.needsCoordinator()) { transactionManager.lookupCoordinator(nextRequestHandler); } else { // For non-coordinator requests, sleep prevent a tight loop node is time.sleep(retryBackoffMs); metadata.requestUpdate(); }</technical_language>

Target:
private void lookupCoordinatorAndRetry(TransactionManager.TxnRequestHandler nextRequestHandler) { if (nextRequestHandler.needsCoordinator()) { transactionManager.lookupCoordinator(nextRequestHandler); } else { time.sleep(retryBackoffMs); metadata.requestUpdate(); } transactionManager.retry(nextRequestHandler); }
Source:
<code>public void saveLibraryDilutions(final Collection<LibraryDilution> libraryDilutions) throws IOException { log.info("Migrating library dilutions..."); for (LibraryDilution ldi : libraryDilutions) { <START> log.debug("Saving library dilution " + ldi.getName()); <END> if (replaceChangeLogs) { if (ldi.getCreationDate() == null || ldi.getLastModified() == null) { throw new IOException("Cannot save dilution due to missing timestamps"); } } else { ldi.setCreationDate(timeStamp); ldi.setLastModified(timeStamp); } if (ldi.getLibrary().getId() == AbstractDilution.UNSAVED_ID && ldi.getLibrary().getLibraryAdditionalInfo() != null && ldi.getLibrary().getLibraryAdditionalInfo().getPreMigrationId() != null) { ldi.setLibrary(serviceManager.getLibraryDao().getByPreMigrationId(ldi.getLibrary().getLibraryAdditionalInfo().getPreMigrationId())); if (ldi.getLibrary() == null) { throw new IOException("No Library found with pre-migration ID " + ldi.getLibrary().getLibraryAdditionalInfo().getPreMigrationId()); } } ldi.setId(serviceManager.getDilutionDao().save(ldi)); log.debug("Saved library dilution " + ldi.getName()); } log.info(libraryDilutions.size() + " library dilutions migrated."); }</code><technical_language>Name null save</technical_language>

Target:
public void saveLibraryDilutions(final Collection<LibraryDilution> libraryDilutions) throws IOException { log.info("Migrating library dilutions..."); for (LibraryDilution ldi : libraryDilutions) { String friendlyName = " of " + ldi.getLibrary().getAlias(); if (ldi.getPreMigrationId() != null) { friendlyName += " with pre-migration id " + ldi.getPreMigrationId(); } log.debug("Saving library dilution " + friendlyName); if (replaceChangeLogs) { if (ldi.getCreationDate() == null || ldi.getLastModified() == null) { throw new IOException("Cannot save dilution due to missing timestamps"); } } else { ldi.setCreationDate(timeStamp); ldi.setLastModified(timeStamp); } if (ldi.getLibrary().getId() == AbstractDilution.UNSAVED_ID && ldi.getLibrary().getLibraryAdditionalInfo() != null && ldi.getLibrary().getLibraryAdditionalInfo().getPreMigrationId() != null) { ldi.setLibrary(serviceManager.getLibraryDao().getByPreMigrationId(ldi.getLibrary().getLibraryAdditionalInfo().getPreMigrationId())); if (ldi.getLibrary() == null) { throw new IOException("No Library found with pre-migration ID " + ldi.getLibrary().getLibraryAdditionalInfo().getPreMigrationId()); } } ldi.setId(serviceManager.getDilutionDao().save(ldi)); log.debug("Saved library dilution " + friendlyName); } log.info(libraryDilutions.size() + " library dilutions migrated."); }
Source:
<code>protected void processFiltered(File file, List<String> lines) throws CheckstyleException { String filePath; String folderPath; try { filePath = file.getCanonicalPath(); folderPath = file.getParentFile().getCanonicalPath(); } catch (IOException ex) { <START> filePath = file.getAbsolutePath(); <END> folderPath = file.getParentFile().getAbsolutePath(); } if (ignoreFileExtensions) { final int extension = filePath.lastIndexOf('.'); final int separator = filePath.lastIndexOf(File.separatorChar); if (extension > separator) { filePath = filePath.substring(0, extension); } } if (isMatchFolder(folderPath) && isMatchFile(filePath)) { if (match) { log(0, MSG_MATCH, filePath); } else { log(0, MSG_MISMATCH, filePath); } } }</code><technical_language>@rnveach ignore exceptions absolutely necessary. cases absolute path works canonical path fails</technical_language>

Target:
protected void processFiltered(File file, List<String> lines) throws CheckstyleException { final String fileName = getFileName(file); final String folderPath = getFolderPath(file); if (isMatchFolder(folderPath) && isMatchFile(fileName)) { log(); } }
Source:
<code>private CommonAggregateStats getPlaceholderCommonAggregateStats(Object component) { CommonAggregateStats commonStats = new CommonAggregateStats(); Map<String, Object> jsonMap = StormCommon.componentConf(component); int numTasks = (int) (long) jsonMap.getOrDefault(Config.TOPOLOGY_TASKS, 0); <START> commonStats.set_num_executors(numTasks); <END> commonStats.set_num_tasks(numTasks); commonStats.set_emitted(0); commonStats.set_transferred(0); commonStats.set_acked(0); return commonStats; }</code><technical_language>double check, is safe assume number of executors is number of tasks? If safe get apply that, 0 (even -1) confusion</technical_language>

Target:
private CommonAggregateStats getPlaceholderCommonAggregateStats(Object component) { CommonAggregateStats commonStats = new CommonAggregateStats(); int numExecutors = 0; try { numExecutors = StormCommon.numStartExecutors(component); } catch (InvalidTopologyException e) { } Map<String, Object> jsonMap = StormCommon.componentConf(component); int numTasks = ObjectReader.getInt(jsonMap.getOrDefault(Config.TOPOLOGY_TASKS, numExecutors)); commonStats.set_num_executors(numExecutors); commonStats.set_num_tasks(numTasks); commonStats.set_emitted(0); commonStats.set_transferred(0); commonStats.set_acked(0); return commonStats; }
Source:
<code><START> public VolatilitySurface getVolSurface(final DoubleMatrix1D modelParameters) { <END> final Function1D<double[], Double> func = new BasisFunctionAggregation<>(_bSplines, modelParameters.getData()); final Function2D<Double, Double> func2D = new Function2D<Double, Double>() { @Override public Double evaluate(final Double t, final Double k) { return func.evaluate(new double[] {t, k }); } }; final FunctionalDoublesSurface surface = new FunctionalDoublesSurface(func2D); return new VolatilitySurface(surface); }</code><technical_language>Check args</technical_language>

Target:
public VolatilitySurface getVolSurface(final DoubleMatrix1D modelParameters) { ArgumentChecker.notNull(modelParameters, "modelParameters"); final Function1D<double[], Double> func = new BasisFunctionAggregation<>(_bSplines, modelParameters.getData()); final Function2D<Double, Double> func2D = new Function2D<Double, Double>() { @Override public Double evaluate(final Double t, final Double k) { return func.evaluate(new double[] {t, k }); } }; final FunctionalDoublesSurface surface = new FunctionalDoublesSurface(func2D); return new VolatilitySurface(surface); }
Source:
<code>public int copyTo(final Map<String,?> props, InputStream src, long filesize, final String destination) { final long finalFilesize; final InputStream finalSrc; if (filesize==-1) { try { File tempFile = File.createTempFile("sshcopy", "data"); tempFile.deleteOnExit(); FileOutputStream out = new FileOutputStream(tempFile); <START> ResourceUtils.copy(src, out); <END> out.close(); finalFilesize = tempFile.length(); finalSrc = new FileInputStream(tempFile); } catch (IOException e) { throw Throwables.propagate(e); } finally { Closeables.closeQuietly(src); } } else { finalFilesize = filesize; finalSrc = src; } return execSsh(props, new Function<SshTool,Integer>() { public Integer apply(SshTool ssh) { return ssh.createFile(props, destination, finalSrc, finalFilesize); }}); }</code><technical_language>I move guava's Files for this kind of thing. for now, like: File tempFile = ResourceUtils.writeToTempFile(src, "sshcopy", "data"); try { finalSrc = new FileInputStream(tempFile); } catch (IOException e) { throw Throwables.propagate(e); }</technical_language>

Target:
public int copyTo(final Map<String,?> props, InputStream src, long filesize, final String destination) { final long finalFilesize; final InputStream finalSrc; if (filesize==-1) { try { File tempFile = ResourceUtils.writeToTempFile(src, "sshcopy", "data"); finalFilesize = tempFile.length(); finalSrc = new FileInputStream(tempFile); } catch (IOException e) { throw Throwables.propagate(e); } finally { Closeables.closeQuietly(src); } } else { finalFilesize = filesize; finalSrc = src; } return execSsh(props, new Function<SshTool,Integer>() { public Integer apply(SshTool ssh) { return ssh.createFile(props, destination, finalSrc, finalFilesize); }}); }
Source:
<code><START> private void checkPercentageValidity(int percentage, String message) { <END> if (percentage < 0 || percentage > 100) { throw new IllegalArgumentException(message); } }</code><technical_language>+static</technical_language>

Target:
private static void checkPercentageValidity(int percentage, String message) { if (percentage < 0 || percentage > 100) { throw new IllegalArgumentException(message); } }
Source:
<code>public WebSocket akkaStreamsSocket() { return WebSocket.Json.accept( request -> { Sink<JsonNode, ?> in = Sink.foreach(System.out::println); <START> final MessageDTO messageDTO = new MessageDTO("1", "1", "Title", "Test Body"); <END> Source<JsonNode, ?> out = Source.tick( Duration.ofSeconds(2), Duration.ofSeconds(2), MessageConverter.messageToJsonNode(messageDTO) ); return Flow.fromSinkAndSource(in, out); }); }</code><technical_language>Extraneous final</technical_language>

Target:
public WebSocket akkaStreamsSocket() { return WebSocket.Json.accept( request -> { Sink<JsonNode, ?> in = Sink.foreach(System.out::println); MessageDTO messageDTO = new MessageDTO("1", "1", "Title", "Test Body"); Source<JsonNode, ?> out = Source.tick( Duration.ofSeconds(2), Duration.ofSeconds(2), MessageConverter.messageToJsonNode(messageDTO) ); return Flow.fromSinkAndSource(in, out); }); }
Source:
<code>public static int getIntParameter(String inParameter, int inDefault) { try { return getConfig().getInt(inParameter, inDefault); } catch (RuntimeException e) { <START> return 0; <END> } }</code><technical_language>returning 0 instead of inDefault in other methods</technical_language>

Target:
public static int getIntParameter(String inParameter, int inDefault) { try { return getConfig().getInt(inParameter, inDefault); } catch (ConversionException e) { return inDefault; } }
Source:
<code>public List<Environment.Variable> environment() { <START> List<Environment.Variable> env = new ArrayList<>(asList( <END> Environment.Variable.newBuilder() .setName("CRATE_HEAP_SIZE") .setValue(String.format("%sm", configuration.resHeap.longValue())) .build() )); return env; }</code><technical_language>new ArrayList<>(asList(</technical_language>

Target:
public List<Environment.Variable> environment() { List<Environment.Variable> env = asList( Environment.Variable.newBuilder() .setName("CRATE_HEAP_SIZE") .setValue(String.format("%sm", configuration.resHeap.longValue())) .build() ); return env; }
Source:
<code>public void onEventMainThread(DiscussionThreadFollowedEvent event) { for (int i = 0; i < discussionPostsAdapter.getCount(); ++i) { <START> if (discussionPostsAdapter.getItem(i).getIdentifier().equalsIgnoreCase(event.getDiscussionThread().getIdentifier())) { <END> discussionPostsAdapter.replace(event.getDiscussionThread(), i); break; } } }</code><technical_language>implement this equality checking in equals() method of DiscussionThread. care of performing null checks (as a sanity check)</technical_language>

Target:
public void onEventMainThread(DiscussionThreadFollowedEvent event) { for (int i = 0; i < discussionPostsAdapter.getCount(); ++i) { if (discussionPostsAdapter.getItem(i).hasSameId(event.getDiscussionThread())) { discussionPostsAdapter.replace(event.getDiscussionThread(), i); break; } } }
Source:
<code>public void updated(Map<String, Object> properties) { cancelPollTask(); this.options = new WatchdogServiceOptions(properties); if (this.options.isEnabled()) { this.rebootCauseWriter = new RebootCauseFileWriter(this.options.getRebootCauseFilePath()); <START> try (PrintWriter wdWriter = new PrintWriter(WD_FILE);) { <END> wdWriter.write(this.options.getWatchdogDevice()); } catch (IOException e) { logger.error("Unable to write watchdog config file", e); } this.pollTask = this.pollExecutor.scheduleAtFixedRate(() -> { Thread.currentThread().setName("WatchdogServiceImpl"); checkCriticalComponents(); }, 0, this.options.getPingInterval(), TimeUnit.MILLISECONDS); } else { disableWatchdog(); } }</code><technical_language>a clarification: WD_FILE location is hard coded in implementation. is modifiable in service preferences. is a reference getWatchdogDevice in private method writeWatchdogDevice. this some sort of inconsistencies? if user changes in service preferences</technical_language>

Target:
public void updated(Map<String, Object> properties) { cancelPollTask(); this.options = new WatchdogServiceOptions(properties); if (this.options.isEnabled()) { this.rebootCauseWriter = new RebootCauseFileWriter(this.options.getRebootCauseFilePath()); try (PrintWriter wdWriter = new PrintWriter(this.options.getWatchdogEnabledTemporaryFilePath())) { wdWriter.write(this.options.getWatchdogDevice()); } catch (IOException e) { logger.error("Unable to write watchdog enabled temporary file", e); } this.pollTask = this.pollExecutor.scheduleAtFixedRate(() -> { Thread.currentThread().setName("WatchdogServiceImpl"); checkCriticalComponents(); }, 0, this.options.getPingInterval(), TimeUnit.MILLISECONDS); } else { disableWatchdog(); } }
Source:
<code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); trace(this, "Starting XWalk webview..."); this.simprints = new SimprintsSupport(this); this.photoGrabber = new PhotoGrabber(this); this.mrdt = new MrdtSupport(this); try { this.smsSender = new SmsSender(this); } catch (Exception ex) { error(ex, "Failed to create SmsSender."); } this.settings = SettingsStore.in(this); this.appUrl = settings.getAppUrl(); this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main); if (settings.allowsConfiguration() && appUrl.contains("app.medicmobile.org")) { View webviewContainer = findViewById(R.id.lytWebView); webviewContainer.setPadding(10, 10, 10, 10); webviewContainer.setBackgroundColor(R.drawable.warning_background); } container = (XWalkView) findViewById(R.id.wbvMain); configureUseragent(); enableLocationUpdates(); setUpUiClient(container); enableRemoteChromeDebugging(); enableJavascript(container); enableStorage(container); enableUrlHandlers(container); browseToRoot(); if (settings.allowsConfiguration()) { toast(redactUrl(appUrl)); } sharedPreferences = getSharedPreferences(MY_LAST_ACTIVITY, 0); String recentNavigation = sharedPreferences.getString(MY_LAST_ACTIVITY, ""); if (!(recentNavigation != null && recentNavigation.isEmpty())) { container.loadUrl(recentNavigation); <START> Log.d("Gopinath", sharedPreferences.getString(MY_LAST_ACTIVITY, "")); <END> } }</code><technical_language>left this in mistake. remove line change text description</technical_language>

Target:
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); trace(this, "Starting XWalk webview..."); this.simprints = new SimprintsSupport(this); this.photoGrabber = new PhotoGrabber(this); this.mrdt = new MrdtSupport(this); try { this.smsSender = new SmsSender(this); } catch(Exception ex) { error(ex, "Failed to create SmsSender."); } this.settings = SettingsStore.in(this); this.appUrl = settings.getAppUrl(); this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main); if(settings.allowsConfiguration() && appUrl.contains("app.medicmobile.org")) { View webviewContainer = findViewById(R.id.lytWebView); webviewContainer.setPadding(10, 10, 10, 10); webviewContainer.setBackgroundColor(R.drawable.warning_background); } container = (XWalkView) findViewById(R.id.wbvMain); configureUseragent(); enableLocationUpdates(); setUpUiClient(container); enableRemoteChromeDebugging(); enableJavascript(container); enableStorage(container); enableUrlHandlers(container); browseToRoot(); if(settings.allowsConfiguration()) { toast(redactUrl(appUrl)); } sharedPreferences = getSharedPreferences(MY_LAST_ACTIVITY, 0); String recentNavigation = sharedPreferences.getString(MY_LAST_ACTIVITY, ""); if (!(recentNavigation != null && recentNavigation.isEmpty())) { container.loadUrl(recentNavigation); } }
Source:
<code>public ResponseEntity<Problem> conflict(final ConflictException ex, final NativeWebRequest request) { <START> LOG.error(ex.getMessage(), ex); <END> return Responses.create(Response.Status.CONFLICT, ex.getMessage(), request); }</code><technical_language>I error, logged "debug" level</technical_language>

Target:
public ResponseEntity<Problem> conflict(final ConflictException ex, final NativeWebRequest request) { LOG.debug(ex.getMessage(), ex); return Responses.create(Response.Status.CONFLICT, ex.getMessage(), request); }
Source:
<code>public boolean isEmbedded() { <START> return (embeddedServer != null); <END> }</code><technical_language>Remove extra parentheses</technical_language>

Target:
public boolean isEmbedded() { return embeddedServer != null; }
Source:
<code>private void initializeHandler(final Thing thing, final ThingHandler thingHandler) { logger.debug("Calling initialize handler for thing '{}' at '{}'.", thing.getUID(), thingHandler); try { SafeMethodCaller.call(new SafeMethodCaller.ActionWithException<Void>() { @Override public Void call() throws Exception { thingHandler.initialize(); return null; } }); } catch (TimeoutException ex) { ThingStatusInfo statusInfo = buildStatusInfo(ThingStatus.UNINITIALIZED, ThingStatusDetail.HANDLER_INITIALIZING_ERROR, ex.getCause() != null ? ex.getCause().getMessage() : ex.getMessage()); setThingStatus(thing, statusInfo); logger.warn("Initializing handler for thing '{}' takes more than {}ms.", thing.getUID(), SafeMethodCaller.DEFAULT_TIMEOUT); } catch (Exception ex) { ThingStatusInfo statusInfo = buildStatusInfo(ThingStatus.UNINITIALIZED, ThingStatusDetail.HANDLER_INITIALIZING_ERROR, ex.getCause() != null ? ex.getCause().getMessage() : ex.getMessage()); setThingStatus(thing, statusInfo); <START> logger.error("Exception occured while initializing handler of thing '" + thing.getUID() + "': " <END> + ex.getMessage(), ex); } }</code><technical_language>Do need this a log status update message</technical_language>

Target:
private void initializeHandler(final Thing thing, final ThingHandler thingHandler) { logger.debug("Calling initialize handler for thing '{}' at '{}'.", thing.getUID(), thingHandler); try { SafeMethodCaller.call(new SafeMethodCaller.ActionWithException<Void>() { @Override public Void call() throws Exception { thingHandler.initialize(); return null; } }); } catch (TimeoutException ex) { logger.warn("Initializing handler for thing '{}' takes more than {}ms.", thing.getUID(), SafeMethodCaller.DEFAULT_TIMEOUT); } catch (Exception ex) { ThingStatusInfo statusInfo = buildStatusInfo(ThingStatus.UNINITIALIZED, ThingStatusDetail.HANDLER_INITIALIZING_ERROR, ex.getCause() != null ? ex.getCause().getMessage() : ex.getMessage()); setThingStatus(thing, statusInfo); logger.error("Exception occured while initializing handler of thing '" + thing.getUID() + "': " + ex.getMessage(), ex); } }
Source:
<code>protected void setUp() throws Exception { super.setUp(); <START> availablePrefixes = <END> CompoundInterpreter.INSTANCE.getAllNewEmtpyExpressions(); assertFalse("At least one interpreter should be declared", availablePrefixes.isEmpty()); DiagramDescription diagramDescription = DescriptionFactory.eINSTANCE.createDiagramDescription(); interpreterContext = SiriusInterpreterContextFactory.createInterpreterContext(diagramDescription, DescriptionPackage.Literals.DIAGRAM_DESCRIPTION__PRECONDITION_EXPRESSION); }</code><technical_language>availableEmptyExpressions Some interpreter do provide a prefix a suffix</technical_language>

Target:
protected void setUp() throws Exception { super.setUp(); availableEmptyExpressions = CompoundInterpreter.INSTANCE.getAllNewEmtpyExpressions(); assertFalse("At least one interpreter should be declared", availableEmptyExpressions.isEmpty()); DiagramDescription diagramDescription = DescriptionFactory.eINSTANCE.createDiagramDescription(); interpreterContext = SiriusInterpreterContextFactory.createInterpreterContext(diagramDescription, DescriptionPackage.Literals.DIAGRAM_DESCRIPTION__PRECONDITION_EXPRESSION); }
Source:
<code>public void setRetainUntil(DocumentRef docRef, Calendar retainUntil, String comment) throws PropertyException { Document doc = resolveReference(docRef); checkPermission(doc, READ); if (!doc.isRecord()) { throw new PropertyException("Document is not a record"); } Calendar current = doc.getRetainUntil(); if (Objects.equals(current, retainUntil)) { return; } checkPermission(doc, SET_RETENTION); Map<String, Serializable> options = new HashMap<>(); options.put(CoreEventConstants.RETAIN_UNTIL, retainUntil); <START> boolean retainUntilIndeterminate = retainUntil == null <END> || RETAIN_UNTIL_INDETERMINATE.compareTo(retainUntil) == 0; options.put("comment", retainUntilIndeterminate ? "" : retainUntil.toInstant().toString()); DocumentModel docModel = readModel(doc); boolean currentIndeterminate = current == null || RETAIN_UNTIL_INDETERMINATE.compareTo(current) == 0; String beforeRetentionEvent = currentIndeterminate ? DocumentEventTypes.BEFORE_SET_RETENTION : DocumentEventTypes.BEFORE_EXTEND_RETENTION; notifyEvent(beforeRetentionEvent, docModel, options, null, null, true, false); doc.setRetainUntil(retainUntil); docModel = readModel(doc); String afterRetentionEvent = currentIndeterminate ? DocumentEventTypes.AFTER_SET_RETENTION : DocumentEventTypes.AFTER_EXTEND_RETENTION; notifyEvent(afterRetentionEvent, docModel, options, null, null, true, false); }</code><technical_language>do in code (ie: Objects.equals)</technical_language>

Target:
public void setRetainUntil(DocumentRef docRef, Calendar retainUntil, String comment) throws PropertyException { Document doc = resolveReference(docRef); checkPermission(doc, READ); if (!doc.isRecord()) { throw new PropertyException("Document is not a record"); } Calendar current = doc.getRetainUntil(); if (current!=null && retainUntil!=null && current.compareTo(retainUntil) == 0) { return; } checkPermission(doc, SET_RETENTION); Map<String, Serializable> options = new HashMap<>(); options.put(CoreEventConstants.RETAIN_UNTIL, retainUntil); boolean retainUntilIndeterminate = retainUntil == null || RETAIN_UNTIL_INDETERMINATE.compareTo(retainUntil) == 0; options.put("comment", retainUntilIndeterminate ? "" : retainUntil.toInstant().toString()); DocumentModel docModel = readModel(doc); boolean currentIndeterminate = current == null || RETAIN_UNTIL_INDETERMINATE.compareTo(current) == 0; String beforeRetentionEvent = currentIndeterminate ? DocumentEventTypes.BEFORE_SET_RETENTION : DocumentEventTypes.BEFORE_EXTEND_RETENTION; notifyEvent(beforeRetentionEvent, docModel, options, null, null, true, false); doc.setRetainUntil(retainUntil); docModel = readModel(doc); String afterRetentionEvent = currentIndeterminate ? DocumentEventTypes.AFTER_SET_RETENTION : DocumentEventTypes.AFTER_EXTEND_RETENTION; notifyEvent(afterRetentionEvent, docModel, options, null, null, true, false); }
Source:
<code>public static List<IVariable> getLambdaFrameVariables(IStackFrame frame) throws DebugException { List<IVariable> variables = new ArrayList<>(); <START> IThread thread = frame.getThread(); <END> if (LambdaUtils.isLambdaFrame(frame)) { IStackFrame[] stackFrames = thread.getStackFrames(); for (int i = 0; i < Math.min(3, stackFrames.length); ++i) { IStackFrame stackFrame = stackFrames[i]; IVariable[] stackFrameVariables = stackFrame.getVariables(); variables.addAll(Arrays.asList(stackFrameVariables)); } } return Collections.unmodifiableList(variables); }</code><technical_language>thread is needed if block</technical_language>

Target:
public static List<IVariable> getLambdaFrameVariables(IStackFrame frame) throws DebugException { List<IVariable> variables = new ArrayList<>(); if (LambdaUtils.isLambdaFrame(frame)) { IThread thread = frame.getThread(); IStackFrame[] stackFrames = thread.getStackFrames(); for (int i = 0; i < Math.min(3, stackFrames.length); ++i) { IStackFrame stackFrame = stackFrames[i]; IVariable[] stackFrameVariables = stackFrame.getVariables(); variables.addAll(Arrays.asList(stackFrameVariables)); } } return Collections.unmodifiableList(variables); }
Source:
<code>public static Slice toQuadKey(@SqlType(BingTileType.NAME) long input) { <START> return Slices.utf8Slice(BingTile.decode(input).toQuadKey()); <END> }</code><technical_language>static import utf8Slice</technical_language>

Target:
public static Slice toQuadKey(@SqlType(BingTileType.NAME) long input) { return utf8Slice(BingTile.decode(input).toQuadKey()); }
Source:
<code>public void shouldCreateProfileAndPreferencesOnUserCreation() throws Exception { final User user = new User().withEmail("test@email.com").withName("testName"); <START> new UserManager(userDao, profileDao, preferenceDao, new String[0]).create(user, false); <END> verify(profileDao).create(any(Profile.class)); verify(preferenceDao).setPreferences(anyString(), anyMapOf(String.class, String.class)); }</code><technical_language>mb create instance of UserManager in method annotated @BeforeMethod</technical_language>

Target:
public void shouldCreateProfileAndPreferencesOnUserCreation() throws Exception { final User user = new User().withEmail("test@email.com").withName("testName"); manager.create(user, false); verify(profileDao).create(any(Profile.class)); verify(preferenceDao).setPreferences(anyString(), anyMapOf(String.class, String.class)); }
Source:
<code>public List<RassXmlAgencyEntry> sortRassXmlAgencyEntriesForUpdate(List<RassXmlAgencyEntry> agencies) { AgenciesSortHelper agencySortHelper = new AgenciesSortHelper(); sortAgenciesWithNoReportsToAgency(agencies, agencySortHelper); sortAgenciesWithReportsToAgencyThatHasBeenSorted(agencySortHelper); <START> sortLeftOverAgencies(agencySortHelper); <END> return agencySortHelper.sortedAgencies; }</code><technical_language>left agencies: agencies reports agency sorted? sense update method name more descriptive</technical_language>

Target:
public List<RassXmlAgencyEntry> sortRassXmlAgencyEntriesForUpdate(List<RassXmlAgencyEntry> agencies) { AgenciesSortHelper agencySortHelper = new AgenciesSortHelper(); sortAgenciesWithNoReportsToAgency(agencies, agencySortHelper); sortAgenciesWithReportsToAgencyThatHasBeenSorted(agencySortHelper); sortAnyUnsortedAgencies(agencySortHelper); return agencySortHelper.sortedAgencies; }