auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public JobExecutionResult executeJobBlocking(JobGraph job) throws JobExecutionException, InterruptedException { checkNotNull(job, "job is null"); final CompletableFuture<JobSubmissionResult> submissionFuture = submitJob(job); final CompletableFuture<JobResult> jobResultFuture = submissionFuture.thenCompose( (JobSubmissionResult ignored) -> requestJobResult(job.getJobID())); final JobResult jobResult; try { jobResult = jobResultFuture.get(); } catch (ExecutionException e) { throw new JobExecutionException(job.getJobID(), ApplicationStatus.UNKNOWN, "Could not retrieve JobResult.", ExceptionUtils.stripExecutionException(e)); } try { return jobResult.toJobExecutionResult(Thread.currentThread().getContextClassLoader()); } catch (IOException | ClassNotFoundException e) { <START> throw new JobExecutionException(job.getJobID(), jobResult.getApplicationStatus(), e); <END> } }</code><technical_language>this misleading? For example application successful failed deserialize result status SUCCEEDED exception</technical_language>

Target:
public JobExecutionResult executeJobBlocking(JobGraph job) throws JobExecutionException, InterruptedException { checkNotNull(job, "job is null"); final CompletableFuture<JobSubmissionResult> submissionFuture = submitJob(job); final CompletableFuture<JobResult> jobResultFuture = submissionFuture.thenCompose( (JobSubmissionResult ignored) -> requestJobResult(job.getJobID())); final JobResult jobResult; try { jobResult = jobResultFuture.get(); } catch (ExecutionException e) { throw new JobExecutionException(job.getJobID(), ApplicationStatus.UNKNOWN, "Could not retrieve JobResult.", ExceptionUtils.stripExecutionException(e)); } try { return jobResult.toJobExecutionResult(Thread.currentThread().getContextClassLoader()); } catch (IOException | ClassNotFoundException e) { throw new JobExecutionException(job.getJobID(), jobResult.getApplicationStatus(), "Could not deserialize the serialized accumulator results.", e); } }
Source:
<code>public TestCheckContext(File file, Settings settings, JavaScriptCheck check) { this.file = file; this.complexity = new ComplexityVisitor(); this.settings = settings; try { this.tree = (ScriptTree) p.parse(file); this.symbolModel = SymbolModelImpl.create(tree, null, null); <START> } catch (RecognitionException e) { <END> LOG.error("Unable to parse file: " + file.getAbsolutePath()); LOG.error(e.getMessage()); if ((check.getClass().getSimpleName().equals("ParsingErrorCheck"))) { this.addIssue(null, e.getLine(), e.getMessage()); } } }</code><technical_language>![CRITICAL](<LINK_0> log rethrow this exception. [![rule](<LINK_1>](<LINK_2></technical_language>

Target:
public TestCheckContext(File file, Settings settings, JavaScriptCheck check) { this.file = file; this.complexity = new ComplexityVisitor(); this.settings = settings; try { this.tree = (ScriptTree) p.parse(file); this.symbolModel = SymbolModelImpl.create(tree, null, null); } catch (RecognitionException e) { LOG.error("Unable to parse file: " + file.getAbsolutePath()); LOG.error(e.getMessage()); if ("ParsingErrorCheck".equals(check.getClass().getSimpleName())) { this.addIssue(null, e.getLine(), e.getMessage()); } } }
Source:
<code>private byte[] encrypt(final byte[] plaintext) throws Exception { final byte[] keyBytes = encryptionConfig.encryptionKey.getBytes(); <START> SecretKeySpec keySpec = new SecretKeySpec(keyBytes, encryptionConfig.encryptionAlgorithm); <END> Cipher cipher = Cipher.getInstance(encryptionConfig.encryptionTransformation, encryptionConfig.encryptionProvider); cipher.init(Cipher.ENCRYPT_MODE, keySpec); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); outputStream.write(cipher.getIV()); outputStream.write(cipher.doFinal(plaintext)); return outputStream.toByteArray(); }</code><technical_language>initialize this once</technical_language>

Target:
private byte[] encrypt(final byte[] plaintext) throws Exception { Cipher cipher = Cipher.getInstance( encryptionConfig.encryptionTransformation,encryptionConfig.encryptionProvider); cipher.init(Cipher.ENCRYPT_MODE, keySpec); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); outputStream.write(cipher.getIV()); outputStream.write(cipher.doFinal(plaintext)); return outputStream.toByteArray(); }
Source:
<code>public int knapsackRec(int[] w, int[] v, int n, int W) { <START> if (n <= 0) <END> return 0; else if (w[n - 1] > W) return knapsackRec(w, v, n - 1, W); else return Math.max(knapsackRec(w, v, n - 1, W), v[n - 1] + knapsackRec(w, v, n - 1, W - w[n - 1])); }</code><technical_language>brackets if for single command if sentences, if (...) { ... }, this for new environment, for loops, while,</technical_language>

Target:
public int knapsackRec(int[] w, int[] v, int n, int W) { if (n <= 0) { return 0; } else if (w[n - 1] > W) { return knapsackRec(w, v, n - 1, W); } else { return Math.max(knapsackRec(w, v, n - 1, W), v[n - 1] + knapsackRec(w, v, n - 1, W - w[n - 1])); } }
Source:
<code>private void initCustomPermissionAuthority() { <START> ReadOnlyPermissionAuthority readOnlyPermissionAuthority = new ReadOnlyPermissionAuthority(); <END> IPermissionProvider permissionProvider = new DefaultPermissionProvider(readOnlyPermissionAuthority); StandalonePermissionProviderDescriptor permissionProviderDescriptor = new StandalonePermissionProviderDescriptor("org.eclipse.sirius.tree.tests.forbiddenPermissionAuthorityProvider", ExtenderConstants.HIGHEST_PRIORITY, permissionProvider); PermissionService.addExtension(permissionProviderDescriptor); }</code><technical_language>replace PermissionService.createDefaultPermissionAuthority</technical_language>

Target:
private void initCustomPermissionAuthority() { IPermissionAuthority permissionAuthority = PermissionService .createDefaultPermissionAuthority(); IPermissionProvider permissionProvider = new DefaultPermissionProvider( permissionAuthority); StandalonePermissionProviderDescriptor permissionProviderDescriptor = new StandalonePermissionProviderDescriptor( "org.eclipse.sirius.tree.tests.forbiddenPermissionAuthorityProvider", ExtenderConstants.HIGHEST_PRIORITY, permissionProvider); PermissionService.addExtension(permissionProviderDescriptor); }
Source:
<code>private void handleDeeplink(Uri uri) { if (uri == null || uri.getPath() == null) { return; } switch (uri.getPath()) { case "/search": String query = uri.getQueryParameter("query"); if (query == null) { return; } this.loadChildFragment(OnlineSearchFragment.newInstance(CombinedSearcher.class, query)); break; case "/main": String feature = uri.getQueryParameter("featureName"); if (feature == null) { return; } feature = feature.toLowerCase(); switch (feature) { <START> case "downloads": <END> loadFragment(DownloadsFragment.TAG, null); break; case "history": loadFragment(PlaybackHistoryFragment.TAG, null); break; case "episodes": loadFragment(EpisodesFragment.TAG, null); break; case "queue": loadFragment(QueueFragment.TAG, null); break; case "subscriptions": loadFragment(SubscriptionFragment.TAG, null); break; default: loadFragment(AddFeedFragment.TAG, null); break; } break; } }</code><technical_language>This pretty similar switch in loadFragment. re-used instead of creating another switch</technical_language>

Target:
private void handleDeeplink(Uri uri) { if (uri == null || uri.getPath() == null) { return; } switch (uri.getPath()) { case "/deeplink/search": String query = uri.getQueryParameter("query"); if (query == null) { return; } this.loadChildFragment(OnlineSearchFragment.newInstance(CombinedSearcher.class, query)); break; case "/deeplink/main": String feature = uri.getQueryParameter("featureName"); if (feature == null) { return; } feature = feature.toLowerCase(Locale.getDefault()); switch (feature) { case "downloads": loadFragment(DownloadsFragment.TAG, null); break; case "history": loadFragment(PlaybackHistoryFragment.TAG, null); break; case "episodes": loadFragment(EpisodesFragment.TAG, null); break; case "queue": loadFragment(QueueFragment.TAG, null); break; case "subscriptions": loadFragment(SubscriptionFragment.TAG, null); break; default: loadFragment(AddFeedFragment.TAG, null); break; } break; default: break; } }
Source:
<code>public ExecutionError filter(ExecutionErrorContext errorContext) { Builder errorBuilder = ExecutionError.builder().type("DB"); <START> StringWriter writer = new StringWriter(); <END> PrintWriter p = new PrintWriter(writer); errorContext.getCause().printStackTrace(p); String stacktrace = writer.toString(); Task task = errorContext.getLastExecutedTask(); NodeInstance nodeInstance = errorContext.getLastExecutedNode(); logger.debug("Last executed node instance {}, last executed task {}", nodeInstance, task); if (nodeInstance != null) { logger.debug("Last executed node instance will be used to populate error details", nodeInstance); errorBuilder .deploymentId(((ProcessInstanceImpl)nodeInstance.getProcessInstance()).getDeploymentId()) .processInstanceId(nodeInstance.getProcessInstance().getId()) .processId(nodeInstance.getProcessInstance().getProcessId()) .activityId(nodeInstance.getId()) .activityName(nodeName(nodeInstance)); } else if (task != null) { logger.debug("Last executed task will be used to populate error details", task); errorBuilder .deploymentId(task.getTaskData().getDeploymentId()) .processInstanceId(task.getTaskData().getProcessInstanceId()) .processId(task.getTaskData().getProcessId()) .activityId(task.getId()) .activityName(task.getName()); } return errorBuilder .message(errorContext.getCause().getMessage()) .error(stacktrace) .errorDate(new Date()) .build(); }</code><technical_language>I 4 instances of this block of code making a string exception's stacktrace - a helper class encapsulate (even trivial) logic</technical_language>

Target:
public ExecutionError filter(ExecutionErrorContext errorContext) { Builder errorBuilder = ExecutionError.builder().type("DB"); String stacktrace = getStackTrace(errorContext.getCause()); Task task = errorContext.getLastExecutedTask(); NodeInstance nodeInstance = errorContext.getLastExecutedNode(); logger.debug("Last executed node instance {}, last executed task {}", nodeInstance, task); if (nodeInstance != null) { logger.debug("Last executed node instance will be used to populate error details", nodeInstance); errorBuilder .deploymentId(((ProcessInstanceImpl)nodeInstance.getProcessInstance()).getDeploymentId()) .processInstanceId(nodeInstance.getProcessInstance().getId()) .processId(nodeInstance.getProcessInstance().getProcessId()) .activityId(nodeInstance.getId()) .activityName(nodeName(nodeInstance)); } else if (task != null) { logger.debug("Last executed task will be used to populate error details", task); errorBuilder .deploymentId(task.getTaskData().getDeploymentId()) .processInstanceId(task.getTaskData().getProcessInstanceId()) .processId(task.getTaskData().getProcessId()) .activityId(task.getId()) .activityName(task.getName()); } return errorBuilder .message(errorContext.getCause().getMessage()) .error(stacktrace) .errorDate(new Date()) .build(); }
Source:
<code>public void onEvent(Event event, Object source, Object data) { try { List<UntypedRecordableEventDescriptor> descriptors = componentManager.getInstanceList(UntypedRecordableEventDescriptor.class); for (UntypedRecordableEventDescriptor descriptor : descriptors) { <START> if (descriptor.getEventTriggers().contains(event.getClass().getCanonicalName()) <END> && checkXObjectCondition(descriptor, source) && this.evaluateVelocityTemplate( event, descriptor.getAuthorReference(), descriptor.getValidationExpression())) { observationManager.notify( new DefaultUntypedRecordableEvent(descriptor.getEventType()), "org.xwiki.platform:xwiki-platform-eventstream-api", source); } } } catch (ComponentLookupException e) { logger.warn( String.format("Unable to retrieve UntypedRecordableEventDescriptor from the ComponentManager. " + "Error : %s", e.getMessage())); } }</code><technical_language>discussed, this design sense me. event triggers role hint(s) of RecordableEventDescriptor instead of requesting descriptors time get event type (the class of event a untyped event in case event#getEventType())</technical_language>

Target:
public void onEvent(Event event, Object source, Object data) { try { List<UntypedRecordableEventDescriptor> descriptors = componentManager.getInstanceList(UntypedRecordableEventDescriptor.class); for (UntypedRecordableEventDescriptor descriptor : descriptors) { if (descriptor.getEventTriggers().contains(event.getClass().getCanonicalName()) && checkXObjectCondition(descriptor, source) && this.evaluateVelocityTemplate( event, descriptor.getAuthorReference(), descriptor.getValidationExpression())) { observationManager.notify( new DefaultUntypedRecordableEvent(descriptor.getEventType()), "org.xwiki.platform:xwiki-platform-eventstream-api", source); } } } catch (ComponentLookupException e) { logger.error("Unable to retrieve a list of registered UntypedRecordableEventDescriptor " + "from the ComponentManager.", e); } }
Source:
<code>public void testCrossJoinPreserveSortOrderNoJoinStrategyHint() throws Exception { String sqlText = format("select tt2.a from \n" + "tab2 tt2 --splice-properties useSpark=%s\n" + "inner join %s ttb\n" + "on ttb.c2 < 5 and tt2.a < 4 order by tt2.a", useSpark, bigTable); if (useSpark) { <START> ResultSet rs = classWatcher.executeQuery("explain " + sqlText); <END> String matchString = TestUtils.FormattedResult.ResultFactory.toStringUnsorted(rs); assertTrue("Cross join is not selected for OLAP", matchString.contains("CrossJoin")); } String expected = "A |\n" + "----\n" + " 1 |\n" + " 1 |\n" + " 1 |\n" + " 1 |\n" + " 2 |\n" + " 2 |\n" + " 2 |\n" + " 2 |\n" + " 3 |\n" + " 3 |\n" + " 3 |\n" + " 3 |"; ResultSet rs = classWatcher.executeQuery(sqlText); String resultString = TestUtils.FormattedResult.ResultFactory.toStringUnsorted(rs); assertEquals("\n" + sqlText + "\n" + "expected result: " + expected + "\n,actual result: " + resultString, expected, resultString); rs.close(); }</code><technical_language>try-with-resources auto close resultset</technical_language>

Target:
public void testCrossJoinPreserveSortOrderNoJoinStrategyHint() throws Exception { String sqlText = format("select tt2.a from \n" + "tab2 tt2 --splice-properties useSpark=%s\n" + "inner join %s ttb\n" + "on ttb.c2 < 5 and tt2.a < 4 order by tt2.a", useSpark, bigTable); if (useSpark) { try (ResultSet rs = classWatcher.executeQuery("explain " + sqlText)) { String matchString = TestUtils.FormattedResult.ResultFactory.toStringUnsorted(rs); assertTrue("Cross join is not selected for OLAP", matchString.contains("CrossJoin")); } } String expected = "A |\n" + "----\n" + " 1 |\n" + " 1 |\n" + " 1 |\n" + " 1 |\n" + " 2 |\n" + " 2 |\n" + " 2 |\n" + " 2 |\n" + " 3 |\n" + " 3 |\n" + " 3 |\n" + " 3 |"; try (ResultSet rs = classWatcher.executeQuery(sqlText)) { String resultString = TestUtils.FormattedResult.ResultFactory.toStringUnsorted(rs); assertEquals("\n" + sqlText + "\n" + "expected result: " + expected + "\n,actual result: " + resultString, expected, resultString); } }
Source:
<code>public String toString() { <START> return "Bing tile [" + x + ", " + y + "] at level " + zoomLevel; <END> }</code><technical_language>nit: com.google.common.base.MoreObjects.toStringHelper in other classes</technical_language>

Target:
public String toString() { return toStringHelper(this) .add("x", x) .add("y", y) .add("zoom_level", zoomLevel) .toString(); }
Source:
<code>protected VdcReturnValueBase checkAndPerformRollbackUsingCommand(VdcActionType commandType, VdcActionParametersBase params, CommandContext context) { <START> VdcReturnValueBase result = new VdcReturnValueBase(); <END> if (canPerformRollbackUsingCommand(commandType, params)) { result = runInternalCommandOnRollback(commandType, params, context); } else { result.setSucceeded(false); } return result; }</code><technical_language>need instantiate a variable a line override it. Move instantiate 'else' clause</technical_language>

Target:
protected VdcReturnValueBase checkAndPerformRollbackUsingCommand(VdcActionType commandType, VdcActionParametersBase params, CommandContext context) { VdcReturnValueBase result = null; if (canPerformRollbackUsingCommand(commandType, params)) { result = runInternalCommandOnRollback(commandType, params, context); } else { result = new VdcReturnValueBase(); result.setSucceeded(false); } return result; }
Source:
<code>public void test_abidw() throws Exception { String[] cmd = new String[] { mKernelImageCheckTool.getAbsolutePath() + "/abidw", "--linux-tree", mKernelImageFile.getParent(), "--out-file", "abi-new.out" }; CommandResult result = <START> RunUtil.getDefault().runTimedCmd(1000000, cmd); <END> CLog.i("Result stdout: %s", result.getStdout()); CLog.e("Result stderr: %s", result.getStderr()); assertEquals(result.getStatus(), CommandStatus.SUCCESS); }</code><technical_language>nit: static</technical_language>

Target:
public void test_abidw() throws Exception { String[] cmd = new String[] { mKernelImageCheckTool.getAbsolutePath() + "/abidw", "--linux-tree", mKernelImageFile.getParent(), "--out-file", "abi-new.out" }; CommandResult result = RunUtil.getDefault().runTimedCmd(CMD_TIMEOUT, cmd); CLog.i("Result stdout: %s", result.getStdout()); if (result.getExitCode() != 0) { CLog.e("Result stderr: %s", result.getStderr()); } assertEquals(CommandStatus.SUCCESS, result.getStatus()); cmd = new String[] { mKernelImageCheckTool.getAbsolutePath() + "/abidiff", "abi-new.out", mKernelAbiFile.getAbsolutePath() }; result = RunUtil.getDefault().runTimedCmd(CMD_TIMEOUT, cmd); CLog.i("Result stdout: %s", result.getStdout()); if (result.getExitCode() != 0) { CLog.e("Result stderr: %s", result.getStderr()); } assertEquals(CommandStatus.SUCCESS, result.getStatus()); }
Source:
<code>public void testTimeoutToHost() { bot.view("Package Explorer").show(); bot.menu("File").click(); bot.menu("File").menu("Import...").click(); bot.shell("Import"); SWTBotTree tree = bot.tree(0); tree.expandNode("Git").select("Git Repository"); bot.button("Next >").click(); bot.shell("Import Git Repository"); bot.textWithLabel("URI:").setText("git://www.example.com/EGIT"); assertSourceParams(null, "www.example.com", "/EGIT", "git", "", true, "", "", false, false); bot.button("Next >").click(); <START> assertStartsWith(" git://www.example.com/EGIT: Connection timed out", <END> bot.text(0).getText()); assertTrue(bot.button("Cancel").isEnabled()); assertTrue(bot.button("< Back").isEnabled()); assertFalse(bot.button("Next >").isEnabled()); assertFalse(bot.button("Finish").isEnabled()); bot.button("Cancel").click(); }</code><technical_language>EGit behaves differently this test expects, timeout is reached display error wizard page raises extra error popup Transport error Reason: git://www.example.com/EGIT: connection timeout: connect this assert fails consistently</technical_language>

Target:
public void testTimeoutToHost() { goToImportGitRepository(); bot.textWithLabel("URI:").setText("git://www.example.com/EGIT"); assertSourceParams(null, "www.example.com", "/EGIT", "git", "", true, "", "", false, false); bot.button("Next >").click(); assertStartsWith(" git://www.example.com/EGIT: Connection timed out", bot.text(0).getText()); assertTrue(bot.button("Cancel").isEnabled()); assertTrue(bot.button("< Back").isEnabled()); assertFalse(bot.button("Next >").isEnabled()); assertFalse(bot.button("Finish").isEnabled()); bot.button("Cancel").click(); }
Source:
<code>private PatchLineComment update(PatchLineComment e, Input in) { if (in.side != null) { e.setSide(in.side == Side.PARENT ? (short) 0 : (short) 1); } if (in.inReplyTo != null) { e.setParentUuid(Url.decode(in.inReplyTo)); } e.setMessage(in.message.trim()); <START> Integer line = in.line; <END> CommentRange range = in.range; if (range != null || line != null) { e.setRange(range); e.setLine(line == null ? range.getEndLine() : line); } e.updated(); return e; }</code><technical_language>I locals worthwhile</technical_language>

Target:
private PatchLineComment update(PatchLineComment e, Input in) { if (in.side != null) { e.setSide(in.side == Side.PARENT ? (short) 0 : (short) 1); } if (in.inReplyTo != null) { e.setParentUuid(Url.decode(in.inReplyTo)); } e.setMessage(in.message.trim()); if (in.range != null || in.line != null) { e.setRange(in.range); e.setLine(in.range != null ? in.range.getEndLine() : in.line); } e.updated(); return e; }
Source:
<code>public ProxyAuthenticator createProxyAuthenticator() throws AxisFault { <START> if (!isProxyHasCredential()) return null; <END> ProxyAuthenticator proxyAuthenticator; try { if (isProxyProfileConfigured()) { proxyAuthenticator = new ProfileProxyAuthenticator(this); } else { proxyAuthenticator = new DefaultProxyAuthenticator(getCreds()); } } catch (MalformedChallengeException e) { throw new AxisFault("Error while creating proxy authenticator", e); } return proxyAuthenticator; }</code><technical_language>of braces { } of number of lines is practise , example refer lines in code</technical_language>

Target:
public ProxyAuthenticator createProxyAuthenticator() throws AxisFault { if (!isProxyHasCredential()) { return null; } ProxyAuthenticator proxyAuthenticator; try { if (isProxyProfileConfigured()) { proxyAuthenticator = new ProfileProxyAuthenticator(this); } else { proxyAuthenticator = new DefaultProxyAuthenticator(getCreds()); } } catch (MalformedChallengeException e) { throw new AxisFault("Error while creating proxy authenticator", e); } return proxyAuthenticator; }
Source:
<code>public RVRendererAdapter<String> create(List<String> searchImageItemList) { <START> SearchCategoriesRenderer searchCategoriesRenderer = new SearchCategoriesRenderer(listener); <END> RendererBuilder<String> builder = new RendererBuilder<String>().bind(String.class, searchCategoriesRenderer); ListAdapteeCollection<String> collection = new ListAdapteeCollection<>( searchImageItemList != null ? searchImageItemList : Collections.<String>emptyList()); return new RVRendererAdapter<>(builder, collection); }</code><technical_language>Unrelated change</technical_language>

Target:
public RVRendererAdapter<String> create(List<String> searchImageItemList) { RendererBuilder<String> builder = new RendererBuilder<String>().bind(String.class, new SearchCategoriesRenderer(listener)); ListAdapteeCollection<String> collection = new ListAdapteeCollection<>( searchImageItemList != null ? searchImageItemList : Collections.<String>emptyList()); return new RVRendererAdapter<>(builder, collection); }
Source:
<code>public void onMessage(final Message message, final Channel channel) throws Exception { <START> boolean retryEnabled = AmqpInboundChannelAdapter.this.retryTemplate == null; <END> try { if (retryEnabled) { createAndSend(message, channel); } else { final org.springframework.messaging.Message<Object> toSend = createMessage(message, channel); AmqpInboundChannelAdapter.this.retryTemplate.execute(context -> { StaticMessageHeaderAccessor.getDeliveryAttempt(toSend).incrementAndGet(); setAttributesIfNecessary(message, toSend); sendMessage(toSend); return null; }, (RecoveryCallback<Object>) AmqpInboundChannelAdapter.this.recoveryCallback); } } catch (MessageConversionException e) { if (getErrorChannel() != null) { setAttributesIfNecessary(message, null); getMessagingTemplate().send(getErrorChannel(), buildErrorMessage(null, new ListenerExecutionFailedException("Message conversion failed", e, message))); } else { throw e; } } finally { if (retryEnabled) { attributesHolder.remove(); } } }</code><technical_language>wrong name for variable wrong boolean operation. In feeling retry is enabled retryTemplate != null. do mean</technical_language>

Target:
public void onMessage(final Message message, final Channel channel) throws Exception { boolean retryDisabled = AmqpInboundChannelAdapter.this.retryTemplate == null; try { if (retryDisabled) { createAndSend(message, channel); } else { final org.springframework.messaging.Message<Object> toSend = createMessage(message, channel); AmqpInboundChannelAdapter.this.retryTemplate.execute(context -> { StaticMessageHeaderAccessor.getDeliveryAttempt(toSend).incrementAndGet(); setAttributesIfNecessary(message, toSend); sendMessage(toSend); return null; }, (RecoveryCallback<Object>) AmqpInboundChannelAdapter.this.recoveryCallback); } } catch (MessageConversionException e) { if (getErrorChannel() != null) { setAttributesIfNecessary(message, null); getMessagingTemplate().send(getErrorChannel(), buildErrorMessage(null, new ListenerExecutionFailedException("Message conversion failed", e, message))); } else { throw e; } } finally { if (retryDisabled) { attributesHolder.remove(); } } }
Source:
<code>public LogParserPublisher(Job parent, String path) { super(parent, path); <START> controlMarkOnUnstableWarning = control("unstableOnWarning"); <END> controlMarkOnBuildFail = control("failBuildOnError"); controlShowGraphs = control("showGraphs"); controlRuleType = control("useProjectRule"); }</code><technical_language>initialize controls in field declaration</technical_language>

Target:
public LogParserPublisher(Job parent, String path) { super(parent, path); }
Source:
<code>private void revertLocalStateEdit(TurboIssue modifiedIssue, boolean isOpenOriginally) { TurboIssue currentIssue = getIssue(modifiedIssue.getRepoId(), modifiedIssue.getId()).orElse(modifiedIssue); LocalDateTime originalStateModifiedAt = modifiedIssue.getStateLastModifiedAt(); LocalDateTime currentStateModifiedAt = currentIssue.getStateLastModifiedAt(); boolean isCurrentStateModifiedOriginalState = originalStateModifiedAt.isEqual(currentStateModifiedAt); if (isCurrentStateModifiedOriginalState) { <START> return; <END> } logger.info("Reverting state for issue " + currentIssue); models.editIssueState(currentIssue.getRepoId(), currentIssue.getId(), isOpenOriginally); refreshUI(); }</code><technical_language>some logs report this scenario</technical_language>

Target:
private void revertLocalStateEdit(TurboIssue modifiedIssue, boolean isOpenOriginally) { TurboIssue currentIssue = getIssue(modifiedIssue.getRepoId(), modifiedIssue.getId()).orElse(modifiedIssue); LocalDateTime originalStateModifiedAt = modifiedIssue.getStateLastModifiedAt(); LocalDateTime currentStateModifiedAt = currentIssue.getStateLastModifiedAt(); boolean isCurrentStateModifiedFromOriginalState = originalStateModifiedAt.isEqual(currentStateModifiedAt); if (!isCurrentStateModifiedFromOriginalState) { logger.warn("Not reverting state for issue " + currentIssue + " as it is modified somewhere else."); return; } logger.info("Reverting state for issue " + currentIssue); models.editIssueState(currentIssue.getRepoId(), currentIssue.getId(), isOpenOriginally); refreshUI(); }
Source:
<code>private List<FeedbackResponse> getFeedbackResponseEntitiesFromGiverForQuestion( String feedbackQuestionId, String giverEmail) { return load() .filter("feedbackQuestionId =", feedbackQuestionId) <START> .filter("giver =", giverEmail) <END> .list(); }</code><technical_language>field is stored giverEmail in database. Simply change query work</technical_language>

Target:
private List<FeedbackResponse> getFeedbackResponseEntitiesFromGiverForQuestion( String feedbackQuestionId, String giverEmail) { return load() .filter("feedbackQuestionId =", feedbackQuestionId) .filter("giverEmail =", giverEmail) .list(); }
Source:
<code>private RecordsRetrieved peekNextResult() { throwOnIllegalState(); <START> return publisherSession.prefetchRecordsQueue().peek(); <END> }</code><technical_language>nice abstract queue session. i.e. publisherSession.peekNext()</technical_language>

Target:
private PrefetchRecordsRetrieved peekNextResult() { throwOnIllegalState(); return publisherSession.peekNextRecord(); }
Source:
<code>private void handleStructureLine(String line) { int index = line.indexOf('='); if ((index > 0) && (index < (line.length() - 1))) { String formatString = line.substring(index + 1); <START> setDefault = line.substring(0, index).equals(OOBibStyle.DEFAULT_MARK); <END> EntryType type = EntryTypeFactory.parse(line.substring(0, index)); try { Layout layout = new LayoutHelper(new StringReader(formatString), this.prefs).getLayoutFromText(); if (setDefault) { defaultBibLayout = layout; } else { bibLayout.put(type, layout); } } catch (IOException ex) { LOGGER.warn("Cannot parse bibliography structure", ex); } } }</code><technical_language>Please fix ident</technical_language>

Target:
private void handleStructureLine(String line) { int index = line.indexOf('='); if ((index > 0) && (index < (line.length() - 1))) { String formatString = line.substring(index + 1); isDefaultLayoutPresent = line.substring(0, index).equals(OOBibStyle.DEFAULT_MARK); EntryType type = EntryTypeFactory.parse(line.substring(0, index)); try { Layout layout = new LayoutHelper(new StringReader(formatString), this.prefs).getLayoutFromText(); if (isDefaultLayoutPresent) { defaultBibLayout = layout; } else { bibLayout.put(type, layout); } } catch (IOException ex) { LOGGER.warn("Cannot parse bibliography structure", ex); } } }
Source:
<code>private void createMessageArea(Composite parent, FormToolkit toolkit, int span) { Section messageSection = createSection(parent, toolkit, span); Composite messageArea = createSectionClient(messageSection, toolkit); messageSection.setText(UIText.CommitEditorPage_SectionMessage); RevCommit commit = getCommit().getRevCommit(); String message = commit.getFullMessage(); PersonIdent author = commit.getAuthorIdent(); if (author != null) message = replaceSignedOffByLine(message, author); PersonIdent committer = commit.getCommitterIdent(); if (committer != null) message = replaceSignedOffByLine(message, committer); SpellcheckableMessageArea textContent = new SpellcheckableMessageArea( messageArea, message, true, toolkit.getBorderStyle()) { @Override protected IAdaptable getDefaultTarget() { return new PlatformObject() { @Override public Object getAdapter(Class adapter) { return Platform.getAdapterManager().getAdapter( getEditorInput(), adapter); } }; } @Override protected void createMarginPainter() { } }; if ((toolkit.getBorderStyle() & SWT.BORDER) == 0) textContent.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); Point size = textContent.getTextWidget().computeSize(SWT.DEFAULT, SWT.DEFAULT); int yHint = size.y > 80 ? 80 : SWT.DEFAULT; GridDataFactory.fillDefaults().hint(SWT.DEFAULT, yHint).minSize(1, 20) .grab(true, true).applyTo(textContent); Control control = textContent.getTextWidget(); <START> if (control != null) { <END> addToFocusTracking(control); } updateSectionClient(messageSection, messageArea, toolkit); }</code><technical_language>textContent.getTextWidget() is guaranteed != null line 441</technical_language>

Target:
private void createMessageArea(Composite parent, FormToolkit toolkit, int span) { Section messageSection = createSection(parent, toolkit, span); Composite messageArea = createSectionClient(messageSection, toolkit); messageSection.setText(UIText.CommitEditorPage_SectionMessage); RevCommit commit = getCommit().getRevCommit(); String message = commit.getFullMessage(); PersonIdent author = commit.getAuthorIdent(); if (author != null) message = replaceSignedOffByLine(message, author); PersonIdent committer = commit.getCommitterIdent(); if (committer != null) message = replaceSignedOffByLine(message, committer); SpellcheckableMessageArea textContent = new SpellcheckableMessageArea( messageArea, message, true, toolkit.getBorderStyle()) { @Override protected IAdaptable getDefaultTarget() { return new PlatformObject() { @Override public Object getAdapter(Class adapter) { return Platform.getAdapterManager().getAdapter( getEditorInput(), adapter); } }; } @Override protected void createMarginPainter() { } }; if ((toolkit.getBorderStyle() & SWT.BORDER) == 0) textContent.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); StyledText textWidget = textContent.getTextWidget(); Point size = textWidget.computeSize(SWT.DEFAULT, SWT.DEFAULT); int yHint = size.y > 80 ? 80 : SWT.DEFAULT; GridDataFactory.fillDefaults().hint(SWT.DEFAULT, yHint).minSize(1, 20) .grab(true, true).applyTo(textContent); addToFocusTracking(textWidget); updateSectionClient(messageSection, messageArea, toolkit); }
Source:
<code>private void onRegisterButtonClick() { String username = usernameInputLayout.getEditText().getText().toString().trim(); String password = passwordInputLayout.getEditText().getText().toString(); String passwordConfirmation = confirmPasswordInputLayout.getEditText().getText().toString(); String email = emailInputLayout.getEditText().getText().toString(); if (username.contains("@")) { showErrorAlertDialog(R.string.register_email_as_username_error); } else if (password.equals(passwordConfirmation)) { RegistrationTask registrationTask = new RegistrationTask(getActivity(), username, password, email); registrationTask.setOnRegistrationCompleteListener(this); registrationTask.execute(); } else { <START> showErrorAlertDialog(R.string.register_password_mismatch); <END> } }</code><technical_language>Please change order of if-else statements if ("@" in username) show error else if (not password equals) show error else execute registration task</technical_language>

