auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public SocketAddress remoteAddress() { SocketAddress address = remoteAddress; if (address == null) { <START> java.net.SocketAddress addr = chctx.channel().attr(REMOTE_ADDRESS_OVERRIDE).getAndSet(null); <END> if (addr == null) addr = chctx.channel().remoteAddress(); if (addr != null) { address = vertx.transport().convert(addr); remoteAddress = address; } } return address; }</code><technical_language>need instead this pattern: java java.net.SocketAddress addr; if (channel.hasAttr(REMOTE_ADDRESS_OVERRIDE)) { Attribute< java.net.SocketAddress> attr = channel.hasAttr(REMOTE_ADDRESS_OVERRIDE); addr = attr.get(); } else { addr = chctx.channel().remoteAddress(); } Calling attr(key) while is set side effect create attribute. Attributes removed</technical_language>

Target:
public SocketAddress remoteAddress() { SocketAddress address = remoteAddress; if (address == null) { if (chctx.channel().hasAttr(REMOTE_ADDRESS_OVERRIDE)) { address = chctx.channel().attr(REMOTE_ADDRESS_OVERRIDE).getAndSet(null); } else { java.net.SocketAddress addr = chctx.channel().remoteAddress(); if (addr != null) { address = vertx.transport().convert(addr); } } if (address != null) remoteAddress = address; } return address; }
Source:
<code>protected List<String> getEnabledProtocols() { <START> return getAttribute(JavaWebAppSoftwareProcessImpl.ENABLED_PROTOCOLS); <END> }</code><technical_language>Return empty list instead of null if attribute set? occur, important</technical_language>

Target:
protected Set<String> getEnabledProtocols() { return getAttribute(JavaWebAppSoftwareProcess.ENABLED_PROTOCOLS); }
Source:
<code>public Mono<CosmosAsyncContainerResponse> replace( CosmosContainerProperties containerProperties, CosmosContainerRequestOptions options) { ModelBridgeInternal.validateResource(containerProperties); if (options == null) { options = new CosmosContainerRequestOptions(); } final CosmosContainerRequestOptions requestOptions = options; return withContext(context -> replace(containerProperties, requestOptions, context)).subscriberContext(reactorContext -> { Optional<String> master = reactorContext.getOrEmpty(TracerProvider.MASTER_CALL); if (master.isPresent()) { reactorContext = reactorContext.put(TracerProvider.NESTED_CALL, true); } <START> return reactorContext.put(TracerProvider.MASTER_CALL, true); <END> }); }</code><technical_language>this code is repeated exactly, this factored out a function passed here? \liked this java return withContext(context -> replace(containerProperties, requestOptions, context)) .subscriberContext(reactorContext -> factoredOutFunc())</technical_language>

Target:
public Mono<CosmosContainerResponse> replace( CosmosContainerProperties containerProperties, CosmosContainerRequestOptions options) { if (options == null) { options = new CosmosContainerRequestOptions(); } if(!database.getClient().getTracerProvider().isEnabled()) { return replaceInternal(containerProperties, options); } final CosmosContainerRequestOptions requestOptions = options; return withContext(context -> replaceInternal(containerProperties, requestOptions, context)); }
Source:
<code>public boolean withinBounds() { if (!baseOffset.withinBounds()) { return false; } if (allWithinThreshold) { return true; } long current = timestamps.getLongSingleValueRow(baseOffset.getOffset()); <START> return current >= timeStart && current < timeEnd; <END> }</code><technical_language>technically need check of conditions based query is descending not, is faster do a check based descending flag, check both, is a benefit do branching of loop, i.e a DescendingTimestampCheckingOffset</technical_language>

Target:
public boolean withinBounds() { if (!baseOffset.withinBounds()) { return false; } if (allWithinThreshold) { return true; } return timeInRange(timestamps.getLongSingleValueRow(baseOffset.getOffset())); }
Source:
<code>public Response recreateToken() { User u; try { u = findUserOrDie(); } catch (WrappedResponse ex) { return ex.getResponse(); } AuthenticatedUser au; try{ au = (AuthenticatedUser) u; } catch (ClassCastException e){ <START> return notFound("Token for " + u.getIdentifier() + " not found."); <END> } if (au == null) { return notFound("Token for " + u.getIdentifier() + " not found."); } authSvc.removeApiToken(au); ApiToken newToken = authSvc.generateApiTokenForUser(au); authSvc.save(newToken); return ok("New token for " + au.getUserIdentifier() + " is " + newToken.getTokenString()); }</code><technical_language>above, this message Guest user API token. PrivateURL user, I guess. thinking nice a slightly message below</technical_language>

