auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public MessageGroup removeMessageFromGroup(Object groupId, Message<?> messageToRemove) { Lock lock = this.lockRegistry.obtain(groupId); try { lock.lockInterruptibly(); try { SimpleMessageGroup group = this.groupIdToMessageGroup.get(groupId); Assert.notNull(group, "MessageGroup for groupId '" + groupId + "' " + "can not be located while attempting to remove Message from the MessageGroup"); if (group.remove(messageToRemove)) { <START> this.groupToUpperBound.get(groupId).release(); <END> group.setLastModified(System.currentTimeMillis()); } return group; } finally { lock.unlock(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new MessagingException("Interrupted while obtaining lock", e); } }</code><technical_language>add a utility method for releases, add Assert.state() UB is null</technical_language>

Target:
public MessageGroup removeMessageFromGroup(Object groupId, Message<?> messageToRemove) { Lock lock = this.lockRegistry.obtain(groupId); try { lock.lockInterruptibly(); try { MessageGroup group = this.groupIdToMessageGroup.get(groupId); Assert.notNull(group, "MessageGroup for groupId '" + groupId + "' " + "can not be located while attempting to remove Message from the MessageGroup"); if (group.remove(messageToRemove)) { UpperBound upperBound = this.groupToUpperBound.get(groupId); Assert.state(upperBound != null, "'upperBound' must not be null."); upperBound.release(); group.setLastModified(System.currentTimeMillis()); } return group; } finally { lock.unlock(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new MessagingException("Interrupted while obtaining lock", e); } }
Source:
<code><START> public Long getPublishedGroupId() { <END> return publishedGroupId; }</code><technical_language>this group id for event</technical_language>

Target:
Long getPublishedGroupId() { return publishedGroupId; }
Source:
<code>public void writeToXml(PrintWriter pw1, int indent) { writeToXmlBegin(pw1, indent); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "equipmentNum", equipmentNum); <START> MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "typeName", MekHqXmlUtil.escape(type.getInternalName())); <END> MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "size", size); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "equipTonnage", equipTonnage); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "trooper", trooper); writeToXmlEnd(pw1, indent); }</code><technical_language>suggestion MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "typeName", type.getInternalName());</technical_language>

Target:
public void writeToXml(PrintWriter pw1, int indent) { writeToXmlBegin(pw1, indent); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "equipmentNum", equipmentNum); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "typeName", type.getInternalName()); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "size", size); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "equipTonnage", equipTonnage); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "trooper", trooper); writeToXmlEnd(pw1, indent); }
Source:
<code>private static OkHttpClient.Builder httpClient() { OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.level(HttpLoggingInterceptor.Level.BODY); httpClient.interceptors().add(interceptor); <START> return httpClient; <END> }</code><technical_language>This is for instance, cached</technical_language>

Target:
private static OkHttpClient.Builder httpClient() { if (httpClientBuilder == null) { httpClientBuilder = new OkHttpClient.Builder(); HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); if (BuildConfig.DEBUG) { interceptor.level(HttpLoggingInterceptor.Level.BASIC); } else { interceptor.level(HttpLoggingInterceptor.Level.NONE); } httpClientBuilder.interceptors().add(interceptor); } return httpClientBuilder; }
Source:
<code>protected void onInit() { <START> this.messageListenerContainer.setMessageListener((ChannelAwareMessageListener) (message, channel) -> { <END> boolean error = false; Map<String, Object> headers = null; Object payload = null; try { payload = this.messageConverter.fromMessage(message); headers = this.headerMapper.toHeadersFromRequest(message.getMessageProperties()); if (this.messageListenerContainer.getAcknowledgeMode() == AcknowledgeMode.MANUAL) { headers.put(AmqpHeaders.DELIVERY_TAG, message.getMessageProperties().getDeliveryTag()); headers.put(AmqpHeaders.CHANNEL, channel); } } catch (RuntimeException e) { if (getErrorChannel() != null) { getMessagingTemplate().send(getErrorChannel(), new ErrorMessage( new ListenerExecutionFailedException("Message conversion failed", e, message))); } else { throw e; } error = true; } if (!error) { sendMessage(getMessageBuilderFactory().withPayload(payload).copyHeaders(headers).build()); } }); this.messageListenerContainer.afterPropertiesSet(); super.onInit(); }</code><technical_language>related this change, extract real class for this Lambda? similar do in other places Kafka Kinesis. I feel easier consult logs in case of StackTraces</technical_language>

Target:
protected void onInit() { this.messageListenerContainer.setMessageListener(new Listener()); this.messageListenerContainer.afterPropertiesSet(); super.onInit(); }
Source:
<code>protected void onUserAction(String userActionName, BaseLoginInteractor interactor, Object... args) { <START> if (authenticationType.equals(AuthenticationType.COOKIE)) { <END> LoginViewModel viewModel = getViewModel(); interactor.start(viewModel.getLogin(), viewModel.getPassword()); } else if (authenticationType.equals(AuthenticationType.BASIC)) { LoginViewModel viewModel = getViewModel(); interactor.start(viewModel.getLogin(), viewModel.getPassword(), viewModel.getBasicAuthMethod()); } else if(authenticationType.equals(AuthenticationType.OAUTH)) { LoginOAuthInteractor oauthInteractor = (LoginOAuthInteractor) interactor; Intent intent = new Intent(getContext(), OAuthActivity.class); intent.putExtra(OAuthActivity.EXTRA_OAUTH_CONFIG, oauthInteractor.getOAuthConfig()); LiferayScreensContext.getActivityFromContext(getContext()) .startActivityForResult(intent, REQUEST_OAUTH_CODE); } }</code><technical_language>equals inverted</technical_language>