Target:
private void onRegisterButtonClick() { String username = usernameInputLayout.getEditText().getText().toString().trim(); String password = passwordInputLayout.getEditText().getText().toString(); String passwordConfirmation = confirmPasswordInputLayout.getEditText().getText().toString(); String email = emailInputLayout.getEditText().getText().toString(); if (username.contains("@")) { showErrorAlertDialog(R.string.register_email_as_username_error); } else if (!password.equals(passwordConfirmation)) { showErrorAlertDialog(R.string.register_password_mismatch); } else { RegistrationTask registrationTask = new RegistrationTask(getActivity(), username, password, email); registrationTask.setOnRegistrationCompleteListener(this); registrationTask.execute(); } }
Source:
<code>public void handleError(HttpCommand command, HttpResponse response) { String message = parseMessage(response); Exception exception = message != null ? new HttpResponseException(command, response, message) : new HttpResponseException(command, response); try { message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine()); switch (response.getStatusCode()) { case 400: if ((command.getCurrentRequest().getEndpoint().getPath().endsWith("/info")) || (message != null && message.indexOf("could not be found") != -1)) exception = new ResourceNotFoundException(message, exception); else if (message != null && message.indexOf("currently in use") != -1) exception = new IllegalStateException(message, exception); else exception = new IllegalArgumentException(message, exception); break; case 401: exception = new AuthorizationException(message, exception); break; case 402: exception = new IllegalStateException(message, exception); break; case 404: <START> exception = new ResourceNotFoundException(message, exception); <END> break; case 405: exception = new IllegalArgumentException(message, exception); break; case 409: exception = new IllegalStateException(message, exception); break; } } finally { closeQuietly(response.getPayload()); command.setException(exception); } }</code><technical_language>why</technical_language>