Target:
public Response recreateToken() { User u; try { u = findUserOrDie(); } catch (WrappedResponse ex) { return ex.getResponse(); } AuthenticatedUser au; try{ au = (AuthenticatedUser) u; } catch (ClassCastException e){ return notFound("Token for " + u.getIdentifier() + " is not eligible for recreation."); } authSvc.removeApiToken(au); ApiToken newToken = authSvc.generateApiTokenForUser(au); authSvc.save(newToken); return ok("New token for " + au.getUserIdentifier() + " is " + newToken.getTokenString()); }
Source:
<code>public void showAllergens(List<AllergenName> allergens) { if (allergens.isEmpty()) { return; } <START> if (!product.getStatesTags().contains("en:ingredients-completed")) { <END> productAllergenAlert.setText(R.string.product_incomplete_message); productAllergenAlertLayout.setVisibility(View.VISIBLE); return; } Set<String> productAllergens = new HashSet<>(product.getAllergensHierarchy()); productAllergens.addAll(product.getTracesTags()); List<String> allergenMatch = new ArrayList<>(); for (AllergenName allergenName : allergens) { if (productAllergens.contains(allergenName.getAllergenTag())) { allergenMatch.add(allergenName.getName()); } } if (allergenMatch.isEmpty()) { return; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append( String.format("%s\n", getResources().getString(R.string.product_allergen_prompt))); boolean first = true; for (String allergenName : allergenMatch) { String formattedAllergen; if (first) { formattedAllergen = allergenName; } else { formattedAllergen = String.format(", %s", allergenName); } stringBuilder.append(formattedAllergen); first = false; } productAllergenAlert.setText(stringBuilder.toString()); productAllergenAlertLayout.setVisibility(View.VISIBLE); }</code><technical_language>@stephanegigandet is a sound idea ? ask for product complete</technical_language>

Target:
public void showAllergens(List<AllergenName> allergens) { if (allergens.isEmpty()) { return; } if (!product.getStatesTags().contains("en:complete")) { productAllergenAlert.setText(R.string.product_incomplete_message); productAllergenAlertLayout.setVisibility(View.VISIBLE); return; } Set<String> productAllergens = new HashSet<>(product.getAllergensHierarchy()); productAllergens.addAll(product.getTracesTags()); List<String> allergenMatch = new ArrayList<>(); for (AllergenName allergenName : allergens) { if (productAllergens.contains(allergenName.getAllergenTag())) { allergenMatch.add(allergenName.getName()); } } if (allergenMatch.isEmpty()) { return; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append( String.format("%s\n", getResources().getString(R.string.product_allergen_prompt))); boolean first = true; for (String allergenName : allergenMatch) { String formattedAllergen; if (first) { formattedAllergen = allergenName; } else { formattedAllergen = String.format(", %s", allergenName); } stringBuilder.append(formattedAllergen); first = false; } productAllergenAlert.setText(stringBuilder.toString()); productAllergenAlertLayout.setVisibility(View.VISIBLE); }
Source:
<code>private void createGroupIfNecessary(InternalResourceGroup resourceGroup, Executor executor, int version) { <START> synchronized (lockObj) { <END> if (resourceGroup.getVersion() == version) { return; } InternalResourceGroup newGroup; ResourceGroupId resourceGroupId = resourceGroup.getId(); if (resourceGroupId.getParent().isPresent()) { createGroupIfNecessary(groups.get(resourceGroupId.getParent().get()).getLatest(), executor, version); InternalResourceGroup parent = groups.get(resourceGroupId.getParent().get()).getLatest(); newGroup = parent.getOrCreateSubGroup(resourceGroupId.getLastSegment(), version); } else { RootInternalResourceGroup newRootVersion = new RootInternalResourceGroup(resourceGroup.getId().getSegments().get(0), this::exportGroup, executor, resourceGroup.getRoot(), version); newGroup = newRootVersion; } configurationManager.get().configure(newGroup); resourceGroup.setNext(newGroup); newGroup.setPrev(resourceGroup); } }</code><technical_language>a confused need a separate monitor. synchronized this</technical_language>

Target:
private void createGroupIfNecessary(InternalResourceGroup resourceGroup, Executor executor, int version) { synchronized (this) { if (resourceGroup.getVersion() == version) { return; } InternalResourceGroup newGroup; ResourceGroupId resourceGroupId = resourceGroup.getId(); if (resourceGroupId.getParent().isPresent()) { createGroupIfNecessary(groups.get(resourceGroupId.getParent().get()).getLatest(), executor, version); InternalResourceGroup parent = groups.get(resourceGroupId.getParent().get()).getLatest(); newGroup = parent.getOrCreateSubGroup(resourceGroupId.getLastSegment(), resourceGroup.isStaticResourceGroup(), version); } else { newGroup = new RootInternalResourceGroup(resourceGroup.getId().getSegments().get(0), this::exportGroup, executor, resourceGroup.getRoot(), version); } configurationManager.get().configure(newGroup); resourceGroup.setNext(newGroup); newGroup.setPrev(resourceGroup); groups.put(resourceGroupId, newGroup); } }
Source:
<code>public InputStream getAttachmentData(String attachmentId, IProgressMonitor monitor) throws IOException, CoreException { String url = repositoryUrl + IBugzillaConstants.URL_GET_ATTACHMENT_DOWNLOAD + attachmentId; GetMethod method = getConnect(url, monitor); try { if (method.getStatusCode() == HttpStatus.SC_OK) { Header contentDisposition = method.getResponseHeader("Content-disposition"); if (contentDisposition == null) { parseHtmlError(method.getResponseBodyAsStream()); <START> throw new CoreException( <END> new Status( IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, "No Exception from parseHtmlError, should throw an Exception" + method.getResponseBodyAsStream())); } return method.getResponseBodyAsStream(); } else { parseHtmlError(method.getResponseBodyAsStream()); throw new CoreException( new Status( IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, "No Exception from parseHtmlError, should throw an Exception" + method.getResponseBodyAsStream())); } } catch (Exception e) { WebUtil.releaseConnection(method, monitor); throw new CoreException(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, "Unable to retrieve attachment", e)); } }</code><technical_language>Frank, change this "throw new CoreExcpetion(convertHtmlErrorToStatus())" extracted a method out of parseHtmlError returned a status.Then need extra CoreException (which thrown)</technical_language>

Target:
public InputStream getAttachmentData(String attachmentId, IProgressMonitor monitor) throws IOException, CoreException { String url = repositoryUrl + IBugzillaConstants.URL_GET_ATTACHMENT_DOWNLOAD + attachmentId; GetMethod method = getConnect(url, monitor); Status status = null; try { if (method.getStatusCode() == HttpStatus.SC_OK) { Header contentDisposition = method.getResponseHeader("Content-disposition"); if (contentDisposition == null) { status = parseHtmlError(method.getResponseBodyAsStream()); } else { return method.getResponseBodyAsStream(); } } else { status = parseHtmlError(method.getResponseBodyAsStream()); } } catch (Exception e) { status = new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, "Unable to retrieve attachment", e); } finally { WebUtil.releaseConnection(method, monitor); if (status != null) { throw new CoreException(status); } } return null; }
Source:
<code>public static Node getNodeBySystemSession(Node node) throws RepositoryException { <START> node.getSession().save(); <END> SessionProvider systemSessionProvider = getSystemSessionProvider(); return (Node) systemSessionProvider.getSession(node.getSession().getWorkspace().getName(), getRepository()) .getItem(node.getPath()); }</code><technical_language>do need save node get system provider</technical_language>

Target:
public static Node getNodeBySystemSession(Node node) throws RepositoryException { SessionProvider systemSessionProvider = getSystemSessionProvider(); return (Node) systemSessionProvider.getSession(node.getSession().getWorkspace().getName(), getRepository()) .getItem(node.getPath()); }
Source:
<code>public IllegalTableTransitionException(TableState oldState, TableState newState, String message) { this.oldState = oldState; this.newState = newState; <START> String defaultMessage = "Error transitioning from " + oldState + " state to " + newState + " state"; <END> if (message != null && !message.isEmpty()) this.message = message; else this.message = defaultMessage; }</code><technical_language>this moved else block</technical_language>

