auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void itDoesntCountInstancesOverLimitInOnDemandLateTasks() { initOnDemandRequest(); SingularityRequest request = requestResource.getRequest(requestId, singularityUser).getRequest(); requestResource.postRequest(request.toBuilder().setInstances(Optional.of(2)).build(), singularityUser); initFirstDeploy(); <START> configuration.setDeltaAfterWhichTasksAreLateMillis(TimeUnit.MILLISECONDS.toMillis(10)); <END> requestResource.scheduleImmediately( singularityUser, request.getId(), new SingularityRunNowRequestBuilder() .setRunAt(System.currentTimeMillis()) .build() ); scheduler.drainPendingQueue(); SingularityState state = stateManager.getState(true, false); System.out.println(state); Assert.assertEquals(0, state.getActiveTasks()); Assert.assertEquals(1, state.getScheduledTasks()); launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING); state = stateManager.getState(true, false); System.out.println(state); Assert.assertEquals(1, state.getActiveTasks()); Assert.assertEquals(1, state.getScheduledTasks()); Assert.assertEquals(1, state.getOnDemandLateTasks()); Assert.assertEquals(0, state.getLateTasks()); launchTask(request, firstDeploy, 2, TaskState.TASK_RUNNING); state = stateManager.getState(true, false); System.out.println(state); Assert.assertEquals(2, state.getActiveTasks()); Assert.assertEquals(1, state.getScheduledTasks()); Assert.assertEquals(0, state.getOnDemandLateTasks()); Assert.assertEquals(0, state.getLateTasks()); configuration.setDeltaAfterWhichTasksAreLateMillis(TimeUnit.SECONDS.toMillis(30)); }</code><technical_language>need MILLISECONDS.toMillis, number. Also, set 0? Outcome depending fast machine running test is</technical_language>

Target:
public void itDoesntCountInstancesOverLimitInOnDemandLateTasks() { initOnDemandRequest(); SingularityRequest request = requestResource.getRequest(requestId, singularityUser).getRequest(); requestResource.postRequest(request.toBuilder().setInstances(Optional.of(2)).build(), singularityUser); initFirstDeploy(); configuration.setDeltaAfterWhichTasksAreLateMillis(0); requestResource.scheduleImmediately( singularityUser, request.getId(), new SingularityRunNowRequestBuilder() .setRunAt(System.currentTimeMillis()) .build() ); scheduler.drainPendingQueue(); SingularityState state = stateManager.getState(true, false); System.out.println(state); Assert.assertEquals(0, state.getActiveTasks()); Assert.assertEquals(1, state.getScheduledTasks()); launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING); state = stateManager.getState(true, false); System.out.println(state); Assert.assertEquals(1, state.getActiveTasks()); Assert.assertEquals(1, state.getScheduledTasks()); Assert.assertEquals(1, state.getOnDemandLateTasks()); Assert.assertEquals(0, state.getLateTasks()); launchTask(request, firstDeploy, 2, TaskState.TASK_RUNNING); state = stateManager.getState(true, false); System.out.println(state); Assert.assertEquals(2, state.getActiveTasks()); Assert.assertEquals(1, state.getScheduledTasks()); Assert.assertEquals(0, state.getOnDemandLateTasks()); Assert.assertEquals(0, state.getLateTasks()); configuration.setDeltaAfterWhichTasksAreLateMillis(TimeUnit.SECONDS.toMillis(30)); }
Source:
<code>public String getImagePath() { <START> return NAME + "_icon32.png"; <END> }</code><technical_language>return getImagePath(DefinitionImageType.PALLETE_ICON_32X32)</technical_language>

Target:
public String getImagePath() { return getImagePath(DefinitionImageType.PALETTE_ICON_32X32); }
Source:
<code>public String getExtraHostsString() { <START> if (getExtraHosts() == null) { <END> return ""; } else { return Joiner.on("\n").join(getExtraHosts()); } }</code><technical_language>check for null in another place check size</technical_language>

Target:
public String getExtraHostsString() { if (CollectionUtils.isEmpty(getExtraHosts())) { return ""; } else { return Joiner.on("\n").join(getExtraHosts()); } }
Source:
<code>private PromiseHttpAsyncClient getPromiseHttpAsyncClient(Request request) { <START> log.info( "Creating new HttpAsyncClient" ); <END> final CloseableHttpAsyncClient nonCachingHttpClient; try { final HttpAsyncClientBuilder clientBuilder = createClientBuilder(); nonCachingHttpClient = clientBuilder.build(); nonCachingHttpClient.start(); } catch ( IOReactorException e ) { throw new RuntimeException( "Reactor " + httpClientOptions.getThreadPrefix() + "not set up correctly" , e ); } return new SettableFuturePromiseHttpPromiseAsyncClient<C>(nonCachingHttpClient, threadLocalContextManager, callbackExecutor); }</code><technical_language>this log.trace</technical_language>

Target:
private PromiseHttpAsyncClient getPromiseHttpAsyncClient(Request request) { log.trace( "Creating new HttpAsyncClient" ); final CloseableHttpAsyncClient nonCachingHttpClient; try { final HttpAsyncClientBuilder clientBuilder = createClientBuilder(); nonCachingHttpClient = clientBuilder.build(); nonCachingHttpClient.start(); } catch ( IOReactorException e ) { throw new RuntimeException( "Reactor " + httpClientOptions.getThreadPrefix() + "not set up correctly" , e ); } return new SettableFuturePromiseHttpPromiseAsyncClient<C>(nonCachingHttpClient, threadLocalContextManager, callbackExecutor); }
Source:
<code><START> private void checkNotHoldsLock(Object lock) <END> { checkState(!Thread.holdsLock(lock), "Cannot execute this method while holding a lock"); }</code><technical_language>static</technical_language>

Target:
private static void checkNotHoldsLock(Object lock) { checkState(!Thread.holdsLock(lock), "Cannot execute this method while holding a lock"); }
Source:
<code>public void set(Subscription s) { if (s == null) { throw new IllegalArgumentException("Subscription can not be null"); } State oldState; State newState; do { <START> oldState = state.get(); <END> if (oldState.isUnsubscribed) { s.unsubscribe(); return; } else { newState = oldState.set(s); } } while (!state.compareAndSet(oldState, newState)); oldState.subscription.unsubscribe(); }</code><technical_language>field state read a local variable loop</technical_language>