Target:
protected void onUserAction(String userActionName, BaseLoginInteractor interactor, Object... args) { if (AuthenticationType.COOKIE.equals(authenticationType)) { LoginViewModel viewModel = getViewModel(); interactor.start(viewModel.getLogin(), viewModel.getPassword()); } else if (AuthenticationType.BASIC.equals(authenticationType)) { LoginViewModel viewModel = getViewModel(); interactor.start(viewModel.getLogin(), viewModel.getPassword(), viewModel.getBasicAuthMethod()); } else if(AuthenticationType.OAUTH.equals(authenticationType)) { LoginOAuthInteractor oauthInteractor = (LoginOAuthInteractor) interactor; Intent intent = new Intent(getContext(), OAuthActivity.class); intent.putExtra(OAuthActivity.EXTRA_OAUTH_CONFIG, oauthInteractor.getOAuthConfig()); LiferayScreensContext.getActivityFromContext(getContext()) .startActivityForResult(intent, REQUEST_OAUTH_CODE); } }
Source:
<code>public Span joinTrace(SpanTextMap textMap) { Map<String, String> carrier = TextMapUtil.asMap(textMap); if (Span.SPAN_SAMPLED.equals(carrier.get(TraceMessageHeaders.SPAN_FLAGS_NAME))) { <START> generateIdIfMissing(carrier, TraceMessageHeaders.SPAN_ID_NAME); <END> generateIdIfMissing(carrier, TraceMessageHeaders.TRACE_ID_NAME); } else if (!hasHeader(carrier, TraceMessageHeaders.SPAN_ID_NAME) || !hasHeader(carrier, TraceMessageHeaders.TRACE_ID_NAME)) { return null; } return extractSpanFromHeaders(carrier, Span.builder()); }</code><technical_language>this is fine, simpler trace == span id absent</technical_language>

Target:
public Span joinTrace(SpanTextMap textMap) { Map<String, String> carrier = TextMapUtil.asMap(textMap); if (Span.SPAN_SAMPLED.equals(carrier.get(TraceMessageHeaders.SPAN_FLAGS_NAME))) { String traceId = generateTraceIdIfMissing(carrier); if (!carrier.containsKey(TraceMessageHeaders.SPAN_ID_NAME)) { carrier.put(TraceMessageHeaders.SPAN_ID_NAME, traceId); } } else if (!hasHeader(carrier, TraceMessageHeaders.SPAN_ID_NAME) || !hasHeader(carrier, TraceMessageHeaders.TRACE_ID_NAME)) { return null; } return extractSpanFromHeaders(carrier, Span.builder()); }
Source:
<code>private Predicate<String> createClassPredicate() { final Collection<String> classes = new HashSet<>(); for (final File buildOutputDirectory : this.compiledCodeDirectories) { if (buildOutputDirectory.exists()) { final DirectoryClassPathRoot dcRoot = new DirectoryClassPathRoot(buildOutputDirectory); classes.addAll(FCollection.map(dcRoot.classNames(), toPredicate())); } } return classes.stream() <START> .map(Glob.toGlobPredicate()) <END> .reduce(x -> false, Predicate::or); }</code><technical_language>reuse Glob.toGlobPredicate(Collection<String> globs) here</technical_language>

Target:
private Predicate<String> createClassPredicate() { final Collection<String> classes = new HashSet<>(); for (final File buildOutputDirectory : this.compiledCodeDirectories) { if (buildOutputDirectory.exists()) { final DirectoryClassPathRoot dcRoot = new DirectoryClassPathRoot(buildOutputDirectory); classes.addAll(FCollection.map(dcRoot.classNames(), toPredicate())); } } return Glob.toGlobPredicate(classes); }
Source:
<code>private long sequenceNumberForIndex(final String indexName) { long lastSequenceNumber = 0; Future<Long> sequenceNumber = queue.submit( new Callable<Long>() { @Override public Long call() { long result = 0; <START> String sql = String.format("SELECT last_sequence FROM %s WHERE index_name = \"%s\"", <END> IndexManager.INDEX_METADATA_TABLE_NAME, indexName); Cursor cursor = null; try { cursor = database.rawQuery(sql, new String[]{}); if (cursor.getCount() > 0) { cursor.moveToNext(); result = cursor.getLong(0); } } catch (SQLException e) { logger.log(Level.SEVERE, "Error getting last sequence number. ", e); } finally { DatabaseUtils.closeCursorQuietly(cursor); } return result; } }); try { lastSequenceNumber = sequenceNumber.get(); } catch (ExecutionException e) { logger.log(Level.SEVERE, "Execution error encountered:", e); } catch (InterruptedException e) { logger.log(Level.SEVERE, "Execution interrupted error encountered:", e); } return lastSequenceNumber; }</code><technical_language>do "WHERE index_name = ?" bind argument placeholder</technical_language>

Target:
private long sequenceNumberForIndex(final String indexName) { Future<Long> sequenceNumber = queue.submit( new Callable<Long>() { @Override public Long call() { long result = 0; String sql = String.format("SELECT last_sequence FROM %s WHERE index_name = ?", IndexManager.INDEX_METADATA_TABLE_NAME); Cursor cursor = null; try { cursor = database.rawQuery(sql, new String[]{ indexName }); if (cursor.getCount() > 0) { cursor.moveToNext(); result = cursor.getLong(0); } } catch (SQLException e) { logger.log(Level.SEVERE, "Error getting last sequence number. ", e); } finally { DatabaseUtils.closeCursorQuietly(cursor); } return result; } }); long lastSequenceNumber = 0; try { lastSequenceNumber = sequenceNumber.get(); } catch (ExecutionException e) { logger.log(Level.SEVERE, "Execution error encountered:", e); } catch (InterruptedException e) { logger.log(Level.SEVERE, "Execution interrupted error encountered:", e); } return lastSequenceNumber; }
Source:
<code>private void clearAllNotifications() { int numChildren = mStackScroller.getChildCount(); final ArrayList<View> viewsToHide = new ArrayList<View>(numChildren); for (int i = 0; i < numChildren; i++) { final View child = mStackScroller.getChildAt(i); if (child instanceof ExpandableNotificationRow) { if (mStackScroller.canChildBeDismissed(child)) { if (child.getVisibility() == View.VISIBLE) { viewsToHide.add(child); } } ExpandableNotificationRow row = (ExpandableNotificationRow) child; List<ExpandableNotificationRow> children = row.getNotificationChildren(); if (row.areChildrenExpanded() && children != null) { for (ExpandableNotificationRow childRow : children) { if (childRow.getVisibility() == View.VISIBLE) { viewsToHide.add(childRow); } } } } } if (viewsToHide.isEmpty()) { animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); return; } addPostCollapseAction(new Runnable() { @Override public void run() { mStackScroller.setDismissAllInProgress(false); try { mBarService.onClearAllNotifications(mCurrentUserId); } catch (Exception ex) { } } <START> for (View v : viewsToHide) { <END> if (!(v instanceof ExpandableNotificationRow)) { continue; } StatusBarNotification sbn = ((ExpandableNotificationRow)v).getStatusBarNotification(); if (!sbn.isClearable()) { mStackScroller.snapViewAnimated(v); } } }); performDismissAllAnimations(viewsToHide); }</code><technical_language>is this run</technical_language>