Target:
public IllegalTableTransitionException(TableState oldState, TableState newState, String message) { this.oldState = oldState; this.newState = newState; if (StringUtils.isNotEmpty(message)) this.message = message; else { String defaultMessage = "Error transitioning from " + oldState + " state to " + newState + " state"; this.message = defaultMessage; } }
Source:
<code>public final String consoleClientResourcesUrl() { String url = getString(DynamicMessageKey.CONSOLE_CLIENT_RESOURCES_URL); <START> boolean isAbsolute = url.contains("://"); END> return isAbsolute ? url : "/" + BaseContextPathData.getInstance().getRelativePath() + url; }</code><technical_language>isAbsolute is determined if a scheme correct? this instead? import com.google.gwt.safehtml.shared.UriUtils; boolean isAbsolute = UriUtils.extractScheme(url) != null;</technical_language>

Target:
public final String consoleClientResourcesUrl() { String url = getString(DynamicMessageKey.CONSOLE_CLIENT_RESOURCES_URL); boolean isAbsolute = UriUtils.extractScheme(url) != null; return isAbsolute ? url : "/" + BaseContextPathData.getInstance().getRelativePath() + url; }
Source:
<code>protected void index() { List<WorkQueueDescriptor> descriptors = getDescriptors(QUEUES_EP); descriptors.forEach(d -> d.categories.forEach(c -> { <START> categoryToQueueId.putIfAbsent(c, d.getId()); <END> categoryToQueueId.computeIfPresent(c, (k, v) -> { if (!v.equals(d.getId())) { getLog().error("Work category '" + c + "' cannot be assigned to work queue '" + d.getId() + "' because it is already assigned to work queue '" + v + "'"); } return v; }); })); }</code><technical_language>inverse lines avoid executing BiFunction time</technical_language>

Target:
protected void index() { List<WorkQueueDescriptor> descriptors = getDescriptors(QUEUES_EP); descriptors.forEach(d -> d.categories.forEach(c -> { categoryToQueueId.computeIfPresent(c, (k, v) -> { if (!v.equals(d.getId())) { getLog().error("Work category '" + c + "' cannot be assigned to work queue '" + d.getId() + "' because it is already assigned to work queue '" + v + "'"); } return v; }); categoryToQueueId.putIfAbsent(c, d.getId()); })); }
Source:
<code>public <V extends Visualization> V getVisualization(String identifier, Class<V> visualizationClass) { Visualization vis = getVisualizationInternal(identifier); if (!visualizationClass.isInstance(vis)) { throw new IllegalArgumentException("Visualization identified by " + identifier + " is not of expected type " + visualizationClass.getName() + " but of type " + vis.getClass().getName()); } <START> return (V) vis; <END> }</code><technical_language>If visualizationClass.cast(vis) need SuppressWarnings annotation</technical_language>

Target:
public <V extends Visualization> V getVisualization(String identifier, Class<V> visualizationClass) { Visualization vis = getVisualizationInternal(identifier); if (!visualizationClass.isInstance(vis)) { throw new IllegalArgumentException("Visualization identified by " + identifier + " is not of expected type " + visualizationClass.getName() + " but of type " + vis.getClass().getName()); } return visualizationClass.cast(vis); }
Source:
<code>private void startBranchComparison(RayMessage msg) { VKmer id = getVertexId(); RayValue vertex = getVertexValue(); if (vertex.visited) { vertex.intersection = true; vertex.stopSearch = true; return; } vertex.visited = true; <START> vertex.flippedFromInitialDirection = msg.isCandidateFlipped(); <END> DIR nextDir = msg.getEdgeTypeBackToFrontier().mirror().neighborDir(); msg.visitNode(id, vertex); if (vertex.degree(nextDir) == 0) { return; } else if (vertex.degree(nextDir) == 1) { NeighborInfo next = vertex.getSingleNeighbor(nextDir); msg.setEdgeTypeBackToFrontier(next.et.mirror()); msg.setFrontierFlipped(vertex.flippedFromInitialDirection); sendMsg(next.kmer, msg); } else { msg.setMessageType(RayMessageType.REQUEST_KMER); msg.setFrontierFlipped(vertex.flippedFromInitialDirection); msg.setSourceVertexId(id); for (EDGETYPE et : nextDir.edgeTypes()) { for (VKmer next : vertex.getEdges(et)) { msg.setEdgeTypeBackToFrontier(et.mirror()); sendMsg(next, msg); } } } }</code><technical_language>isCandidateFlipped()? understanding, candidate receive this CONTINUE_WALK message. Is isWalkNodeFlipped()</technical_language>

Target:
private void startBranchComparison(RayMessage msg) { VKmer id = getVertexId(); RayValue vertex = getVertexValue(); if (vertex.visited) { vertex.intersection = true; vertex.stopSearch = true; LOG.info("start branch comparison had to stop at " + id + " with total length " + msg.getWalkLength()); return; } vertex.visited = true; vertex.flippedFromInitialDirection = msg.isCandidateFlipped(); DIR nextDir = msg.getEdgeTypeBackToFrontier().mirror().neighborDir(); msg.visitNode(id, vertex); if (vertex.degree(nextDir) == 0) { LOG.info("reached dead end at " + id + " with total length " + msg.getWalkLength()); return; } else if (vertex.degree(nextDir) == 1) { NeighborInfo next = vertex.getSingleNeighbor(nextDir); msg.setEdgeTypeBackToFrontier(next.et.mirror()); msg.setFrontierFlipped(vertex.flippedFromInitialDirection); sendMsg(next.kmer, msg); LOG.info("bouncing over path node: " + id); } else { msg.setMessageType(RayMessageType.REQUEST_KMER); msg.setFrontierFlipped(vertex.flippedFromInitialDirection); msg.setSourceVertexId(id); for (EDGETYPE et : nextDir.edgeTypes()) { for (VKmer next : vertex.getEdges(et)) { msg.setEdgeTypeBackToFrontier(et.mirror()); sendMsg(next, msg); LOG.info("evaluating branch: " + next); } } } }
Source:
<code>public SyslogProcessor call() { try { LOG.debug("Converting syslog message into event ({} bytes)", m_bytes.remaining()); try { <START> SyslogdIPMgrJDBCImpl.getInstance().dataSourceSync(); <END> } catch (SQLException e) { LOG.debug("Database Sync failed"); } ConvertToEvent re = new ConvertToEvent( m_systemId, m_sourceAddress, m_port, StandardCharsets.US_ASCII.decode(m_bytes).toString(), m_config ); LOG.debug("Sending syslog event to the SyslogProcessor queue"); return new SyslogProcessor(re.getEvent(), m_config.getNewSuspectOnMessage()); } catch (final UnsupportedEncodingException e) { LOG.info("Failure to convert package", e); } catch (final MessageDiscardedException e) { LOG.info("Message discarded, returning without enqueueing event.", e); } catch (final Throwable e) { LOG.error("Unexpected exception while processing SyslogConnection", e); } return null; }</code><technical_language>This code updated handled a this sync called loading wont called opennms is stopped</technical_language>