Target:
public void handleError(HttpCommand command, HttpResponse response) { String message = parseMessage(response); Exception exception = message != null ? new HttpResponseException(command, response, message) : new HttpResponseException(command, response); try { message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine()); switch (response.getStatusCode()) { case 400: if ((command.getCurrentRequest().getEndpoint().getPath().endsWith("/info")) || (message != null && message.indexOf("could not be found") != -1)) exception = new ResourceNotFoundException(message, exception); else if (message != null && message.indexOf("currently in use") != -1) exception = new IllegalStateException(message, exception); else exception = new IllegalArgumentException(message, exception); break; case 401: exception = new AuthorizationException(message, exception); break; case 402: exception = new IllegalStateException(message, exception); break; case 404: if (!command.getCurrentRequest().getMethod().equals("DELETE")) { exception = new ResourceNotFoundException(message, exception); } break; case 405: exception = new IllegalArgumentException(message, exception); break; case 409: exception = new IllegalStateException(message, exception); break; } } finally { closeQuietly(response.getPayload()); command.setException(exception); } }
Source:
<code>public void testDescribeTable() { sql("describe tbl").ok("DESCRIBE `TBL`"); sql("describe extended tbl").ok("DESCRIBE EXTENDED `TBL`"); sql("describe formatted tbl").ok("DESCRIBE EXTENDED `TBL`"); <START> } <END></code><technical_language>describe formatted tbl => DESCRIBE FORMATTED TBL</technical_language>