Target:
private void clearAllNotifications() { int numChildren = mStackScroller.getChildCount(); final ArrayList<View> viewsToHide = new ArrayList<View>(numChildren); for (int i = 0; i < numChildren; i++) { final View child = mStackScroller.getChildAt(i); if (child instanceof ExpandableNotificationRow) { if (mStackScroller.canChildBeDismissed(child)) { if (child.getVisibility() == View.VISIBLE) { viewsToHide.add(child); } } ExpandableNotificationRow row = (ExpandableNotificationRow) child; List<ExpandableNotificationRow> children = row.getNotificationChildren(); if (row.areChildrenExpanded() && children != null) { for (ExpandableNotificationRow childRow : children) { if (childRow.getVisibility() == View.VISIBLE) { viewsToHide.add(childRow); } } } } } if (viewsToHide.isEmpty()) { animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); return; } addPostCollapseAction(new Runnable() { @Override public void run() { mStackScroller.setDismissAllInProgress(false); try { mBarService.onClearAllNotifications(mCurrentUserId); } catch (Exception ex) { } for (View v : viewsToHide) { if (!(v instanceof ExpandableNotificationRow)) { continue; } StatusBarNotification sbn = ((ExpandableNotificationRow)v).getStatusBarNotification(); if (!sbn.isClearable()) { mStackScroller.snapView(v, false ); } } } }); performDismissAllAnimations(viewsToHide); }
Source:
<code>public void yield_from(){ setRootRule(PythonGrammar.YIELD_EXPR); assertThat(p).matches("yield from foo"); assertThat(p).matches("yield foo"); <START> assertThat(p).notMatches("yield from"); <END> }</code><technical_language>@d3matt good here. i merge: add assertion yield arguments? Thanks</technical_language>

Target:
public void yield_from(){ setRootRule(PythonGrammar.YIELD_EXPR); assertThat(p).matches("yield"); assertThat(p).matches("yield from foo"); assertThat(p).matches("yield foo"); assertThat(p).notMatches("yield from"); }
Source:
<code>public InputArgument(Block block, Type signature) { inputText = new SimpleStringProperty(signature.toHaskellType()); this.loadFXML("InputArgument"); inputAnchor = new InputAnchor(block, signature); inputAnchor.layoutXProperty().bind(inputLabel.widthProperty().divide(2)); <START> inputAnchor.isErrorProperty().addListener((ObservableValue<? extends Boolean> value, Boolean oldValue, Boolean newValue) -> setError(newValue)); <END> inputLabel.layoutYProperty().bind(this.heightProperty().divide(2).subtract(inputLabel.heightProperty().divide(2))); this.setPrefHeight(ArgumentSpace.HEIGHT); this.getChildren().add(inputAnchor); }</code><technical_language>lambda signature is a bit long... sense a method reference instead? inputAnchor.isErrorProperty().addListener(this::setError); // ... private void setError(ObservableValue<? extends Boolean> value, Boolean oldValue, Boolean newValue) { setError(newValue) } // ..</technical_language>

Target:
public InputArgument(Block block, Type signature) { inputText = new SimpleStringProperty(signature.toHaskellType()); this.loadFXML("InputArgument"); inputAnchor = new InputAnchor(block, signature); inputAnchor.layoutXProperty().bind(inputLabel.widthProperty().divide(2)); inputAnchor.isErrorProperty().addListener(this::checkError); inputLabel.layoutYProperty().bind(this.heightProperty().divide(2).subtract(inputLabel.heightProperty().divide(2))); this.setPrefHeight(ArgumentSpace.HEIGHT); this.getChildren().add(inputAnchor); }
Source:
<code><START> private String encode(final String value) throws Exception { <END> return URLEncoder.encode(value, StandardCharsets.UTF_8); }</code><technical_language>remove throws clause</technical_language>

Target:
private String encode(final String value) { return URLEncoder.encode(value, StandardCharsets.UTF_8); }
Source:
<code>public void handle(LeaveGroupResponse leaveResponse, RequestFuture<Void> future) { final List<MemberResponse> members = leaveResponse.memberResponses(); if (members.size() > 1) { future.raise(new IllegalStateException("The expected leave group response " + "should only contain no more than one member info, however get " + members)); } final Errors error = leaveResponse.error(); if (error == Errors.NONE) { log.debug("LeaveGroup response with returned successfully: {}", sentGeneration, response); future.complete(null); } else { <START> log.error("LeaveGroup response with failed with error: {}", sentGeneration, error.message()); <END> future.raise(error); } }</code><technical_language>nit: original a more accurate? response fail; contained error indicating request failed</technical_language>

Target:
public void handle(LeaveGroupResponse leaveResponse, RequestFuture<Void> future) { final List<MemberResponse> members = leaveResponse.memberResponses(); if (members.size() > 1) { future.raise(new IllegalStateException("The expected leave group response " + "should only contain no more than one member info, however get " + members)); } final Errors error = leaveResponse.error(); if (error == Errors.NONE) { log.debug("LeaveGroup response with returned successfully: {}", sentGeneration, response); future.complete(null); } else { log.error("LeaveGroup request with failed with error: {}", sentGeneration, error.message()); future.raise(error); } }
Source:
<code>public ObjectRule untitledRaml() { return super.untitledRaml() .with(annotationTypesField()) .with(annotationField()) .with(typesField()) .with(usesField()) <START> .with(exclusiveKeys(BaseRamlGrammar.TYPES_KEY_NAME, BaseRamlGrammar.SCHEMAS_KEY_NAME)); <END> }</code><technical_language>static imports</technical_language>