Target:
public SyslogProcessor call() { try { LOG.debug("Converting syslog message into event ({} bytes)", m_bytes.remaining()); ConvertToEvent re = new ConvertToEvent( m_systemId, m_location, m_sourceAddress, m_port, StandardCharsets.US_ASCII.decode(m_bytes).toString(), m_config ); LOG.debug("Sending syslog event to the SyslogProcessor queue"); return new SyslogProcessor(re.getEvent(), m_config.getNewSuspectOnMessage()); } catch (final UnsupportedEncodingException e) { LOG.info("Failure to convert package", e); } catch (final MessageDiscardedException e) { LOG.info("Message discarded, returning without enqueueing event.", e); } catch (final Throwable e) { LOG.error("Unexpected exception while processing SyslogConnection", e); } return null; }
Source:
<code>public void onSearch(String query, SuggestionAnimation suggestionAnimation) { storeQuery(query); <START> <END> ((PostSearchFragment) getSupportFragmentManager().findFragmentById(R.id.postsearch)) .setUrl("<LINK_0>" + Uri.encode(query)); if (suggestionAnimation != null) { animateSuggestion(query, suggestionAnimation); } else { startPostsearch(); } }</code><technical_language>I find text animating other cards a bit distracting. do hiding pre-search fragment here? eg: findViewById(R.id.presearch).setVisibility(View.INVISIBLE);</technical_language>

Target:
public void onSearch(String query, SuggestionAnimation suggestionAnimation) { storeQuery(query); ((PostSearchFragment) getSupportFragmentManager().findFragmentById(R.id.postsearch)) .startSearch(query); if (suggestionAnimation != null) { animateSuggestion(query, suggestionAnimation); } else { startPostsearch(); } }
Source:
<code>public HttpClient get() { final DruidHttpClientConfig config = getConfigProvider().get().get(); final HttpClientConfig.Builder builder = HttpClientConfig .builder() .withNumConnections(config.getNumConnections()) .withReadTimeout(config.getReadTimeout()) .withWorkerCount(config.getNumMaxThreads()) .withCompressionCodec( HttpClientConfig.CompressionCodec.valueOf(StringUtils.toUpperCase(config.getCompressionCodec())) ) <START> .withUnusedConnectionTimeoutDuration(config.getUnusedConnectionTimeout().toStandardDuration()); <END> if (getSslContextBinding() != null) { builder.withSslContext(getSslContextBinding().getProvider().get()); } HttpClient client = HttpClientInit.createClient( builder.build(), LifecycleUtils.asMmxLifecycle(getLifecycleProvider().get()) ); if (isEscalated) { return escalator.createEscalatedClient(client); } else { return client; } }</code><technical_language>print a warning log if unusedConnectionTime >= readTimeout ? ideally, fail process startup in case incompatible fail process startup for users set readTimeout smaller values</technical_language>

Target:
public HttpClient get() { final DruidHttpClientConfig config = getConfigProvider().get().get(); final HttpClientConfig.Builder builder = HttpClientConfig .builder() .withNumConnections(config.getNumConnections()) .withReadTimeout(config.getReadTimeout()) .withWorkerCount(config.getNumMaxThreads()) .withCompressionCodec( HttpClientConfig.CompressionCodec.valueOf(StringUtils.toUpperCase(config.getCompressionCodec())) ) .withUnusedConnectionTimeoutDuration(config.getUnusedConnectionTimeout()); if (getSslContextBinding() != null) { builder.withSslContext(getSslContextBinding().getProvider().get()); } HttpClient client = HttpClientInit.createClient( builder.build(), LifecycleUtils.asMmxLifecycle(getLifecycleProvider().get()) ); if (isEscalated) { return escalator.createEscalatedClient(client); } else { return client; } }
Source:
<code>public Manager() { super(); this.templateManager = new ApplicationTemplateMngrDelegate(); this.appManager = new ApplicationMngrDelegate(); this.instanceManager = new InstanceMngrDelegate( this ); <START> this.messagingType = MessagingConstants.FACTORY_RABBIT_MQ; <END> }</code><technical_language>for agent: default value</technical_language>

Target:
public Manager() { super(); this.templateManager = new ApplicationTemplateMngrDelegate(); this.appManager = new ApplicationMngrDelegate(); this.instanceManager = new InstanceMngrDelegate( this ); }
Source:
<code>public void detach() { if (getWindow() != null) { return; } ConfirmationModel model = new ConfirmationModel(); setWindow(model); model.setTitle(ConstantsManager.getInstance().getConstants().detachStorageTitle()); model.setHelpTag(HelpTag.detach_storage); model.setHashName("detach_storage"); model.setMessage(ConstantsManager.getInstance().getConstants().areYouSureYouWantDetachFollowingStoragesMsg()); ArrayList<String> list = new ArrayList<String>(); boolean shouldAddressWarnning = false; for (StorageDomain item : Linq.<StorageDomain> cast(getSelectedItems())) { list.add(item.getStorageName()); if (item.getStorageDomainType() == StorageDomainType.Data || <START> item.getStorageDomainType() == StorageDomainType.Master) { <END> shouldAddressWarnning = true; } } model.setItems(list); if (containsLocalStorage(model)) { model.getLatch().setIsAvailable(true); model.getLatch().setIsChangable(true); model.setNote(ConstantsManager.getInstance().getMessages().detachNote(getLocalStoragesFormattedString())); } if (shouldAddressWarnning) { model.setNote(ConstantsManager.getInstance().getConstants().detachWarnningNote()); } UICommand tempVar = new UICommand("OnDetach", this); tempVar.setTitle(ConstantsManager.getInstance().getConstants().ok()); tempVar.setIsDefault(true); model.getCommands().add(tempVar); UICommand tempVar2 = new UICommand("Cancel", this); tempVar2.setTitle(ConstantsManager.getInstance().getConstants().cancel()); tempVar2.setIsCancel(true); model.getCommands().add(tempVar2); }</code><technical_language>please item.getStorageDomainType().isDataDomain()</technical_language>