Target:
public void set(Subscription s) { if (s == null) { throw new IllegalArgumentException("Subscription can not be null"); } State oldState; State newState; final AtomicReference<State> localState = this.state; do { oldState = localState.get(); if (oldState.isUnsubscribed) { s.unsubscribe(); return; } else { newState = oldState.set(s); } } while (!localState.compareAndSet(oldState, newState)); oldState.subscription.unsubscribe(); }
Source:
<code>public void insertRow(final String tableName, final HBaseColumn[] columns, final Object[] values, final int indexOfIdColumn) { if (tableName == null || columns == null || values == null || indexOfIdColumn >= values.length || values[indexOfIdColumn] == null) { throw new IllegalArgumentException( "Can't insert a row without having (correct) tableName, columns, values or indexOfIdColumn"); } if (columns.length != values.length) { throw new IllegalArgumentException("The amount of columns don't match the amount of values"); } try (final Table table = _connection.getTable(TableName.valueOf(tableName))) { final Put put = new Put(getValueAsByteArray(values[indexOfIdColumn])); for (int i = 0; i < columns.length; i++) { if (i != indexOfIdColumn) { final byte[] columnFamily = Bytes.toBytes(columns[i].getColumnFamily()); byte[] qualifier = null; if (columns[i].getQualifier() != null) { qualifier = Bytes.toBytes(columns[i].getQualifier()); } else { qualifier = Bytes.toBytes(new String("")); } final byte[] value = getValueAsByteArray(values[i]); if (value == null) { <START> logger.warn("The value of column '{}:{}' is null. This insertion is skipped", columns[i] <END> .getColumnFamily() .toString(), columns[i].getQualifier().toString()); } else { put.addColumn(columnFamily, qualifier, value); } } } table.put(put); } catch (IOException e) { throw new MetaModelException(e); } }</code><technical_language>log this info level instead</technical_language>