Target:
public ObjectRule untitledRaml() { return super.untitledRaml() .with(annotationTypesField()) .with(annotationField()) .with(typesField()) .with(usesField()) .with(exclusiveKeys(TYPES_KEY_NAME, SCHEMAS_KEY_NAME)); }
Source:
<code>public ListenableFuture<Long> count(Class<?> entityClass) { Assert.notNull(entityClass, "Entity type must not be null"); <START> return doCount(Query.empty(), entityClass, getKeyspace(entityClass), getTableName(entityClass)); <END> }</code><technical_language>table name keyspace name together, sense introduce a object encapsulates pieces of information. introducing object TableName contains table name optional keyspace name</technical_language>

Target:
public ListenableFuture<Long> count(Class<?> entityClass) { Assert.notNull(entityClass, "Entity type must not be null"); return doCount(Query.empty(), entityClass, constructTableCoordinates(entityClass)); }
Source:
<code>public void parseConfig(List<String> configParts) throws BindingConfigParseException { String id = ""; Boolean group = false; Integer channelID = 0; for (int i = 0; i < configParts.size(); i++) { String paramName = configParts.get(i).split("=")[0].toLowerCase(); String paramValue = configParts.get(i).split("=")[1]; switch (paramName) { case "id": id = paramValue; break; case "group": if (paramValue.equals("1") || paramValue.toLowerCase().equals("true")) { group = true; } break; case "channel": try { channelID = Integer.parseInt(paramValue); } catch (NumberFormatException e) { throw new BindingConfigParseException("Channel ID (" + paramValue + ") is not a number."); } } } if (id.length() != 26) { throw new BindingConfigParseException("The ID must contain exactly 26 digits!"); } for (int i = 0; i < id.length(); i++) { if (id.charAt(i) != '0' && id.charAt(i) != '1') { throw new BindingConfigParseException("The ID must contains only the digits 1 and 0!"); } } <START> if (channelID < 0 && channelID > 15) { <END> throw new BindingConfigParseException("The channel ID must be in a range from 0 to 15!"); } String channelIDCode = StringUtils.leftPad(Integer.toBinaryString(channelID), 4, "0"); commandON = id + getGroupCode(group) + "1" + channelIDCode; commandOFF = id + getGroupCode(group) + "0" + channelIDCode; logger.trace("commandON = {}", commandON); logger.trace("commandOFF = {}", commandOFF); }</code><technical_language>This conditional true</technical_language>

Target:
public void parseConfig(List<String> configParts) throws BindingConfigParseException { String id = ""; Boolean group = false; Integer channelID = 0; for (int i = 0; i < configParts.size(); i++) { String paramName = configParts.get(i).split("=")[0].toLowerCase(); String paramValue = configParts.get(i).split("=")[1]; switch (paramName) { case "id": id = paramValue; break; case "group": if (paramValue.equals("1") || paramValue.toLowerCase().equals("true")) { group = true; } break; case "channel": try { channelID = Integer.parseInt(paramValue); } catch (NumberFormatException e) { throw new BindingConfigParseException("Channel ID (" + paramValue + ") is not a number."); } } } if (id.length() != 26) { throw new BindingConfigParseException("The ID must contain exactly 26 digits!"); } for (int i = 0; i < id.length(); i++) { if (id.charAt(i) != '0' && id.charAt(i) != '1') { throw new BindingConfigParseException("The ID must contains only the digits 1 and 0!"); } } if (channelID < 0 || channelID > 15) { throw new BindingConfigParseException("The channel ID must be in a range from 0 to 15!"); } String channelIDCode = StringUtils.leftPad(Integer.toBinaryString(channelID), 4, "0"); commandON = id + getGroupCode(group) + "1" + channelIDCode; commandOFF = id + getGroupCode(group) + "0" + channelIDCode; logger.trace("commandON = {}", commandON); logger.trace("commandOFF = {}", commandOFF); }
Source:
<code>public void init() { if (tpe != null && !tpe.isShutdown()) { tpe.shutdownNow(); } <START> tpe = new ThreadPoolExecutor(1, 2, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(1000)); <END> }</code><technical_language>remove Runnable</technical_language>

Target:
public void init() { if (tpe != null && !tpe.isShutdown()) { tpe.shutdownNow(); } tpe = new ThreadPoolExecutor(POOL_SIZE, MAX_POOL_SIZE, KEEP_ALIVE_TIME, TimeUnit.SECONDS, new LinkedBlockingQueue<>(QUEUE_SIZE)); }
Source:
<code><START> default boolean isEmpty() { <END> return this.shadow$isEmpty(); }</code><technical_language>If this is intrinsic (which is in dev time), need prefix a prefix for @Implements(iface = ...) mixing well</technical_language>

Target:
default boolean api$isEmpty() { return this.shadow$isEmpty(); }
Source:
<code>public void startStripe(InputStreamSources dictionaryStreamSources, List<ColumnEncoding> encoding) throws IOException { ColumnEncoding.ColumnEncodingKind kind = encoding.get(streamDescriptor.getStreamId()) .getColumnEncoding(streamDescriptor.getSequence()) .getColumnEncodingKind(); <START> if (kind == DIRECT || kind == DIRECT_V2 || kind == DWRF_DIRECT) { <END> currentReader = directReader; } else if (kind == DICTIONARY) { currentReader = dictionaryReader; } else { throw new IllegalArgumentException("Unsupported encoding " + kind); } currentReader.startStripe(dictionaryStreamSources, encoding); }</code><technical_language>I this expressed a switch statement</technical_language>