Target:
public void detach() { if (getWindow() != null) { return; } ConfirmationModel model = new ConfirmationModel(); setWindow(model); model.setTitle(ConstantsManager.getInstance().getConstants().detachStorageTitle()); model.setHelpTag(HelpTag.detach_storage); model.setHashName("detach_storage"); model.setMessage(ConstantsManager.getInstance().getConstants().areYouSureYouWantDetachFollowingStoragesMsg()); ArrayList<String> list = new ArrayList<String>(); boolean shouldAddressWarnning = false; for (StorageDomain item : Linq.<StorageDomain> cast(getSelectedItems())) { list.add(item.getStorageName()); if (item.getStorageDomainType().isDataDomain()) { shouldAddressWarnning = true; break; } } model.setItems(list); if (containsLocalStorage(model)) { shouldAddressWarnning = false; model.getLatch().setIsAvailable(true); model.getLatch().setIsChangable(true); model.setNote(ConstantsManager.getInstance().getMessages().detachNote(getLocalStoragesFormattedString())); } if (shouldAddressWarnning) { model.setNote(ConstantsManager.getInstance().getConstants().detachWarnningNote()); } UICommand tempVar = new UICommand("OnDetach", this); tempVar.setTitle(ConstantsManager.getInstance().getConstants().ok()); tempVar.setIsDefault(true); model.getCommands().add(tempVar); UICommand tempVar2 = new UICommand("Cancel", this); tempVar2.setTitle(ConstantsManager.getInstance().getConstants().cancel()); tempVar2.setIsCancel(true); model.getCommands().add(tempVar2); }
Source:
<code>private static SqlScalarFunction castFunctionFromDecimalTo(TypeSignature to, String... methodNames) { Signature signature = Signature.builder() .kind(SCALAR) .operatorType(CAST) .argumentTypes(parseTypeSignature("decimal(precision,scale)", ImmutableSet.of("precision", "scale"))) .returnType(to) .build(); return SqlScalarFunction.builder(DecimalCasts.class) .signature(signature) .deterministic(true) <START> .choice(c -> c <END> .implementation(b -> b .methods(methodNames) .withExtraParameters((context) -> { long precision = context.getLiteral("precision"); long scale = context.getLiteral("scale"); Number tenToScale; if (isShortDecimal(context.getParameterTypes().get(0))) { tenToScale = longTenToNth(intScale(scale)); } else { tenToScale = bigIntegerTenToNth(intScale(scale)); } return ImmutableList.of(precision, scale, tenToScale); }))) .build(); }</code><technical_language>nit: choice -> choice</technical_language>

Target:
private static SqlScalarFunction castFunctionFromDecimalTo(TypeSignature to, String... methodNames) { Signature signature = Signature.builder() .kind(SCALAR) .operatorType(CAST) .argumentTypes(parseTypeSignature("decimal(precision,scale)", ImmutableSet.of("precision", "scale"))) .returnType(to) .build(); return SqlScalarFunction.builder(DecimalCasts.class) .signature(signature) .deterministic(true) .choice(choice -> choice .implementation(methodsGroup -> methodsGroup .methods(methodNames) .withExtraParameters((context) -> { long precision = context.getLiteral("precision"); long scale = context.getLiteral("scale"); Number tenToScale; if (isShortDecimal(context.getParameterTypes().get(0))) { tenToScale = longTenToNth(intScale(scale)); } else { tenToScale = bigIntegerTenToNth(intScale(scale)); } return ImmutableList.of(precision, scale, tenToScale); }))) .build(); }
Source:
<code>public void resourceChanged(IResourceChangeEvent event) { if (event.getDelta() == null) { return; } try { final Set<IProject> modifiedProjects = new HashSet<>(); <START> event.getDelta().accept(new IResourceDeltaVisitor() { <END> @Override public boolean visit(IResourceDelta delta) { if (delta.getResource() != null && delta.getResource().getType() == IResource.PROJECT && (delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.CHANGED)) { modifiedProjects.add((IProject) delta.getResource()); } return delta.getResource() == null || delta.getResource().getType() == IResource.ROOT; } }); updateMarkers(modifiedProjects); } catch (CoreException e) { ResourcesPlugin.getPlugin().getLog().log(new Status(IStatus.ERROR, ResourcesPlugin.getPlugin().getBundle().getSymbolicName(), e.getMessage(), e)); } }</code><technical_language>I new code lambdas possible</technical_language>

Target:
public void resourceChanged(IResourceChangeEvent event) { if (event.getDelta() == null) { return; } try { final Set<IProject> modifiedProjects = new HashSet<>(); event.getDelta().accept(delta -> { if (delta.getResource() != null && delta.getResource().getType() == IResource.PROJECT && (delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.CHANGED)) { modifiedProjects.add((IProject) delta.getResource()); } return delta.getResource() == null || delta.getResource().getType() == IResource.ROOT; }); updateMarkers(modifiedProjects); } catch (CoreException e) { ResourcesPlugin.getPlugin().getLog().log(new Status(IStatus.ERROR, ResourcesPlugin.getPlugin().getBundle().getSymbolicName(), e.getMessage(), e)); } }
Source:
<code>public Query.QueryBuilder visitQueryable(Queryable plan) { <START> if (invoked == false) { <END> invoked = true; if (plan.isNested()) { return visitOuterQueryPlan(plan); } else { return visitUnnestedQueryPlan(plan); } } else { if (plan.isNested()) { return visitMiddleQueryPlan(plan); } else { return visitInnerQueryPlan(plan); } } }</code><technical_language>This written if (!invoked)</technical_language>