Target:
public void testDescribeTable() { sql("describe tbl").ok("DESCRIBE `TBL`"); sql("describe extended tbl").ok("DESCRIBE EXTENDED `TBL`"); sql("describe formatted tbl").ok("DESCRIBE FORMATTED `TBL`"); }
Source:
<code>public void addOrganisationToUser(final String userId, final String organisationId) { try { final User intercomUser = User.find(userId); <START> final Company company = Company.find(organisationId); <END> intercomUser.addCompany(company); User.update(intercomUser); } catch (final Exception e) { logger.warn("Error adding organisation with id: to Intercom user with id: - ", organisationId, userId, e.getMessage()); } }</code><technical_language>spend some time understanding Intercom API find out need a Company is read Intercom create a new Company associate user. is createUser method avoid potential race conditions Company is created calling this method</technical_language>

Target:
public void addOrganisationToUser(final String userId, final String organisationId) { try { final User intercomUser = User.find(userId); final Company company = new Company(); company.setCompanyID(organisationId); intercomUser.addCompany(company); User.update(intercomUser); } catch (final Exception e) { logger.warn("Error adding organisation with id: to Intercom user with id: - ", organisationId, userId, e.getMessage()); } }
Source:
<code>protected State calculateNextState(final int permits, final long timeoutInNanos, final State activeState) { <START> long cyclePeriodInNanos = activeState.getConfig().getLimitRefreshPeriod().toNanos(); <END> int permissionsPerCycle = activeState.getConfig().getLimitForPeriod(); long currentNanos = currentNanoTime(); long currentCycle = currentNanos / cyclePeriodInNanos; long nextCycle = activeState.activeCycle; int nextPermissions = activeState.getActivePermissions(); if (nextCycle != currentCycle) { long elapsedCycles = currentCycle - nextCycle; long accumulatedPermissions = elapsedCycles * permissionsPerCycle; nextCycle = currentCycle; nextPermissions = (int) min(nextPermissions + accumulatedPermissions, permissionsPerCycle); } long nextNanosToWait = nanosToWaitForPermission( permits, cyclePeriodInNanos, permissionsPerCycle, nextPermissions, currentNanos, currentCycle ); State nextState = reservePermissions(activeState.getConfig(), permits, timeoutInNanos, nextCycle, nextPermissions, nextNanosToWait); return nextState; }</code><technical_language>Move activeState.getConfig() separate variable</technical_language>