Target:
public void startStripe(InputStreamSources dictionaryStreamSources, List<ColumnEncoding> encoding) throws IOException { ColumnEncoding.ColumnEncodingKind kind = encoding.get(streamDescriptor.getStreamId()) .getColumnEncoding(streamDescriptor.getSequence()) .getColumnEncodingKind(); switch (kind) { case DIRECT: case DIRECT_V2: case DWRF_DIRECT: currentReader = directReader; break; case DICTIONARY: currentReader = dictionaryReader; break; default: throw new IllegalArgumentException("Unsupported encoding " + kind); } currentReader.startStripe(dictionaryStreamSources, encoding); }
Source:
<code>private void restartUnhealthy() { runningProcesses.stream() .filter(consumerProcess -> !isHealthy(consumerProcess)) .forEach(consumerProcess -> { Signal restartUnhealthy = Signal.of(RESTART_UNHEALTHY, consumerProcess.getSubscriptionName()); logger.info("Lost contact with consumer {}, last seen {}ms ago. Creating signal {}.", consumerProcess, consumerProcess.lastSeen(), restartUnhealthy); <START> taskQueue.offer(Signal.of(RESTART_UNHEALTHY, consumerProcess.getSubscriptionName())); <END> }); }</code><technical_language>lost id here. Please change line taskQueue.offer(restartUnhealthy)</technical_language>

Target:
private void restartUnhealthy() { runningProcesses.stream() .filter(consumerProcess -> !consumerProcess.isHealthy()) .forEach(consumerProcess -> { Signal restartUnhealthy = Signal.of(RESTART_UNHEALTHY, consumerProcess.getSubscriptionName()); logger.info("Lost contact with consumer {}, last seen {}ms ago {}. {}", consumerProcess, consumerProcess.lastSeen(), restartUnhealthy.getLogWithIdAndType()); taskQueue.offer(restartUnhealthy); }); }
Source:
<code>public CoordinatorRuleManager( @Json ObjectMapper jsonMapper, Supplier<TieredBrokerConfig> config, @Coordinator DruidLeaderClient druidLeaderClient ) { this.jsonMapper = jsonMapper; this.config = config; this.druidLeaderClient = druidLeaderClient; this.rules = new AtomicReference<>( <START> new HashMap<String, List<Rule>>() <END> ); }</code><technical_language>Please Collections.emptyMap()</technical_language>

Target:
public CoordinatorRuleManager( @Json ObjectMapper jsonMapper, Supplier<TieredBrokerConfig> config, @Coordinator DruidLeaderClient druidLeaderClient ) { this.jsonMapper = jsonMapper; this.config = config; this.druidLeaderClient = druidLeaderClient; this.rules = new AtomicReference<>( Collections.emptyMap() ); }
Source:
<code><START> public ICompletableFuture<Map<K, Object>> executeOnKeysInternalAsync(Set<K> keys, Set<Data> dataKeys, <END> EntryProcessor entryProcessor, final ExecutionCallback<Map<K, Object>> callback) { if (dataKeys.isEmpty()) { toDataCollectionWithNonNullKeyValidation(keys, dataKeys); } Collection<Integer> partitionsForKeys = getPartitionsForKeys(dataKeys); OperationFactory operationFactory = operationProvider.createMultipleEntryOperationFactory(name, dataKeys, entryProcessor); final SimpleCompletableFuture<Map<K, Object>> resultFuture = new SimpleCompletableFuture<Map<K, Object>>(getNodeEngine()); ExecutionCallback<Map<Integer, Object>> partialCallback = new ExecutionCallback<Map<Integer, Object>>() { @Override public void onResponse(Map<Integer, Object> response) { Map<K, Object> result = createHashMap(response.size()); for (Object object : response.values()) { MapEntries mapEntries = (MapEntries) object; mapEntries.putAllToMap(serializationService, result); } resultFuture.setResult(result); if (callback != null) { callback.onResponse(result); } } @Override public void onFailure(Throwable t) { resultFuture.setResult(t); if (callback != null) { callback.onFailure(t); } } }; operationService.invokeOnPartitionsAsync(SERVICE_NAME, operationFactory, partitionsForKeys, partialCallback); return resultFuture; }</code><technical_language>callback is null. Do need it</technical_language>

Target:
public ICompletableFuture<Map<K, Object>> executeOnKeysInternalAsync(Set<K> keys, Set<Data> dataKeys, EntryProcessor entryProcessor, final ExecutionCallback<Map<K, Object>> callback) { if (dataKeys.isEmpty()) { toDataCollectionWithNonNullKeyValidation(keys, dataKeys); } Collection<Integer> partitionsForKeys = getPartitionsForKeys(dataKeys); OperationFactory operationFactory = operationProvider.createMultipleEntryOperationFactory(name, dataKeys, entryProcessor); final SimpleCompletableFuture<Map<K, Object>> resultFuture = new SimpleCompletableFuture<Map<K, Object>>(getNodeEngine()); ExecutionCallback<Map<Integer, Object>> partialCallback = new ExecutionCallback<Map<Integer, Object>>() { @Override public void onResponse(Map<Integer, Object> response) { Map<K, Object> result = null; try { result = createHashMap(response.size()); for (Object object : response.values()) { MapEntries mapEntries = (MapEntries) object; mapEntries.putAllToMap(serializationService, result); } } catch (Throwable e) { resultFuture.setResult(e); if (callback != null) { callback.onFailure(e); } } resultFuture.setResult(result); if (callback != null) { callback.onResponse(result); } } @Override public void onFailure(Throwable t) { resultFuture.setResult(t); if (callback != null) { callback.onFailure(t); } } }; operationService.invokeOnPartitionsAsync(SERVICE_NAME, operationFactory, partitionsForKeys, partialCallback); return resultFuture; }
Source:
<code><START> public void testIsAdHocAutostart_true() throws Exception { <END> String id = UUID.randomUUID().toString(); AdHocSubProcess adHocSubProcess = bpmn2.createAdHocSubProcess(); adHocSubProcess.setId(id); CustomElement.autoStart.of(adHocSubProcess).set(Boolean.TRUE); tested = new AdHocSubProcessPropertyReader(adHocSubProcess, definitionResolverReal.getDiagram(), definitionResolverReal); assertTrue(tested.isAdHocAutostart()); }</code><technical_language>Exception is thrown</technical_language>