Target:
public Query.QueryBuilder visitQueryable(Queryable plan) { if (! invoked) { invoked = true; if (plan.isNested()) { return visitOuterQueryPlan(plan); } else { return visitUnnestedQueryPlan(plan); } } else { if (plan.isNested()) { return visitMiddleQueryPlan(plan); } else { return visitInnerQueryPlan(plan); } } }
Source:
<code>public WebSocketClientProtocolHandler(WebSocketClientHandshaker handshaker, boolean handleCloseFrames, boolean dropPongFrames, long handshakeTimeoutMillis) { super(dropPongFrames); this.handshaker = handshaker; this.handleCloseFrames = handleCloseFrames; <START> this.handshakeTimeoutMillis = handshakeTimeoutMillis; <END> }</code><technical_language>check positive</technical_language>

Target:
public WebSocketClientProtocolHandler(WebSocketClientHandshaker handshaker, boolean handleCloseFrames, boolean dropPongFrames, long handshakeTimeoutMillis) { super(dropPongFrames); this.handshaker = handshaker; this.handleCloseFrames = handleCloseFrames; this.handshakeTimeoutMillis = checkPositive(handshakeTimeoutMillis, "handshakeTimeoutMillis"); }
Source:
<code>public Catalog getCatalog(String catalogName) throws NoSuchObjectException, MetaException { if (!sharedCache.isCatalogCachePrewarmed()) { return rawStore.getCatalog(catalogName); } <START> catalogName = catalogName.toLowerCase(); <END> Catalog cat = sharedCache.getCatalogFromCache(catalogName); if (cat == null) { throw new NoSuchObjectException(); } return cat; }</code><technical_language>StringUtils.normalizeIdentifier instead of lowerCase ? (that lowercase well)</technical_language>

Target:
public Catalog getCatalog(String catalogName) throws NoSuchObjectException, MetaException { if (!sharedCache.isCatalogCachePrewarmed()) { return rawStore.getCatalog(catalogName); } Catalog cat = sharedCache.getCatalogFromCache(normalizeIdentifier(catalogName)); if (cat == null) { throw new NoSuchObjectException(); } return cat; }
Source:
<code>public CommandStatus runTimed(long timeout, IRunUtil.IRunnableResult runnable, boolean logErrors) { mInterrupter.checkInterrupted(); RunnableNotifier runThread = new RunnableNotifier(runnable, logErrors); if (logErrors) { if (timeout > 0l) { CLog.d("Running command with timeout: %dms", timeout); } else { CLog.d("Running command without timeout."); } } try { runThread.start(); long startTime = System.currentTimeMillis(); long pollInterval = 0; if (timeout > 0L && timeout < THREAD_JOIN_POLL_INTERVAL) { pollInterval = timeout; } else { pollInterval = THREAD_JOIN_POLL_INTERVAL; } do { try { runThread.join(pollInterval); } catch (InterruptedException e) { if (isInterruptAllowed()) { CLog.i("runTimed: interrupted while joining the runnable"); break; } else { CLog.i("runTimed: currently uninterruptible, ignoring interrupt"); } } mInterrupter.checkInterrupted(); } while ((timeout == 0L || (System.currentTimeMillis() - startTime) < timeout) && runThread.isAlive()); CommandStatus status = runThread.getStatus(); if (CommandStatus.TIMED_OUT.equals(status) || CommandStatus.EXCEPTION.equals(status)) { CLog.i("runTimed: Calling interrupt, status is %s", status); runThread.cancel(); } mInterrupter.checkInterrupted(); return status; } <START> catch (RunInterruptedException e) { <END> runThread.cancel(); throw e; } }</code><technical_language>I thinking call cancel in a finally{} matter what? instead of timeout, exception. if a pass, hurt is cancelled, no? avoid catching/throwing some RuntimeException</technical_language>

Target:
public CommandStatus runTimed(long timeout, IRunUtil.IRunnableResult runnable, boolean logErrors) { mInterrupter.checkInterrupted(); RunnableNotifier runThread = new RunnableNotifier(runnable, logErrors); if (logErrors) { if (timeout > 0l) { CLog.d("Running command with timeout: %dms", timeout); } else { CLog.d("Running command without timeout."); } } try { runThread.start(); long startTime = System.currentTimeMillis(); long pollInterval = 0; if (timeout > 0L && timeout < THREAD_JOIN_POLL_INTERVAL) { pollInterval = timeout; } else { pollInterval = THREAD_JOIN_POLL_INTERVAL; } do { try { runThread.join(pollInterval); } catch (InterruptedException e) { if (isInterruptAllowed()) { CLog.i("runTimed: interrupted while joining the runnable"); break; } else { CLog.i("runTimed: currently uninterruptible, ignoring interrupt"); } } mInterrupter.checkInterrupted(); } while ((timeout == 0L || (System.currentTimeMillis() - startTime) < timeout) && runThread.isAlive()); CommandStatus status = runThread.getStatus(); if (CommandStatus.TIMED_OUT.equals(status) || CommandStatus.EXCEPTION.equals(status)) { CLog.i("runTimed: Calling interrupt, status is %s", status); runThread.cancel(); } mInterrupter.checkInterrupted(); return status; } finally { runThread.cancel(); } }
Source:
<code>public MojioWebSocket(String baseUrl, Authenticator authenticator) { factory = new WebSocketFactory(); listenerWebSocketMap = new HashMap<>(); this.baseUrl = baseUrl; this.authenticator = authenticator; <START> setAccessToken(); <END> }</code><technical_language>I this. This starts a new thread retrieve access token. do token retrieval right connect time. If need spin a background thread (which do) do complete connection stuff in a callback ensure done in proper order</technical_language>

Target:
public MojioWebSocket(String baseUrl, Authenticator authenticator) { factory = new WebSocketFactory(); listenerWebSocketMap = new HashMap<>(); this.baseUrl = baseUrl; this.authenticator = authenticator; }
Source:
<code>public DispatchRequest undo(LogInAction action, LogInResult result, AsyncCallback<Void> callback, UndoCommand<LogInAction, LogInResult> undoCommand) { undoCommand.undo(action, result, callback); <START> return new CompletedDispatchRequest(); <END> }</code><technical_language>return undoCommand.undo(action, result, callback);</technical_language>