Target:
public void insertRow(final String tableName, final HBaseColumn[] columns, final Object[] values, final int indexOfIdColumn) { if (tableName == null || columns == null || values == null || indexOfIdColumn >= values.length || values[indexOfIdColumn] == null) { throw new IllegalArgumentException( "Can't insert a row without having (correct) tableName, columns, values or indexOfIdColumn"); } if (columns.length != values.length) { throw new IllegalArgumentException("The amount of columns don't match the amount of values"); } try (final Table table = _connection.getTable(TableName.valueOf(tableName))) { final Put put = new Put(getValueAsByteArray(values[indexOfIdColumn])); for (int i = 0; i < columns.length; i++) { if (i != indexOfIdColumn) { final byte[] columnFamily = Bytes.toBytes(columns[i].getColumnFamily()); byte[] qualifier = null; if (columns[i].getQualifier() != null) { qualifier = Bytes.toBytes(columns[i].getQualifier()); } else { qualifier = Bytes.toBytes(new String("")); } final byte[] value = getValueAsByteArray(values[i]); if (value == null) { logger.info("The value of column '{}' is null. This insertion is skipped", columns[i] .getName()); } else { put.addColumn(columnFamily, qualifier, value); } } } table.put(put); } catch (IOException e) { throw new MetaModelException(e); } }
Source:
<code><START> CompletableFuture<Void> asyncCompleteLocalTransaction(AdvancedCache<?, ?> cache, long timeout) { <END> return blockingHandler.runBlockingOperation(() -> { try { rollbackLocalTransaction(cache, xid, timeout); } catch (HeuristicMixedException e) { hasCommits = true; hasRollbacks = true; } catch (Throwable t) { hasErrors = true; } }, this).toCompletableFuture(); }</code><technical_language>suggestion CompletionStage<Void> asyncCompleteLocalTransaction(AdvancedCache<?, ?> cache, long timeout) {</technical_language>

Target:
CompletionStage<Void> asyncCompleteLocalTransaction(AdvancedCache<?, ?> cache, long timeout) { return blockingManager.runBlocking(() -> { try { rollbackLocalTransaction(cache, xid, timeout); } catch (HeuristicMixedException e) { hasCommits = true; hasRollbacks = true; } catch (Throwable t) { hasErrors = true; } }, this); }
Source:
<code>public void receiveMessage(PubsubMessage message, AckReplyConsumer replyConsumer) { final ByteString data = message.getData(); final String messageId = message.getMessageId(); log.debug("Received ID:{} with content: {}", messageId, data.toStringUtf8()); final byte[] bytes = data.toByteArray(); try { consumer.consume(bytes); reporter.reportMessageSize(bytes.length); consumed.increment(); replyConsumer.ack(); } catch (ConsumerSchemaValidationException e) { reporter.reportConsumerSchemaError(); log.error("ID:{} - {}", messageId, e.getMessage(), e); replyConsumer.ack(); <START> } catch (Exception e) { <END> errors.incrementAndGet(); log.error("ID:{} - Failed to consume", messageId, e); reporter.reportMessageError(); } }</code><technical_language>for understanding - removing ack finally block put message queue delivered another time, right</technical_language>

Target:
public void receiveMessage(PubsubMessage message, AckReplyConsumer replyConsumer) { final ByteString data = message.getData(); final String messageId = message.getMessageId(); log.debug("Received ID:{} with content: {}", messageId, data.toStringUtf8()); final byte[] bytes = data.toByteArray(); try { consumer.consume(bytes); reporter.reportMessageSize(bytes.length); consumed.increment(); replyConsumer.ack(); } catch (ConsumerSchemaValidationException e) { reporter.reportConsumerSchemaError(); log.error("ID:{} - {}", messageId, e.getMessage(), e); replyConsumer.ack(); } catch (Exception e) { errors.incrementAndGet(); log.error("ID:{} - Failed to consume", messageId, e); reporter.reportMessageError(); replyConsumer.nack(); } }
Source:
<code>public void formatsTextToHtml() throws Exception { final String meta = new MarkdownTxtmark().html( <START> "**hi**, _dude_!\r\n\n b**o\n \n \n o**m\n" <END> ); MatcherAssert.assertThat( String.format("<x>%s</x>", meta), Matchers.describedAs( meta, XhtmlMatchers.hasXPaths( "/x/p/strong[.='hi']", "/x/p/em[.='dude']", "/x/pre/code[.=' b**o\n\n\no**m\n']" ) ) ); }</code><technical_language>@dmzaytsev try org.apache.commons.lang3.StringUtils#join() here. more visual</technical_language>

Target:
public void formatsTextToHtml() throws Exception { final String meta = new MarkdownTxtmark().html( MarkdownTxtmarkTest.join( "**hi**, _dude_!", "", " b**o", " ", " o**m", "" ) ); MatcherAssert.assertThat( String.format("<x>%s</x>", meta), Matchers.describedAs( meta, XhtmlMatchers.hasXPaths( "/x/p/strong[.='hi']", "/x/p/em[.='dude']", MarkdownTxtmarkTest.join( "/x/pre/code[.=' b**o", "", "", "o**m']" ) ) ) ); }
Source:
<code>public void verifyMonetizationModuleAdsenseShown() { Assertion.assertTrue(checkIfElementOnPage(adsenseContainer)); Assertion.assertTrue(checkIfElementOnPage(adsenseIns)); <START> PageObjectLogging.log("verifyMonetizationModuleAdsenseShown", "Monetization module is shown (adsense)", true); <END> waitForElementByElement(adsenseContainer); PageObjectLogging.log("verifyMonetizationModuleAdsenseShown", "Monetization module is visible (adsense)", true); }</code><technical_language>s necessary log here? assertion put logging file already. Also, I another logging end of method</technical_language>

Target:
public void verifyMonetizationModuleAdsenseShown() { Assertion.assertTrue(checkIfElementOnPage(adsenseContainer)); Assertion.assertTrue(checkIfElementOnPage(adsenseIns)); waitForElementByElement(adsenseContainer); PageObjectLogging.log("verifyMonetizationModuleAdsenseShown", "Monetization module is visible (adsense)", true); }
Source:
<code>public void acknowledgeTaskResults(TaskId taskId, OutputBufferId bufferId, long sequenceId) { requireNonNull(taskId, "taskId is null"); requireNonNull(bufferId, "bufferId is null"); <START> Preconditions.checkArgument(sequenceId >= 0, "sequenceId is negative"); <END> tasks.getUnchecked(taskId).acknowledgeTaskResults(bufferId, sequenceId); }</code><technical_language>static import</technical_language>

Target:
public void acknowledgeTaskResults(TaskId taskId, OutputBufferId bufferId, long sequenceId) { requireNonNull(taskId, "taskId is null"); requireNonNull(bufferId, "bufferId is null"); checkArgument(sequenceId >= 0, "sequenceId is negative"); tasks.getUnchecked(taskId).acknowledgeTaskResults(bufferId, sequenceId); }
Source:
<code>public void onEnvironmentShutdown() { if ( main != null ) { try { main.destroy(); } catch ( Exception e ) { <START> e.printStackTrace(); <END> } } }</code><technical_language>logger instead of printing stack</technical_language>

Target:
public void onEnvironmentShutdown() { if ( main != null ) { try { main.destroy(); } catch ( Exception e ) { logger.error( "Error during Karaf shutdown", e ); } } }
Source:
<code>private void generate() throws Exception { while (!_out.isFull()) { DataComplex current = _stack.peek(); if (_iteratorStack.size() != _stack.size()) { if (_typeStack.peek() == MAP) { DataMap dataMap = preProcessMap((DataMap) current); if (dataMap != null) { _iteratorStack.push(createIterator(dataMap)); _traverseCallback.startMap(dataMap); } else { <START> _stack.pop(); <END> _typeStack.pop(); _done = _stack.isEmpty(); if (_done) { flushOutputStream(_traverseCallback); break; } } } else { DataList dataList = preProcessList((DataList) current); if (dataList != null) { _iteratorStack.push(createIterator(dataList)); _traverseCallback.startList(dataList); } else { _stack.pop(); _typeStack.pop(); _done = _stack.isEmpty(); if (_done) { flushOutputStream(_traverseCallback); break; } } } continue; } Iterator<?> curr = _iteratorStack.peek(); if (curr.hasNext()) { Object currItem = curr.next(); if (_typeStack.peek() == MAP) { Map.Entry<String, ?> entry = (Map.Entry<String, ?>) currItem; _traverseCallback.key(entry.getKey()); writeValue(entry.getValue()); } else { writeValue(currItem); } } else { _stack.pop(); _iteratorStack.pop(); Object type = _typeStack.pop(); if (type == MAP) { _traverseCallback.endMap(); } else { _traverseCallback.endList(); } _done = _stack.isEmpty(); if (_done) { flushOutputStream(_traverseCallback); break; } } } }</code><technical_language>This part else condition in list. Suggest moving this a common method</technical_language>

Target:
private void generate() throws Exception { while (!_out.isFull()) { DataComplex current = _stack.peek(); if (_iteratorStack.size() != _stack.size()) { if (_typeStack.peek() == MAP) { DataMap dataMap = preProcessMap((DataMap) current); if (dataMap != null) { _iteratorStack.push(createIterator(dataMap)); _traverseCallback.startMap(dataMap); } else { removeProcessedEntity(); if (_done) { _traverseCallback.close(); break; } } } else { DataList dataList = preProcessList((DataList) current); if (dataList != null) { _iteratorStack.push(createIterator(dataList)); _traverseCallback.startList(dataList); } else { removeProcessedEntity(); if (_done) { _traverseCallback.close(); break; } } } continue; } Iterator<?> curr = _iteratorStack.peek(); if (curr.hasNext()) { Object currItem = curr.next(); if (_typeStack.peek() == MAP) { Map.Entry<String, ?> entry = (Map.Entry<String, ?>) currItem; _traverseCallback.key(entry.getKey()); writeValue(entry.getValue()); } else { writeValue(currItem); } } else { _iteratorStack.pop(); Object type = removeProcessedEntity(); if (type == MAP) { _traverseCallback.endMap(); } else { _traverseCallback.endList(); } if (_done) { _traverseCallback.close(); break; } } } }
Source:
<code>public String getString(final ByteBuffer byteBuffer) { if (byteBuffer == null) return null; <START> return DecimalType.instance.getString(byteBuffer); <END> }</code><technical_language>Missing duplicate</technical_language>

Target:
public String getString(final ByteBuffer byteBuffer) { if (byteBuffer == null) return null; return DecimalType.instance.getString(byteBuffer.duplicate()); }
Source:
<code>public void checkBundleUser(AthenaUser user, DownloadBundle bundle){ <START> if (!user.getId().equals(bundle.getUserId())) { <END> throw new PermissionDeniedException(); } }</code><technical_language>I suggest Objects.equals is more null-safe</technical_language>

Target:
public void checkBundleUser(AthenaUser user, DownloadBundle bundle){ if (ObjectUtils.notEqual(user.getId(), bundle.getUserId())) { throw new PermissionDeniedException(); } }
Source:
<code>protected BasicProgressMonitor doSubTask(final float work, final int maxHierarchyLevels) { <START> int newMaxHierarchyLevels = Math.max(0, maxHierarchyLevels - 1); <END> return new BasicProgressMonitor(newMaxHierarchyLevels) .withLogging(recordLogs) .withLogPersistence(persistLogs) .withExecutionTimeMeasurement(recordExecutionTime); }</code><technical_language>behavior before. If maxHierarchyLevels is -1, remain changed 0</technical_language>

Target:
protected BasicProgressMonitor doSubTask(final float work, final int maxHierarchyLevels) { int newMaxHierarchyLevels = maxHierarchyLevels > 0 ? maxHierarchyLevels - 1 : maxHierarchyLevels; return new BasicProgressMonitor() .withMaxHierarchyLevels(newMaxHierarchyLevels) .withLogging(recordLogs) .withLogPersistence(persistLogs) .withExecutionTimeMeasurement(recordExecutionTime); }
Source:
<code>public static Locale getLocaleFromString(String localeString, boolean returnDefaultLocale) { Locale result = returnDefaultLocale ? null : Locale.US; try { result = org.apache.commons.lang.LocaleUtils.toLocale(localeString); <START> if(null == result && returnDefaultLocale) { <END> result = Locale.US; } } catch(IllegalArgumentException e) { result = returnDefaultLocale ? Locale.US : null; } return result; }</code><technical_language>Please "something <operator> null" convention</technical_language>

Target:
public static Locale getLocaleFromString(String localeString, boolean returnDefaultLocale) { Locale result = returnDefaultLocale ? null : Locale.US; try { result = org.apache.commons.lang.LocaleUtils.toLocale(localeString); if(result == null && returnDefaultLocale) { result = Locale.US; } } catch(IllegalArgumentException e) { result = returnDefaultLocale ? Locale.US : null; } return result; }
Source:
<code>private LRARecord enlistParticipant(URI coordinatorUrl, String participantUrl, String recoveryUrlBase, String terminateUrl, long timeLimit, String compensatorData) throws UnsupportedEncodingException { LRARecord p = new LRARecord(this, lraService, coordinatorUrl.toASCIIString(), participantUrl, compensatorData); String pid = p.get_uid().fileStringForm(); String txId = URLEncoder.encode(coordinatorUrl.toASCIIString(), "UTF-8"); p.setRecoveryURI(recoveryUrlBase, txId, pid); if (add(p) != AddOutcome.AR_REJECTED) { setTimeLimit(timeLimit); return p; } else if (isRecovering() && p.getCompensator() == null && p.getEndNotificationUri() != null) { heuristicList.putRear(p); updateState(); <START> return p; <END> } else if (isRecovering() && p.getCompensator() == null && p.getEndNotificationUri() != null) { afterLRAListeners.add(new AfterLRAListener(p.getEndNotificationUri(), p.getRecoveryCoordinatorURI())); updateState(); return p; } return null; }</code><technical_language>duplicated if branching, a merge/rebase conflict</technical_language>

Target:
private LRARecord enlistParticipant(URI coordinatorUrl, String participantUrl, String recoveryUrlBase, String terminateUrl, long timeLimit, String compensatorData) throws UnsupportedEncodingException { LRARecord p = new LRARecord(this, lraService, coordinatorUrl.toASCIIString(), participantUrl, compensatorData); String pid = p.get_uid().fileStringForm(); String txId = URLEncoder.encode(coordinatorUrl.toASCIIString(), "UTF-8"); p.setRecoveryURI(recoveryUrlBase, txId, pid); if (add(p) != AddOutcome.AR_REJECTED) { setTimeLimit(timeLimit); return p; } else if (isRecovering() && p.getCompensator() == null && p.getEndNotificationUri() != null) { heuristicList.putRear(p); updateState(); return p; } return null; }
Source:
<code>public void showIssue(String repoId, int id, boolean isPullRequest, boolean isForceRefresh) { if (isPullRequest) { logger.info("Showing pull request #" + id); runBrowserOperation(() -> driver.get( GitHubURL.getPathForPullRequest(repoId, id), isForceRefresh, (currentUrl, targetUrl) -> currentUrl.equalsIgnoreCase(targetUrl + "/commits") || currentUrl.equalsIgnoreCase(targetUrl + "/files") <START> )); <END> } else { logger.info("Showing issue #" + id); runBrowserOperation(() -> driver.get(GitHubURL.getPathForIssue(repoId, id), isForceRefresh)); } runBrowserOperation(() -> scrollToBottom()); }</code><technical_language>This overloaded get is necessary. explain below</technical_language>

Target:
public void showIssue(String repoId, int id, boolean isPullRequest, boolean isForceRefresh) { if (isPullRequest) { logger.info("Showing pull request #" + id); if (!isCurrentUrlPrPageIgnoreTabs(repoId, id)) { runBrowserOperation(() -> driver.get(GitHubURL.getPathForPullRequest(repoId, id), isForceRefresh)); } else { logger.info("Already at PR page: " + getCurrentUrl() + " will not reload."); } } else { logger.info("Showing issue #" + id); runBrowserOperation(() -> driver.get(GitHubURL.getPathForIssue(repoId, id), isForceRefresh)); } runBrowserOperation(() -> scrollToBottom()); }
Source:
<code>protected boolean startDecoratorNode() { new Subscriber(NodeChannel.DRIVE_CTRL.getMsgPath(), new MessageListener() { @Override public void actionPerformed(String topicName, Message m) { commandedAngle = ((DriveControlMessage)m).getAngleInt(); } }); new Subscriber(NodeChannel.BRAKE_CTRL.getMsgPath(), new MessageListener() { @Override public void actionPerformed(String topicName, Message m) { commandedBrakeEngaged = ((BrakeControlMessage)m).isBrakeEngaged(); } }); new Subscriber(NodeChannel.ENCODER_RESET.getMsgPath(), new MessageListener() { @Override public void actionPerformed(String topicName, Message m) { byte[] bytes = new byte[6]; bytes[0] = (byte)RBSerialMessage.getHeaderByte("RBSM_MID_ENC_RESET_REQUEST"); bytes[1] = (byte)0; bytes[2] = (byte)0; bytes[3] = (byte)0; <START> bytes[4] = (byte)(0xc0); <END> bytes[5] = (byte)RBSerialMessage.getHeaderByte("FOOTER"); send(bytes); } }); return true; }</code><technical_language>is this C0? I prefer for magic values in communication system</technical_language>

Target:
protected boolean startDecoratorNode() { new Subscriber(NodeChannel.DRIVE_CTRL.getMsgPath(), new MessageListener() { @Override public void actionPerformed(String topicName, Message m) { commandedAngle = ((DriveControlMessage)m).getAngleInt(); } }); new Subscriber(NodeChannel.BRAKE_CTRL.getMsgPath(), new MessageListener() { @Override public void actionPerformed(String topicName, Message m) { commandedBrakeEngaged = ((BrakeControlMessage)m).isBrakeEngaged(); } }); new Subscriber(NodeChannel.ENCODER_RESET.getMsgPath(), new MessageListener() { @Override public void actionPerformed(String topicName, Message m) { byte[] message = new byte[6]; message[0] = (byte)RBSerialMessage.getHeaderByte("RBSM_MID_ENC_RESET_REQUEST"); message[1] = 0; message[2] = 0; message[3] = 0; message[4] = 0; message[5] = (byte)RBSerialMessage.getHeaderByte("FOOTER"); send(message); } }); return true; }
Source:
<code>public void testCustomBenchmarkSuiteSupplier() throws Exception { Bootstrap app = new Bootstrap( <START> ImmutableList.<Module>builder() <END> .add(new BenchmarkSuiteModule(ImmutableSet.of("test-supplier"))) .build()); app.strictConfig() .setRequiredConfigurationProperties(ImmutableMap.<String, String>builder() .putAll(DEFAULT_CONFIGURATION_PROPERTIES) .put("benchmark-suite-supplier", "test-supplier") .build()) .initialize(); }</code><technical_language>merge previous line</technical_language>

Target:
public void testCustomBenchmarkSuiteSupplier() { Bootstrap app = new Bootstrap(ImmutableList.<Module>builder() .add(new BenchmarkSuiteModule(ImmutableSet.of("test-supplier"))) .build()); Injector injector = null; try { injector = app.strictConfig() .setRequiredConfigurationProperties(ImmutableMap.<String, String>builder() .putAll(DEFAULT_CONFIGURATION_PROPERTIES) .put("benchmark-suite-supplier", "test-supplier") .build()) .initialize(); } finally { if (injector != null) { injector.getInstance(LifeCycleManager.class).stop(); } } }
Source:
<code>public ViewApps(MainWindow parent) { eventHandlerCenter = new EventHandlerCenter(); this.getStyleClass().add("mainWindowScene"); availableInstallerListWidget = new SimpleIconListWidget(); availableInstallerListWidget.getStyleClass().add("rightPane"); leftContent = new LeftSideBar(); this.initWait(); this.initFailure(); categories = new ObservableArrayList<>(); <START> centerItems = new FilterPromise<CenterItemDTO>(eventHandlerCenter.getRemoteAvailableInstallers(), this.filter); <END> this.drawSideBar(); this.showWait(); }</code><technical_language>replace <CenterItemDTO> <></technical_language>

Target:
public ViewApps(MainWindow parent) { eventHandlerCenter = new EventHandlerCenter(); this.getStyleClass().add("mainWindowScene"); availableInstallerListWidget = new SimpleIconListWidget(); availableInstallerListWidget.getStyleClass().add("rightPane"); leftContent = new LeftSideBar(); this.initWait(); this.initFailure(); categories = new ObservableArrayList<>(); centerItems = new FilterPromise<>(eventHandlerCenter.getRemoteAvailableInstallers(), this.filter); this.drawSideBar(); this.showWait(); }
Source:
<code>public void addBricks(){ if (getWindow() != null) { return; } VolumeBrickModel volumeBrickModel = new VolumeBrickModel(); <START> volumeBrickModel.getReplicaCount().setEntity(this.getReplicaCount().getEntity()); <END> volumeBrickModel.getReplicaCount().setIsChangable(true); volumeBrickModel.getReplicaCount().setIsAvailable(this.getReplicaCount().getIsAvailable()); volumeBrickModel.getStripeCount().setEntity(this.getStripeCount().getEntity()); volumeBrickModel.getStripeCount().setIsChangable(true); volumeBrickModel.getStripeCount().setIsAvailable(this.getStripeCount().getIsAvailable()); setWindow(volumeBrickModel); volumeBrickModel.setTitle(ConstantsManager.getInstance().getConstants().addBricksVolume()); volumeBrickModel.setHashName("add_bricks"); volumeBrickModel.getBricks().setItems(new ArrayList<EntityModel>()); UICommand command = new UICommand("Ok", this); command.setTitle(ConstantsManager.getInstance().getConstants().ok()); command.setIsDefault(true); volumeBrickModel.getCommands().add(command); command = new UICommand("Cancel", this); command.setTitle(ConstantsManager.getInstance().getConstants().cancel()); command.setIsDefault(true); volumeBrickModel.getCommands().add(command); }</code><technical_language>do 'this' keyword here? if is reason remove (several places)</technical_language>

Target:
public void addBricks(){ if (getWindow() != null) { return; } VolumeBrickModel volumeBrickModel = new VolumeBrickModel(); volumeBrickModel.getReplicaCount().setEntity(getReplicaCount().getEntity()); volumeBrickModel.getReplicaCount().setIsChangable(true); volumeBrickModel.getReplicaCount().setIsAvailable(getReplicaCount().getIsAvailable()); volumeBrickModel.getStripeCount().setEntity(getStripeCount().getEntity()); volumeBrickModel.getStripeCount().setIsChangable(true); volumeBrickModel.getStripeCount().setIsAvailable(getStripeCount().getIsAvailable()); setWindow(volumeBrickModel); volumeBrickModel.setTitle(ConstantsManager.getInstance().getConstants().addBricksVolume()); volumeBrickModel.setHashName("add_bricks"); volumeBrickModel.getBricks().setItems(new ArrayList<EntityModel>()); UICommand command = new UICommand("Ok", this); command.setTitle(ConstantsManager.getInstance().getConstants().ok()); command.setIsDefault(true); volumeBrickModel.getCommands().add(command); command = new UICommand("Cancel", this); command.setTitle(ConstantsManager.getInstance().getConstants().cancel()); command.setIsDefault(true); volumeBrickModel.getCommands().add(command); }
Source:
<code>public void restoreAdvancedOptions() { libraryPreferences.load(loadedLibraryPreferences -> { view.setVersion(loadedLibraryPreferences.getProjectPreferences().getVersion()); <START> view.setArtifactId(""); <END> view.setGroupId(projectContext.getActiveOrganizationalUnit().isPresent() ? projectContext.getActiveOrganizationalUnit().get().getDefaultGroupId() : loadedLibraryPreferences.getOrganizationalUnitPreferences().getGroupId()); }, error -> { }); }</code><technical_language>restore project name spaces instead of empty string (view.setArtifactId(view.getName().replaceAll(" ", ""));), if user fills name, clicks "Configure Advanced Options", clicks "Restore Advanced Options", artifact id empty</technical_language>

Target:
public void restoreAdvancedOptions() { libraryPreferences.load(loadedLibraryPreferences -> { view.setVersion(loadedLibraryPreferences.getProjectPreferences().getVersion()); setDefaultArtifactId(); view.setGroupId(projectContext.getActiveOrganizationalUnit().isPresent() ? projectContext.getActiveOrganizationalUnit().get().getDefaultGroupId() : loadedLibraryPreferences.getOrganizationalUnitPreferences().getGroupId()); }, error -> { }); }
Source:
<code>public void run() { if (!isRunAllowed() || !InfinispanRoutePolicy.this.isRunAllowed()) { return; } if (isLeader()) { <START> if (!cache.replace(lockKey, lockKey, lockKey, lifespan, lifespanTimeUnit)) { <END> setLeader(false); } } if (!isLeader()) { Object result = cache.putIfAbsent(lockKey, lockValue, lifespan, lifespanTimeUnit); if (result == null) { setLeader(true); } else if (ObjectHelper.equal(lockValue, result) && !isLeader()) { setLeader(true); } else { setLeader(false); } } }</code><technical_language>replacing lockKey lockKey? lockValue lockValue</technical_language>

Target:
public void run() { if (!isRunAllowed() || !InfinispanRoutePolicy.this.isRunAllowed()) { return; } if (isLeader()) { if (!cache.replace(lockKey, lockValue, lockValue, lifespan, lifespanTimeUnit)) { setLeader(false); } } if (!isLeader()) { Object result = cache.putIfAbsent(lockKey, lockValue, lifespan, lifespanTimeUnit); if (result == null) { setLeader(true); } else if (ObjectHelper.equal(lockValue, result) && !isLeader()) { setLeader(true); } else { setLeader(false); } } }
Source:
<code>public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater inflater = getActivity().getLayoutInflater(); convertView = inflater.inflate( android.R.layout.simple_list_item_multiple_choice, null); } Keyword tag = getItem(position); TextView tv = (TextView) convertView.findViewById( <START> android.R.id.text1); <END> if (tv != null && tag != null) { tv.setText(tag.getName()); tv.setTextColor(tag.getTextColor()); } ListView lv = (ListView) parent; if (lv != null && selectedTags.contains(tag)) { lv.setItemChecked(position, true); } return convertView; }</code><technical_language>android.R.id.text1 Change this</technical_language>