Target:
public void testIsAdHocAutostart_true() { String id = UUID.randomUUID().toString(); AdHocSubProcess adHocSubProcess = bpmn2.createAdHocSubProcess(); adHocSubProcess.setId(id); CustomElement.autoStart.of(adHocSubProcess).set(Boolean.TRUE); tested = new AdHocSubProcessPropertyReader(adHocSubProcess, definitionResolverReal.getDiagram(), definitionResolverReal); assertTrue(tested.isAdHocAutostart()); }
Source:
<code>public OutputStream setBinaryStream(long pos) throws SQLException { try { if (isDebugEnabled()) { debugCode("setBinaryStream("+pos+");"); } checkClosed(); if (pos != 1) { throw DbException.getInvalidValueException("pos", pos); } if (value.getPrecision() != 0) { throw DbException.getInvalidValueException("length", value.getPrecision()); } final PipedInputStream in = new PipedInputStream(); final Task task = new Task() { @Override public void call() { <START> value = conn.createBlob(in, -1); <END> } }; PipedOutputStream out = new PipedOutputStream(in) { @Override public void close() throws IOException { super.close(); try { task.get(); } catch (Exception e) { throw DbException.convertToIOException(e); } } }; task.execute(); return new BufferedOutputStream(out); } catch (Exception e) { throw logAndConvert(e); } }</code><technical_language>This change generates additional synthetic accessor method. Local final variable avoid this</technical_language>

Target:
public OutputStream setBinaryStream(long pos) throws SQLException { try { if (isDebugEnabled()) { debugCode("setBinaryStream("+pos+");"); } checkClosed(); if (pos != 1) { throw DbException.getInvalidValueException("pos", pos); } if (value.getPrecision() != 0) { throw DbException.getInvalidValueException("length", value.getPrecision()); } final JdbcConnection c = conn; final PipedInputStream in = new PipedInputStream(); final Task task = new Task() { @Override public void call() { value = c.createBlob(in, -1); } }; PipedOutputStream out = new PipedOutputStream(in) { @Override public void close() throws IOException { super.close(); try { task.get(); } catch (Exception e) { throw DbException.convertToIOException(e); } } }; task.execute(); return new BufferedOutputStream(out); } catch (Exception e) { throw logAndConvert(e); } }
Source:
<code>protected VM getVmFromConfiguration() { QueryReturnValue queryReturnValue = runInternalQuery( QueryType.GetVmConfigurationBySnapshot, new IdQueryParameters(getParameters().getSnapshotId())); <START> return queryReturnValue.getSucceeded() ? queryReturnValue.getReturnValue() : null; <END> }</code><technical_language>coverity mad of a NPE return null</technical_language>