Target:
protected State calculateNextState(final int permits, final long timeoutInNanos, final State activeState) { RateLimiterConfig config = activeState.getConfig(); long cyclePeriodInNanos = config.getLimitRefreshPeriod().toNanos(); int permissionsPerCycle = config.getLimitForPeriod(); long currentNanos = currentNanoTime(); long currentCycle = currentNanos / cyclePeriodInNanos; long nextCycle = activeState.activeCycle; int nextPermissions = activeState.getActivePermissions(); if (nextCycle != currentCycle) { long elapsedCycles = currentCycle - nextCycle; long accumulatedPermissions = elapsedCycles * permissionsPerCycle; nextCycle = currentCycle; nextPermissions = (int) min(nextPermissions + accumulatedPermissions, permissionsPerCycle); } long nextNanosToWait = nanosToWaitForPermission( permits, cyclePeriodInNanos, permissionsPerCycle, nextPermissions, currentNanos, currentCycle ); State nextState = reservePermissions(config, permits, timeoutInNanos, nextCycle, nextPermissions, nextNanosToWait); return nextState; }
Source:
<code>private void cookies(MockHttpServletRequest request) { List<Cookie> cookies = new ArrayList<>(); String cookieHeaderValue = header("Cookie"); if (cookieHeaderValue != null) { StringTokenizer tokens = new StringTokenizer(cookieHeaderValue, "=;"); while (tokens.hasMoreTokens()) { String cookieName = tokens.nextToken().trim(); Assert.isTrue(tokens.hasMoreTokens(), () -> "Expected value for cookie name '" + cookieName + "': full cookie header was [" + cookieHeaderValue + "]"); String cookieValue = tokens.nextToken().trim(); processCookie(request, cookies, new Cookie(cookieName, cookieValue)); } } Set<com.gargoylesoftware.htmlunit.util.Cookie> managedCookies = this.webClient.getCookies(this.webRequest.getUrl()); for (com.gargoylesoftware.htmlunit.util.Cookie cookie : managedCookies) { processCookie(request, cookies, new Cookie(cookie.getName(), cookie.getValue())); } Cookie[] parentCookies = request.getCookies(); if (parentCookies != null) { <START> cookies.addAll(Arrays.asList(parentCookies)); <END> } if (!ObjectUtils.isEmpty(cookies)) { request.setCookies(cookies.toArray(new Cookie[0])); } }</code><technical_language>Please avoid creation of extra ArrayList follows. suggestion Collections.addAll(cookies, parentCookies);</technical_language>