Target:
public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater inflater = getActivity().getLayoutInflater(); convertView = inflater.inflate( android.R.layout.simple_list_item_multiple_choice, null); } Keyword tag = getItem(position); TextView textViewName = (TextView) convertView.findViewById( android.R.id.text1); if (textViewName != null && tag != null) { textViewName.setText(tag.getName()); textViewName.setTextColor(tag.getTextColor(keywordColorUtils)); } ListView parentListView = (ListView) parent; if (parentListView != null && selectedTags.contains(tag)) { parentListView.setItemChecked(position, true); } return convertView; }
Source:
<code><START> public boolean hasWindowedExpression() { <END> return m_hasWindowingExpression; }</code><technical_language>"WindowED" VS. "WindowING" . I preference pick consistently</technical_language>

Target:
public boolean hasWindowedExpression() { return m_hasWindowedExpression; }
Source:
<code><START> private void timeoutEvent(TimeoutMap.Listener.Type type, String cid) { <END> switch (type) { case Remove: case Evict: correlationIds.remove(cid); break; case Put: default: correlationIds.add(cid); } dirty = true; }</code><technical_language>avoid switch common practice people dont works remove put in this example etc. code understandable maintainable for everyone</technical_language>

Target:
private void timeoutEvent(TimeoutMap.Listener.Type type, String cid) { if (type == Put) { correlationIds.add(cid); } else if (type == Remove || type == Evict) { correlationIds.remove(cid); } dirty = true; }
Source:
<code>protected ViewModel onAuthentication(HttpServletRequest request, HttpServletResponse response, com.stormpath.sdk.idsite.AuthenticationResult result) { AuthenticationResult authcResult = new TransientAuthenticationResult(result.getAccount()); saveResult(request, response, authcResult); publish(new DefaultSuccessfulAuthenticationRequestEvent(request, response, null, authcResult)); <START> if (postLoginHandler != null) { <END> if (!postLoginHandler.handle(request, response, result.getAccount())) { return null; } } return new DefaultViewModel(loginNextUri).setRedirect(true); }</code><technical_language>Is reason collapse this to: if (postLoginHandler != null && !postLoginHandler.handle(request, response, result.getAccount()) {</technical_language>

Target:
protected ViewModel onAuthentication(HttpServletRequest request, HttpServletResponse response, com.stormpath.sdk.idsite.AuthenticationResult result) { AuthenticationResult authcResult = new TransientAuthenticationResult(result.getAccount()); saveResult(request, response, authcResult); publish(new DefaultSuccessfulAuthenticationRequestEvent(request, response, null, authcResult)); if (postLoginHandler != null && !postLoginHandler.handle(request, response, result.getAccount())) { return null; } return new DefaultViewModel(loginNextUri).setRedirect(true); }
Source:
<code><START> static <T> Option<Seq<T>> sequence(Iterable<? extends Option<? extends T>> values) { <END> final Option<Seq<T>> zero = Option.of(List.empty()); final BiFunction<Option<Seq<T>>, Option<? extends T>, Option<Seq<T>>> f = (result, option) -> result.flatMap(sequence -> option.map(sequence::append)); return Iterator.ofAll(values).foldLeft(zero, f); }</code><technical_language>provide 'user friendly' messages NullPointerException, here: java Objects.requireNonNull(values, "values is null");</technical_language>

Target:
static <T> Option<Seq<T>> sequence(Iterable<? extends Option<? extends T>> values) { Objects.requireNonNull(values, "values is null"); List<T> list = List.empty(); for (Option<? extends T> value : values) { if (value.isEmpty()) { return Option.none(); } list = list.prepend(value.get()); } return Option.some(list.reverse()); }
Source:
<code>public LightingManager(ICubicWorld world) { this.world = world; this.skylightCubeDiffuseProcessor = new SkyLightCubeDiffuseProcessor(world, "Sky Light Diffuse", 5); <START> this.firstLightProcessor = new FirstLightProcessor(null, "First Light", world.getCubeCache(), 1); <END> }</code><technical_language>Right pretty disabled "checking if lighting safely calculated" thing. this change in isAreaLoaded "work"</technical_language>

Target:
public LightingManager(ICubicWorld world) { this.world = world; this.skylightCubeDiffuseProcessor = new SkyLightCubeDiffuseProcessor(world, "Sky Light Diffuse", 5); this.firstLightProcessor = new FirstLightProcessor(GeneratorStage.LIGHTING, "First Light", world.getCubeCache(), 1); }
Source:
<code>public void testGetDomainRootAnyType() { Assert.assertEquals("example.xx", matcher.getDomainRoot("example.XX")); Assert.assertEquals("example.xx", matcher.getDomainRoot("www.example.XX")); Assert.assertEquals("example.xx", matcher.getDomainRoot("www.blah.blah.example.XX")); <START> Assert.assertNull(matcher.getDomainRoot("xx")); <END> Assert.assertNull(matcher.getDomainRoot("jp")); Assert.assertNull(matcher.getDomainRoot("ac.jp")); Assert.assertNull(matcher.getDomainRoot("any.tokyo.jp")); Assert.assertEquals("metro.tokyo.jp", matcher.getDomainRoot("metro.tokyo.jp")); Assert.assertEquals("blah.blah.tokyo.jp", matcher.getDomainRoot("blah.blah.tokyo.jp")); Assert.assertEquals("blah.ac.jp", matcher.getDomainRoot("blah.blah.ac.jp")); Assert.assertEquals("garbage", matcher.getDomainRoot("garbage")); Assert.assertEquals("garbage", matcher.getDomainRoot("garbage.garbage")); Assert.assertEquals("garbage", matcher.getDomainRoot("*.garbage.garbage")); Assert.assertEquals("garbage", matcher.getDomainRoot("*.garbage.garbage.garbage")); }</code><technical_language>@nielsbasjes I prefer non-functional changes in a separate commit</technical_language>

Target:
public void testGetDomainRootAnyType() { Assert.assertEquals("example.xx", matcher.getDomainRoot("example.XX")); Assert.assertEquals("example.xx", matcher.getDomainRoot("www.example.XX")); Assert.assertEquals("example.xx", matcher.getDomainRoot("www.blah.blah.example.XX")); Assert.assertEquals(null, matcher.getDomainRoot("xx")); Assert.assertEquals(null, matcher.getDomainRoot("jp")); Assert.assertEquals(null, matcher.getDomainRoot("ac.jp")); Assert.assertEquals(null, matcher.getDomainRoot("any.tokyo.jp")); Assert.assertEquals("metro.tokyo.jp", matcher.getDomainRoot("metro.tokyo.jp")); Assert.assertEquals("blah.blah.tokyo.jp", matcher.getDomainRoot("blah.blah.tokyo.jp")); Assert.assertEquals("blah.ac.jp", matcher.getDomainRoot("blah.blah.ac.jp")); Assert.assertEquals("garbage", matcher.getDomainRoot("garbage")); Assert.assertEquals("garbage", matcher.getDomainRoot("garbage.garbage")); Assert.assertEquals("garbage", matcher.getDomainRoot("*.garbage.garbage")); Assert.assertEquals("garbage", matcher.getDomainRoot("*.garbage.garbage.garbage")); }
Source:
<code>private static void cartesianProductRecurse( int i, List<TupleList> lists, List<Member> partial, Member[] partialArray, int partialSize, List<Member> result) { final TupleList tupleList = lists.get(i); final int partialSizeNext = partialSize + tupleList.getArity(); final int iNext = i + 1; final TupleCursor cursor = tupleList.tupleCursor(); int currentIteration = 0; while (cursor.forward()) { CancellationChecker.checkCancelOrTimeout( <START> currentIteration++, Locus.peek().execution); <END> cursor.currentToArray(partialArray, partialSize); if (i == lists.size() - 1) { result.addAll(partial); } else { cartesianProductRecurse( iNext, lists, partial, partialArray, partialSizeNext, result); } } }</code><technical_language>put Execution in a variable please? execution remove a virtual function calls iteration, this is a tight loop. (please apply this in other instances)</technical_language>

Target:
private static void cartesianProductRecurse( int i, List<TupleList> lists, List<Member> partial, Member[] partialArray, int partialSize, List<Member> result) { final TupleList tupleList = lists.get(i); final int partialSizeNext = partialSize + tupleList.getArity(); final int iNext = i + 1; final TupleCursor cursor = tupleList.tupleCursor(); int currentIteration = 0; Execution execution = Locus.peek().execution; while (cursor.forward()) { CancellationChecker.checkCancelOrTimeout( currentIteration++, execution); cursor.currentToArray(partialArray, partialSize); if (i == lists.size() - 1) { result.addAll(partial); } else { cartesianProductRecurse( iNext, lists, partial, partialArray, partialSizeNext, result); } } }
Source:
<code>public void unloadWorld( WorldEvent.Unload event ) { if( Platform.isServer() ) { <START> final CompassReader compassReader = this.worldSet.remove( event.world ); <END> compassReader.close(); } }</code><technical_language>Is 100% guaranteed, world is contained? else .close() result in NPE</technical_language>

Target:
public void unloadWorld( WorldEvent.Unload event ) { if( Platform.isServer() && this.worldSet.containsKey( event.world ) ) { final CompassReader compassReader = this.worldSet.remove( event.world ); compassReader.close(); } }
Source:
<code>public void visitNode(Tree tree) { NewClassTree newClassTree = (NewClassTree) tree; if (hasOnlyStaticMethod((AbstractTypedTree) newClassTree.identifier())) { <START> String className = ((IdentifierTree) newClassTree.identifier()).name(); <END> addIssue(tree, "Remove this instantiation of \"" + className + "\"."); } }</code><technical_language>ClassTree identifier is necessarily identifier</technical_language>

Target:
public void visitNode(Tree tree) { Tree identifier = ((NewClassTree) tree).identifier(); if (hasOnlyStaticMethod(((AbstractTypedTree) identifier).getSymbolType().getSymbol())) { String message = "Remove this instantiation."; String name = getNewClassName(identifier); if (name != null) { message = "Remove this instantiation of \"{0}\"."; } addIssue(tree, MessageFormat.format(message, name)); } }
Source:
<code>public static CompletionStage<Workspace> getPartialWorkspaceAsync( @NotNull Path clientPath, @NotNull Path workspacePath) { return executeClientAndProcessOutputAsync(clientPath, workspacePath, Collections.singletonList("workfold"), output -> { String workspaceName = null, workspaceUser = null, collectionUrl = null; boolean anyDataAvailable = false; List<Workspace.Mapping> mappings = Lists.newArrayList(); for (String line : output) { Matcher matcher = WORKFOLD_REPORT_PATTERN.matcher(line); if (matcher.matches()) { if (workspaceName == null) { String workspaceNameAndOwner = matcher.group(2); Matcher workspaceNameAndOwnerMatcher = WORKFOLD_WORKSPACE_NAME_AND_OWNER_PATTERN.matcher( workspaceNameAndOwner); if (workspaceNameAndOwnerMatcher.matches()) { workspaceName = workspaceNameAndOwnerMatcher.group(1); workspaceUser = workspaceNameAndOwnerMatcher.group(2); } else { workspaceName = workspaceNameAndOwner; } <START> anyDataAvailable = true; <END> } else if (collectionUrl == null) { collectionUrl = matcher.group(2); } else { String serverPath = matcher.group(1).trim(); String localPath = matcher.group(2); mappings.add(new Workspace.Mapping(serverPath, localPath, false)); } } } return anyDataAvailable ? new Workspace(collectionUrl, workspaceName, null, workspaceUser, null, mappings) : null; }); }</code><technical_language>workspaceDataAvailable is better</technical_language>

Target:
public static CompletionStage<Workspace> getPartialWorkspaceAsync( @NotNull Path clientPath, @NotNull Path workspacePath) { return executeClientAndProcessOutputAsync(clientPath, workspacePath, Collections.singletonList("workfold"), output -> { String workspaceName = null, workspaceUser = null, collectionUrl = null; boolean workspaceDataAvailable = false; List<Workspace.Mapping> mappings = Lists.newArrayList(); for (String line : output) { Matcher matcher = WORKFOLD_REPORT_PATTERN.matcher(line); if (matcher.matches()) { if (workspaceName == null) { String workspaceNameAndOwner = matcher.group(2); Matcher workspaceNameAndOwnerMatcher = WORKFOLD_WORKSPACE_NAME_AND_OWNER_PATTERN.matcher( workspaceNameAndOwner); if (workspaceNameAndOwnerMatcher.matches()) { workspaceName = workspaceNameAndOwnerMatcher.group(1); workspaceUser = workspaceNameAndOwnerMatcher.group(2); } else { workspaceName = workspaceNameAndOwner; } workspaceDataAvailable = true; } else if (collectionUrl == null) { collectionUrl = matcher.group(2); } else { String serverPath = matcher.group(1).trim(); String localPath = matcher.group(2); mappings.add(new Workspace.Mapping(serverPath, localPath, false)); } } } return workspaceDataAvailable ? new Workspace(collectionUrl, workspaceName, null, workspaceUser, null, mappings) : null; }); }
Source:
<code>private boolean setNewValue(Attribute attr) { if (attr.getType().equals("java.util.LinkedHashMap")) { return generateValueFromMap(attr, getUniqueCellId(attr)); } if (attr.getType().equals("java.lang.Integer")) { return generateValueFromNumber(attr, getUniqueCellId(attr)); } if (attr.getType().equals("java.lang.Boolean")) { return generateValueFromBoolean(attr, getUniqueCellId(attr)); } <START> if (attr.getType().equals("java.util.ArrayList") || attr.getType().equals("java.util.LargeArrayList")) { <END> return generateValueFromList(attr, getUniqueCellId(attr)); } return generateValueFromString(attr, getUniqueCellId(attr)); }</code><technical_language>I prefer constant there</technical_language>

Target:
private boolean setNewValue(Attribute attr) { if (attr.getType().equals("java.util.LinkedHashMap")) { return generateValueFromMap(attr, getUniqueCellId(attr)); } if (attr.getType().equals("java.lang.Integer")) { return generateValueFromNumber(attr, getUniqueCellId(attr)); } if (attr.getType().equals("java.lang.Boolean")) { return generateValueFromBoolean(attr, getUniqueCellId(attr)); } if (attr.getType().equals("java.util.ArrayList") || attr.getType().equals(Utils.largeArrayListClassName)) { return generateValueFromList(attr, getUniqueCellId(attr)); } return generateValueFromString(attr, getUniqueCellId(attr)); }