Target:
private VM getVmFromConfiguration() { QueryReturnValue queryReturnValue = runInternalQuery( QueryType.GetVmConfigurationBySnapshot, new IdQueryParameters(getParameters().getSnapshotId())); return queryReturnValue.getSucceeded() ? queryReturnValue.getReturnValue() : null; }
Source:
<code>public boolean hasNext() { <START> if(currentIteratorHasNext()) <END> { return true; } loadNextChunkIterator(); return currentIteratorHasNext(); }</code><technical_language>if ( :trollface:</technical_language>

Target:
public boolean hasNext() { boolean interrupted = Thread.interrupted(); Boolean dataLoaded = null; try { while (!currentIteratorHasNext() && dataLoaded == null) { try { dataLoaded = tryLoadNextChunkIterator(); } catch (InterruptedException ex) { interrupted = true; } } return currentIteratorHasNext(); } finally { if (interrupted) { Thread.currentThread().interrupt(); } } }
Source:
<code>private void handleResponsesWithoutContentLength(CarbonMessage cMsg) { if (cMsg.isAlreadyRead()) { MessageDataSource messageDataSource = cMsg.getMessageDataSource(); if (messageDataSource != null) { messageDataSource.serializeData(); cMsg.setEndOfMsgAdded(true); cMsg.getHeaders().remove(Constants.HTTP_CONTENT_LENGTH); } else { <START> LOG.error("Message is already built but cannot find the MessageDataSource"); <END> } } if (cMsg.getHeader(Constants.HTTP_TRANSFER_ENCODING) == null && cMsg.getHeader(Constants.HTTP_CONTENT_LENGTH) == null) { cMsg.setHeader(Constants.HTTP_CONTENT_LENGTH, String.valueOf(cMsg.getFullMessageLength())); } }</code><technical_language>is specific reason for "LOG" in capitals. capitals define constants enums etc</technical_language>

Target:
private void handleResponsesWithoutContentLength(CarbonMessage cMsg) { if (cMsg.isAlreadyRead()) { MessageDataSource messageDataSource = cMsg.getMessageDataSource(); if (messageDataSource != null) { messageDataSource.serializeData(); cMsg.setEndOfMsgAdded(true); cMsg.getHeaders().remove(Constants.HTTP_CONTENT_LENGTH); } else { logger.error("Message is already built but cannot find the MessageDataSource"); } } if (cMsg.getHeader(Constants.HTTP_TRANSFER_ENCODING) == null && cMsg.getHeader(Constants.HTTP_CONTENT_LENGTH) == null) { cMsg.setHeader(Constants.HTTP_CONTENT_LENGTH, String.valueOf(cMsg.getFullMessageLength())); } }
Source:
<code><START> public UpdateQueue(ArrayList<Subscriber> subscribers, ArrayList<Alert> alerts, String pushType, String errorQueue, int retries, int retriesDelay) { <END> this.subscribers = subscribers; this.alerts = alerts; this.pushType = pushType; this.error_queue = errorQueue; this.retries = retries; this.retriesDelay = retriesDelay; }</code><technical_language>Please try compatible method overloading</technical_language>

Target:
public UpdateQueue(ArrayList<Subscriber> subscribers, ArrayList<Alert> alerts, String pushType, String errorQueue, int retries, int retriesDelay) { this.subscribers = subscribers; this.alerts = alerts; this.pushType = pushType; this.error_queue = errorQueue; this.retries = retries; this.retries_delay = retriesDelay; }
Source:
<code>public void reset() { drId = Long.MIN_VALUE; <START> spUniqueId = Long.MIN_VALUE; <END> mpUniqueId = Long.MIN_VALUE; }</code><technical_language>a matter of default, a odd Long.MIN_VALUE while rest of DR 0, a.k.a. InvocationBuffer.UNSET_UNIQUE_ID</technical_language>

Target:
public void reset() { drId = Long.MIN_VALUE; spUniqueId = 0; mpUniqueId = 0; }
Source:
<code><START> private static double mean(int[] m) { <END> double sum = 0; for (int i = 0; i < m.length; i++) { sum += m[i]; } return sum / m.length; }</code><technical_language>need static</technical_language>

Target:
private double mean(int[] m) { double sum = 0; for (int i = 0; i < m.length; i++) { sum += m[i]; } return sum / m.length; }
Source:
<code>private Repository openRepo() throws TransportException { try { <START> RepositoryBuilder builder = new RepositoryBuilder() <END> .setGitDir(remoteGitDir); if (local != null) { builder.setFS(local.getFS()); } return builder.build(); } catch (IOException err) { throw new TransportException(uri, JGitText.get().notAGitDirectory); } }</code><technical_language>optional: move this 'try': RepositoryBuilder builder = new RepositoryBuilder(); if (local != null) { builder.setFS(local.getFS()); } builder.setGitDir(remoteGitDir); try { return builder.build(); } catch (... Alternatively, avoid breaking chaining of calls: try { return new RepositoryBuilder() .setFS(local != null ? local.getFS() : FS.DETECTED) .setGitDir(remoteGitDir) .build(); } catch (..</technical_language>

Target:
private Repository openRepo() throws TransportException { try { return new RepositoryBuilder() .setFS(local != null ? local.getFS() : FS.DETECTED) .setGitDir(remoteGitDir).build(); } catch (IOException err) { throw new TransportException(uri, JGitText.get().notAGitDirectory); } }
Source:
<code>private synchronized boolean isLeader(CorfuMsg msg, IServerRouter r) { boolean lostLeadership = isActive.get() || !isLeader.get(); if (lostLeadership) { log.warn("This node has changed, active={}, leader={}. Dropping message type={}, id={}", isActive.get(), <START> isLeader.get(), msg.getMsgType()); <END> LogReplicationLeadershipLoss payload = new LogReplicationLeadershipLoss(serverContext.getLocalEndpoint()); r.sendResponse(msg, CorfuMsgType.LOG_REPLICATION_LEADERSHIP_LOSS.payloadMsg(payload)); } return !lostLeadership; }</code><technical_language>id is needed</technical_language>

Target:
private synchronized boolean isLeader(CorfuMsg msg, IServerRouter r) { boolean lostLeadership = isActive.get() || !isLeader.get(); if (lostLeadership) { log.warn("This node has changed, active={}, leader={}. Dropping message type={}, id={}", isActive.get(), isLeader.get(), msg.getMsgType(), msg.getRequestID()); LogReplicationLeadershipLoss payload = new LogReplicationLeadershipLoss(serverContext.getLocalEndpoint()); r.sendResponse(msg, CorfuMsgType.LOG_REPLICATION_LEADERSHIP_LOSS.payloadMsg(payload)); } return !lostLeadership; }
Source:
<code>public void previewPageFilesAreDeletedOnCancel() { openGradleNewWizard(); bot.waitUntil(Conditions.shellIsActive(NEW_GRADLE_PROJECT_WIZARD_TITLE)); bot.textWithLabel(ProjectWizardMessages.Label_ProjectName).setText(TEST_PROJECT_NAME); bot.captureScreenshot("new_wiz.png"); SWTBotButton nextButton = bot.button(IDialogConstants.NEXT_LABEL); bot.waitUntil(Conditions.widgetIsEnabled(nextButton)); nextButton.click(); bot.waitUntil(Conditions.shellIsActive(NEW_GRADLE_PROJECT_WIZARD_TITLE)); bot.button(IDialogConstants.NEXT_LABEL).click(); bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.BACK_LABEL))); File workspaceRootDir = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile(); <START> System.out.println(workspaceRootDir.getAbsolutePath()); <END> assertTrue(workspaceRootDir.isDirectory()); File[] workspaceRootFiles = workspaceRootDir.listFiles(); assertTrue(workspaceRootFiles.length > 0); Optional<File> firstMatch = FluentIterable.of(workspaceRootFiles) .firstMatch(new FileNamePredicate(TEST_PROJECT_NAME)); assertTrue(firstMatch.isPresent()); File testProjectDir = firstMatch.get(); assertTrue(testProjectDir.isDirectory()); bot.button(IDialogConstants.CANCEL_LABEL).click(); assertFalse(testProjectDir.exists()); }</code><technical_language>This code similar previewPageFilesAreCreatedAndDeleted, method System.out.println. Is this a development leftover</technical_language>