Target:
private void cookies(MockHttpServletRequest request) { List<Cookie> cookies = new ArrayList<>(); String cookieHeaderValue = header("Cookie"); if (cookieHeaderValue != null) { StringTokenizer tokens = new StringTokenizer(cookieHeaderValue, "=;"); while (tokens.hasMoreTokens()) { String cookieName = tokens.nextToken().trim(); Assert.isTrue(tokens.hasMoreTokens(), () -> "Expected value for cookie name '" + cookieName + "': full cookie header was [" + cookieHeaderValue + "]"); String cookieValue = tokens.nextToken().trim(); processCookie(request, cookies, new Cookie(cookieName, cookieValue)); } } Set<com.gargoylesoftware.htmlunit.util.Cookie> managedCookies = this.webClient.getCookies(this.webRequest.getUrl()); for (com.gargoylesoftware.htmlunit.util.Cookie cookie : managedCookies) { processCookie(request, cookies, new Cookie(cookie.getName(), cookie.getValue())); } Cookie[] parentCookies = request.getCookies(); if (parentCookies != null) { Collections.addAll(cookies, parentCookies); } if (!ObjectUtils.isEmpty(cookies)) { request.setCookies(cookies.toArray(new Cookie[0])); } }
Source:
<code>public static Slice simplifyGeometry(@SqlType(GEOMETRY_TYPE_NAME) Slice input, @SqlType(DOUBLE) double distanceTolerance) { if (Double.isNaN(distanceTolerance)) { <START> throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "distance is NaN"); <END> } if (distanceTolerance < 0) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "distance is negative"); } if (distanceTolerance == 0) { return input; } return JtsGeometryUtils.serialize(simplify(JtsGeometryUtils.deserialize(input), distanceTolerance)); }</code><technical_language>s/distance/distanceTolerance</technical_language>