Target:
public DispatchRequest undo(LogInAction action, LogInResult result, AsyncCallback<Void> callback, UndoCommand<LogInAction, LogInResult> undoCommand) { return undoCommand.undo(action, result, callback); }
Source:
<code>public boolean canHandle(ActionContext context) { return false; <START> } <END></code><technical_language>This a funny (not clear usage of canHandle be, results be) - explain rationale for this change</technical_language>

Target:
public boolean canHandle(ActionContext context) { return !context.getSelectedManifestations().isEmpty(); }
Source:
<code>private Collection<View> getViewsToUpdate(Diagram gmdDiagram) { Collection<View> viewsToUpdate = Sets.newLinkedHashSet(); TreeIterator<EObject> childIterator = gmdDiagram.eAllContents(); EReference elementReference = NotationPackage.eINSTANCE.getView_Element(); while (childIterator.hasNext()) { EObject child = childIterator.next(); if (child instanceof View && !child.eIsSet(elementReference)) { <START> boolean childIsANoteOrAText = child instanceof Shape && ("Note".equals(((Shape) child).getType()) || "Text".equals(((Shape) child).getType())); <END> boolean childIsANoteAttachement = child instanceof Connector && "NoteAttachment".equals(((Connector) child).getType()); boolean childIsADecorationNode = child instanceof BasicDecorationNode; if (childIsANoteOrAText || childIsANoteAttachement || childIsADecorationNode) { viewsToUpdate.add((View) child); } } } return viewsToUpdate; }</code><technical_language>org.eclipse.gmf.runtime.diagram.core.util.ViewType.{NOTE,TEXT,NOTE_ATTACHMENT} instead of hard-coding strings. expect change in future versions of GMF (as pour is names version migrate from)</technical_language>

Target:
private Collection<View> getViewsToUpdate(Diagram gmdDiagram) { Collection<View> viewsToUpdate = Sets.newLinkedHashSet(); TreeIterator<EObject> childIterator = gmdDiagram.eAllContents(); EReference elementReference = NotationPackage.eINSTANCE.getView_Element(); while (childIterator.hasNext()) { EObject child = childIterator.next(); if (child instanceof View && !child.eIsSet(elementReference)) { boolean childIsANoteOrAText = child instanceof Shape && (ViewType.NOTE.equals(((Shape) child).getType()) || ViewType.TEXT.equals(((Shape) child).getType())); boolean childIsANoteAttachement = child instanceof Connector && ViewType.NOTEATTACHMENT.equals(((Connector) child).getType()); boolean childIsADecorationNode = child instanceof BasicDecorationNode; if (childIsANoteOrAText || childIsANoteAttachement || childIsADecorationNode) { viewsToUpdate.add((View) child); } } } return viewsToUpdate; }
Source:
<code>public void testCpuLoad() { SystemInfo si = new SystemInfo(); HardwareAbstractionLayer hal = si.getHardware(); <START> System.out.println(hal.getProcessorLoad()); <END> }</code><technical_language>This a test, prints out. want is checks output is a non-zero % number for example</technical_language>