Target:
public void previewPageFilesAreDeletedOnCancel() { openGradleNewWizard(); bot.waitUntil(Conditions.shellIsActive(NEW_GRADLE_PROJECT_WIZARD_TITLE)); bot.textWithLabel(ProjectWizardMessages.Label_ProjectName).setText(TEST_PROJECT_NAME); SWTBotButton nextButton = bot.button(IDialogConstants.NEXT_LABEL); bot.waitUntil(Conditions.widgetIsEnabled(nextButton)); nextButton.click(); bot.waitUntil(Conditions.shellIsActive(NEW_GRADLE_PROJECT_WIZARD_TITLE)); bot.button(IDialogConstants.NEXT_LABEL).click(); bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.BACK_LABEL))); File workspaceRootDir = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile(); assertTrue(workspaceRootDir.isDirectory()); File[] workspaceRootFiles = workspaceRootDir.listFiles(); assertTrue(workspaceRootFiles.length > 0); Optional<File> firstMatch = FluentIterable.of(workspaceRootFiles) .firstMatch(new FileNamePredicate(TEST_PROJECT_NAME)); assertTrue(firstMatch.isPresent()); File testProjectDir = firstMatch.get(); assertTrue(testProjectDir.isDirectory()); bot.button(IDialogConstants.CANCEL_LABEL).click(); assertFalse(testProjectDir.exists()); }
Source:
<code>public void testSameHash() { <START> Object key1 = new Object() { <END> @Override public int hashCode() { return 1; } }; Object key2 = new Object() { @Override public int hashCode() { return 1; } }; assertEquals(key1.hashCode(), key2.hashCode()); assertNotEquals(key1, key2); Cache<Object, Integer> cache = new CacheSimple<>(10); cache.put(key1, 1); assertTrue("Same key, expected in cache", cache.containsKey(key1)); assertFalse("Keys with same hash code should not be considered equal", cache.containsKey(key2)); }</code><technical_language>eventual call .equals() in main code falls == (which passes test), nice this a more explicit overriding .equals() in guys making clear equal() other, necessary</technical_language>

Target:
public void testSameHash() { CompoundKey key1 = new CompoundKey(1, 1); CompoundKey key2 = new CompoundKey(1, 2); assertEquals(key1.hashCode(), key2.hashCode()); assertNotEquals(key1, key2); Cache<CompoundKey, Integer> cache = new CacheSimple<>(10); cache.put(key1, 1); assertTrue("Same key, expected to be in cache", cache.containsKey(key1)); assertFalse("Keys with same hash code should not be considered equal", cache.containsKey(key2)); }
Source:
<code>public void execute() { initializeAndStart(); <START> try (QuietClosable ignored = this::closePartitions) { <END> while (!isStopping()) iteration(); } }</code><technical_language>naming misleading. is more unused in try block. point of this idiom. suppressing exceptions finally instead of originator. suppressible? Also, unused better, is untrue especially if closePartitions is method throws. I suppressible highlights intentions specifically</technical_language>

Target:
public void execute() { initializeAndStart(); try (UncheckedCloseable suppressible = this::closePartitions) { while (!isStopping()) iteration(); } }
Source:
<code>public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); <START> mInviteCollaboratorsListener = ((InviteCollaboratorsListener) getActivity()); <END> mCollabInitialsView.setInviteCollaboratorsListener(mInviteCollaboratorsListener); }</code><technical_language>I this assumption activity this Fragment implements InviteCollaboratorsListener, I is true here. in case wants reuse this fragment else, this dependency is clean fail runtime. Activity set this listener</technical_language>

Target:
public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mCollabInitialsView.setShowCollaboratorsListener(this); }
Source:
<code>private Object findObject(ResultSet rs, String columnName) throws SQLException { int separatorIndex = columnName.indexOf('.'); if (separatorIndex > 0) { try { return rs.getObject(columnName.substring(separatorIndex)); <START> } catch (SQLException ignored) { } <END> } return rs.getObject(columnName); }</code><technical_language>a fan of testing this time this. Generating stack traces is pretty performance intensive. A option allow a Map<String, String> configurable map fields result set field. This allows more flexible I think</technical_language>

Target:
private Object findObject(ResultSet rs, String columnName) throws SQLException{ return rs.getObject(queryProvider.getSortKeyResultName(columnName)); }
Source:
<code>public boolean pingAgent( String applicationName, String rootInstanceName, String message, long timeout ) throws InterruptedException, IOException { final ManagedApplication ma = this.appNameToManagedApplication.get( applicationName ); if (ma == null) { throw new NoSuchElementException( "No application with name: " + applicationName ); } final Application app = ma.getApplication(); Instance instance = null; for (Instance i : app.getRootInstances()) { if (i.getName().equals( rootInstanceName )) { instance = i; break; } } if (instance == null) { throw new NoSuchElementException( "No root instance with name " + rootInstanceName + " in application " + applicationName); } MsgEcho ping = new MsgEcho( "PING:" + message ); this.messagingClient.sendMessageToAgent( app, instance, ping ); logger.fine( "Sent PING request message=" + message + "timeout=" + timeout + "ms to application=" + applicationName + ", agent=" + rootInstanceName ); boolean hasFound = false; final long deadline = System.currentTimeMillis() + timeout; final String expectedMessage = "PONG:" + message; while (true) { synchronized ( this.echoMessages ) { for (Iterator<MsgEcho> i = echoMessages.iterator(); i.hasNext(); ) { final MsgEcho m = i.next(); <START> if ( m.getContent().equals( expectedMessage ) ) { <END> hasFound = true; i.remove(); break; } } long now = System.currentTimeMillis(); if ( hasFound || now >= deadline ) { break; } this.echoMessages.wait( deadline - now ); } } return hasFound; }</code><technical_language>if messages content</technical_language>

Target:
public boolean pingAgent( String applicationName, String rootInstanceName, String message, long timeout ) throws InterruptedException, IOException { final ManagedApplication ma = this.appNameToManagedApplication.get( applicationName ); if (ma == null) { throw new NoSuchElementException( "No application with name: " + applicationName ); } final Application app = ma.getApplication(); Instance instance = null; for (Instance i : app.getRootInstances()) { if (i.getName().equals( rootInstanceName )) { instance = i; break; } } if (instance == null) { throw new NoSuchElementException( "No root instance with name " + rootInstanceName + " in application " + applicationName); } final long deadline = System.currentTimeMillis() + timeout; MsgEcho ping = new MsgEcho( "PING:" + message, deadline ); this.messagingClient.sendMessageToAgent( app, instance, ping ); logger.fine( "Sent PING request message=" + message + "timeout=" + timeout + "ms to application=" + applicationName + ", agent=" + rootInstanceName ); return waitForEchoMessage( ping.getUuid(), deadline ) != null; }