Target:
public static Slice simplifyGeometry(@SqlType(GEOMETRY_TYPE_NAME) Slice input, @SqlType(DOUBLE) double distanceTolerance) { if (Double.isNaN(distanceTolerance)) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "distanceTolerance is NaN"); } if (distanceTolerance < 0) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "distanceTolerance is negative"); } if (distanceTolerance == 0) { return input; } return JtsGeometryUtils.serialize(simplify(JtsGeometryUtils.deserialize(input), distanceTolerance)); }
Source:
<code>public boolean doAction(View view, ViewActionTrigger actionDetail, ViewDetail viewDetail) { Intent intent = new Intent(context, newActivityClass); Bundle bundle = new Bundle(); <START> bundle.putLong("ID", (Long) view.getTag(view.getId())); <END> intent.putExtras(bundle); context.startActivity(intent); return true; }</code><technical_language>this ID represent</technical_language>

Target:
public boolean doAction(View view, ViewActionTrigger actionDetail, ViewDetail viewDetail) { Intent intent = new Intent(context, newActivityClass); if (bundleGenerator != null) { intent.putExtras(bundleGenerator.generate(view)); } context.startActivity(intent); return true; }
Source:
<code>private String getCachedContextMapping( String baseUrl, String referer ) { if ( referer != null ) { return this.cachedContextMapping.computeIfAbsent( referer, k -> { List<IRequireJsPackageConfiguration> requireJsPackageConfigurations = this.packageConfigurationsTracker.getPackages(); for ( IRequireJsPackageConfiguration requireJsPackage : requireJsPackageConfigurations ) { String webRootPath = requireJsPackage.getWebRootPath(); <START> if ( !StringUtils.isEmpty( webRootPath ) && referer.contains( baseUrl + webRootPath ) ) { <END> Map<String, Object> contextConfig = new HashMap<>(); Map<String, Map<String, String>> topMap = new HashMap<>(); Map<String, String> map = new HashMap<>(); requireJsPackage.getModuleIdsMapping().forEach( map::put ); topMap.put( "*", map ); contextConfig.put( "map", topMap ); return JSONObject.toJSONString( contextConfig ); } } return null; } ); } return null; }</code><technical_language>Do need import commons-lang for a single webRootPath != null && webRootPath.length != 0? (in reality existing implementation of IRequireJsPackageConfiguration returns null for getName(), harm extra-careful)</technical_language>