Target:
public void testCpuLoad() { SystemInfo si = new SystemInfo(); HardwareAbstractionLayer hal = si.getHardware(); assertTrue(hal.getProcessors()[0].getLoad() >= 0 && hal.getProcessors()[0].getLoad() <= 100); }
Source:
<code>public void accumulate(final VariantContext vc) { if (sample == null){ final List<String> samples = vc.getSampleNamesOrderedByName(); <START> if (samples == null || samples.size() != 1){ <END> throw new IllegalArgumentException("Expected to have exactly 1 sample in a GVCF, found " + ((samples == null) ? "NULL" : samples.size())); } sample = samples.get(0); } VariantContext subContext = vc.subContextFromSample(sample); super.accumulate(subContext); }</code><technical_language>Need a space (</technical_language>

Target:
public void accumulate(final VariantContext vc) { final VariantContext subContext = vc.subContextFromSample(sample); super.accumulate(subContext); }
Source:
<code>public boolean equals(@Nullable Object object) { if (!(object instanceof DoubleStateValue)) { return false; } DoubleStateValue other = (DoubleStateValue) object; <START> return this.unboxDouble() == other.unboxDouble(); <END> }</code><technical_language>comparing doubles directly, hit rounding problems of floating points precision (1.000 + 1.000 = 1.999999 etc.) cases users do mathematical operations values, want compare other (the state system mipmap feature mind). in scope of this patch (the previous implementation a straight .equals() anyway) worth keeping in mind</technical_language>

Target:
public boolean equals(@Nullable Object object) { if (!(object instanceof DoubleStateValue)) { return false; } DoubleStateValue other = (DoubleStateValue) object; return Double.compare(this.value, other.value) == 0; }
Source:
<code>public String toString() { <START> return String.format("%s, skipMgmtNetwork=%s", super.toString(), Boolean.valueOf(skipMgmtNetwork())); <END> }</code><technical_language>I Boolean.valueOf() is redundant a primitive field, agree</technical_language>

Target:
public String toString() { return String.format("%s, skipMgmtNetwork=%s", super.toString(), isManagementNetworkSkipped()); }
Source:
<code><START> public URLMapInfo processURLMap(final UrlMapContext context) <END> throws DotSecurityException, DotDataException { if (this.shouldLoadPatterns()) { this.loadPatterns(); } if (containsRegEx(context.getUri())) { final Matches matches = this.findPatternChange(context.getUri()); final Structure structure = CacheLocator.getContentTypeCache() .getStructureByInode(matches.getPatternChange().getStructureInode()); final Field hostField = this.findHostField(structure); final Contentlet contentlet = this.getContentlet(matches, structure, hostField, context); if (contentlet == null) { return null; } final Identifier pageUriIdentifier = this.getDetailtPageUri(structure); return new URLMapInfo(contentlet, pageUriIdentifier); } else { return null; } }</code><technical_language>returning optional URLMapInfo more fashioned</technical_language>

Target:
public Optional<URLMapInfo> processURLMap(final UrlMapContext context) throws DotSecurityException, DotDataException { if (this.shouldLoadPatterns()) { this.loadPatterns(); } if (containsRegEx(context.getUri())) { final Matches matches = this.findPatternChange(context.getUri()); final Structure structure = CacheLocator.getContentTypeCache() .getStructureByInode(matches.getPatternChange().getStructureInode()); final Field hostField = this.findHostField(structure); final Contentlet contentlet = this.getContentlet(matches, structure, hostField, context); if (contentlet == null) { return Optional.empty(); } final Identifier pageUriIdentifier = this.getDetailtPageUri(structure); return Optional.of(new URLMapInfo(contentlet, pageUriIdentifier)); } else { return Optional.empty(); } }
Source:
<code>protected int run() throws Exception { boolean errorOccurred = false; final Jenkins jenkins = Jenkins.getActiveInstance(); final HashSet<String> hs = new HashSet<String>(); hs.addAll(nodes); List<String> names = null; for (String node_s : hs) { Computer computer = null; try { computer = jenkins.getComputer(node_s); if (computer == null) { if (names == null) { <START> names = new ArrayList<String>(); <END> for (Computer c : jenkins.getComputers()) { if (!c.getName().isEmpty()) { names.add(c.getName()); } } } String adv = EditDistance.findNearest(node_s, names); throw new IllegalArgumentException(adv == null ? hudson.model.Messages.Computer_NoSuchSlaveExistsWithoutAdvice(node_s) : hudson.model.Messages.Computer_NoSuchSlaveExists(node_s, adv)); } computer.cliOnline(); } catch (Exception e) { if (hs.size() == 1) { throw e; } final String errorMsg = String.format(node_s + ": " + e.getMessage()); stderr.println(errorMsg); errorOccurred = true; continue; } } if (errorOccurred){ throw new AbortException("Error occured while performing this command, see previous stderr output."); } return 0; }</code><technical_language>sense initialize declaration. simplify code</technical_language>

Target:
protected int run() throws Exception { boolean errorOccurred = false; final Jenkins jenkins = Jenkins.getActiveInstance(); final HashSet<String> hs = new HashSet<String>(nodes); List<String> names = null; for (String node_s : hs) { Computer computer = null; try { computer = jenkins.getComputer(node_s); if (computer == null) { if (names == null) { names = new ArrayList<String>(); for (Computer c : jenkins.getComputers()) { if (!c.getName().isEmpty()) { names.add(c.getName()); } } } String adv = EditDistance.findNearest(node_s, names); throw new IllegalArgumentException(adv == null ? hudson.model.Messages.Computer_NoSuchSlaveExistsWithoutAdvice(node_s) : hudson.model.Messages.Computer_NoSuchSlaveExists(node_s, adv)); } computer.cliOnline(); } catch (Exception e) { if (hs.size() == 1) { throw e; } final String errorMsg = node_s + ": " + e.getMessage(); stderr.println(errorMsg); errorOccurred = true; continue; } } if (errorOccurred){ throw new AbortException("Error occured while performing this command, see previous stderr output."); } return 0; }
Source:
<code>private Option[] configureSolr() { return options( editConfigurationFilePut(SYSTEM_PROPERTIES_REL_PATH, "solr.client", "HttpSolrClient"), editConfigurationFilePut( SYSTEM_PROPERTIES_REL_PATH, "solr.http.url", "http://localhost:9994/solr"), editConfigurationFilePut( SYSTEM_PROPERTIES_REL_PATH, "solr.data.dir", <START> new File("target/solr/server/solr").getAbsolutePath()), <END> editConfigurationFilePut(SYSTEM_PROPERTIES_REL_PATH, "solr.cloud.zookeeper", "")); }</code><technical_language>hardcoding a port instead of dynamically allocating one? this prevent running multiple itests in parallel</technical_language>

Target:
private Option[] configureSolr() { return options( editConfigurationFilePut(SYSTEM_PROPERTIES_REL_PATH, "solr.client", "HttpSolrClient"), editConfigurationFilePut( SYSTEM_PROPERTIES_REL_PATH, "solr.http.url", "http://localhost:9994/solr"), editConfigurationFilePut(SYSTEM_PROPERTIES_REL_PATH, "solr.http.port", "9994"), editConfigurationFilePut( SYSTEM_PROPERTIES_REL_PATH, "solr.data.dir", new File("target/solr/server/solr").getAbsolutePath()), editConfigurationFilePut(SYSTEM_PROPERTIES_REL_PATH, "solr.cloud.zookeeper", "")); }
Source:
<code>public void setup() throws IOException { Leader leader = mock(Leader.class); when(leader.getQuorumAuthServer()).thenReturn(null); Socket socket = mock(Socket.class); when(socket.getRemoteSocketAddress()).thenReturn(new InetSocketAddress(32)); BinaryOutputArchive oa = mock(BinaryOutputArchive.class); doAnswer(invocationOnMock -> {Thread.sleep(5); return null;}) .when(oa).writeRecord(any(QuorumPacket.class), Matchers.anyString()); BufferedOutputStream bos = mock(BufferedOutputStream.class); <START> doAnswer(invocationOnMock -> {allSentLatch.countDown(); return null;}).when(bos).flush(); <END> learnerHandler = new MockLearnerHandler(socket, leader); learnerHandler.setOutputArchive(oa); learnerHandler.setBufferedOutput(bos); learnerHandler.sid = sid; }</code><technical_language>allSentLatch needs initialized in setup, if other test case in this class, initialize this latch, throw NPE. if test in testMetrics method, general, for other tests, move testMetrics instead of setup</technical_language>

Target:
public void setup() throws IOException { Leader leader = mock(Leader.class); when(leader.getQuorumAuthServer()).thenReturn(null); Socket socket = mock(Socket.class); when(socket.getRemoteSocketAddress()).thenReturn(new InetSocketAddress(32)); BinaryOutputArchive oa = mock(BinaryOutputArchive.class); doAnswer(invocationOnMock -> {Thread.sleep(5); return null;}) .when(oa).writeRecord(any(QuorumPacket.class), anyString()); BufferedOutputStream bos = mock(BufferedOutputStream.class); doAnswer(invocationOnMock -> { if (allSentLatch != null) { allSentLatch.countDown(); } return null; }).when(bos).flush(); learnerHandler = new MockLearnerHandler(socket, leader); learnerHandler.setOutputArchive(oa); learnerHandler.setBufferedOutput(bos); learnerHandler.sid = sid; }