Target:
private String getCachedContextMapping( String baseUrl, String referer ) { if ( referer != null ) { return this.cachedContextMapping.computeIfAbsent( referer, k -> { List<IRequireJsPackageConfiguration> requireJsPackageConfigurations = this.packageConfigurationsTracker.getPackages(); for ( IRequireJsPackageConfiguration requireJsPackage : requireJsPackageConfigurations ) { String webRootPath = requireJsPackage.getWebRootPath(); if ( webRootPath != null && !webRootPath.isEmpty() && referer.contains( baseUrl + webRootPath ) ) { Map<String, Object> contextConfig = new HashMap<>(); Map<String, Map<String, String>> topMap = new HashMap<>(); Map<String, String> map = new HashMap<>(); requireJsPackage.getModuleIdsMapping().forEach( map::put ); topMap.put( "*", map ); contextConfig.put( "map", topMap ); return JSONObject.toJSONString( contextConfig ); } } return null; } ); } return null; }
Source:
<code>public void testListWithCustomGlobalHeaderOverridden() { Map<String, String> headers = new HashMap<>(1); headers.put("my", "local"); <START> clustersService.list().headers(headers).send(); <END> assertEquals("local", getLastRequestHeaders().get("my").getFirst()); }</code><technical_language>nice able do this: clustersService.list() .header("First", "first") .header("Secod", "second") .send(); able pass a map is good, convenient for cases</technical_language>

Target:
public void testListWithCustomGlobalHeaderOverridden() { clustersService.list() .header("my", "local") .send(); assertEquals("local", getLastRequestHeaders().get("my").getFirst()); }