auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Map<String, Product> getProducts(IOperationMonitor monitor) throws BugzillaRestException { return getContainer(client, monitor, "/product?type=accessible", new Function<ProductResponse, Product[]>() { public Product[] apply(ProductResponse input) { return input.getProducts(); } <START> }, new Function<Product, String>() { <END> public String apply(Product input) { return input.getName(); }; }, new TypeToken<ProductResponse>() { }); }</code><technical_language>Instead of duplicating this, Product Field implement interface declares getName method need define function once, in getContainer method</technical_language>

Target:
public Map<String, Product> getProducts(IOperationMonitor monitor) throws BugzillaRestException { return retrieveItems(monitor, "/product?type=accessible", new Function<ProductResponse, Product[]>() { public Product[] apply(ProductResponse input) { return input.getProducts(); } }, new TypeToken<ProductResponse>() { }); }
Source:
<code>public void visit(NodeTraversal t, Node n, Node parent) { Node maybeCallNode = n.getFirstChild(); if (maybeCallNode == null || maybeCallNode.getToken() != Token.CALL) { return; } String callName = maybeCallNode.getFirstChild().getQualifiedName(); if (!"goog.scope".equals(callName)) { return; } Node blockOfScopeContents = n.getLastChild().getLastChild().getLastChild(); blockOfScopeContents.detachFromParent(); List<Node> scopeChildren = new ArrayList<>(); @Nullable Node maybeChildToAdd = blockOfScopeContents.getFirstChild(); while (maybeChildToAdd != null) { <START> scopeChildren.add(maybeChildToAdd); <END> maybeChildToAdd = maybeChildToAdd.getNext(); } Node insertAfterThisNode = n; for (Node scopeChild : scopeChildren) { scopeChild.detachFromParent(); n.getParent().addChildAfter(scopeChild, insertAfterThisNode); insertAfterThisNode = scopeChild; } n.detachFromParent(); compiler.reportCodeChange(); }</code><technical_language>optional: I collapse loops, child (both in while condition body), removing child appending insertion point</technical_language>

Target:
public void visit(NodeTraversal t, Node n, Node parent) { Node maybeCallNode = n.getFirstChild(); if (maybeCallNode == null || maybeCallNode.getToken() != Token.CALL) { return; } String callName = maybeCallNode.getFirstChild().getQualifiedName(); if (!"goog.scope".equals(callName)) { return; } Node blockOfScopeContents = n.getLastChild().getLastChild().getLastChild(); blockOfScopeContents.detachFromParent(); Node insertAfterThisNode = n; @Nullable Node nodeToMove = blockOfScopeContents.getFirstChild(); while (nodeToMove != null) { Node nextNodeToMove = nodeToMove.getNext(); nodeToMove.detachFromParent(); n.getParent().addChildAfter(nodeToMove, insertAfterThisNode); insertAfterThisNode = nodeToMove; nodeToMove = nextNodeToMove; } n.detachFromParent(); compiler.reportCodeChange(); }
Source:
<code>public final Object processMessageGroup(MessageGroup group) { Assert.notNull(group, "MessageGroup must not be null"); Map<String, Object> headers = this.aggregateHeaders(group); Object payload = this.aggregatePayloads(group, headers); AbstractIntegrationMessageBuilder<?> builder; <START> MessageBuilderFactory messageBuilderFactory = getMessageBuilderFactory(); <END> if (payload instanceof Message<?>) { builder = messageBuilderFactory.fromMessage((Message<?>) payload).copyHeadersIfAbsent(headers); } else { builder = messageBuilderFactory.withPayload(payload).copyHeadersIfAbsent(headers); } return builder.popSequenceDetails().build(); }</code><technical_language>need store in a local variable here; branch of if</technical_language>

Target:
public final Object processMessageGroup(MessageGroup group) { Assert.notNull(group, "MessageGroup must not be null"); Map<String, Object> headers = this.aggregateHeaders(group); Object payload = this.aggregatePayloads(group, headers); AbstractIntegrationMessageBuilder<?> builder; if (payload instanceof Message<?>) { builder = getMessageBuilderFactory().fromMessage((Message<?>) payload).copyHeadersIfAbsent(headers); } else { builder = getMessageBuilderFactory().withPayload(payload).copyHeadersIfAbsent(headers); } return builder.popSequenceDetails().build(); }
Source:
<code>private void printElement(final PrintWriter stdout, TreeNode node, int level, boolean isLast, final TreeNode lastParentNode) { if (node.getProject() != null) { if (!currentTabSeparator.equals(" ")) { final String nodeProject = node.getProject().getName(); final String lastParentProject = lastParentNode.getProject().getName(); if (nodeProject.equals(lastParentProject)) { currentTabSeparator = " "; } } if (level > 0) { stdout.print(String.format("%-" + 4 * level + "s", currentTabSeparator)); } final String prefix = isLast ? LAST_NODE_PREFIX : NODE_PREFIX ; String printout; if (node.isVisible()) { printout = prefix + node.getProject().getName(); } else { printout = prefix + NOT_VISIBLE_PROJECT; } <START> stdout.println(printout); <END> stdout.flush(); } if (node.isLeaf()) { return; } else { final List<TreeNode> children = node.getChildren(); ++level; for(TreeNode treeNode : children) { final boolean isLastIndex = children.indexOf(treeNode) == children.size() - 1; printElement(stdout, treeNode, level, isLastIndex, lastParentNode); } } }</code><technical_language>try avoid println() instead print(str + "\n"). LF a line separator if server is running Windows</technical_language>

Target:
private void printElement(final PrintWriter stdout, TreeNode node, int level, boolean isLast, final TreeNode lastParentNode) { if (node.getProject() != null) { if (!currentTabSeparator.equals(" ")) { final String nodeProject = node.getProject().getName(); final String lastParentProject = lastParentNode.getProject().getName(); if (nodeProject.equals(lastParentProject)) { currentTabSeparator = " "; } } if (level > 0) { stdout.print(String.format("%-" + 4 * level + "s", currentTabSeparator)); } final String prefix = isLast ? LAST_NODE_PREFIX : NODE_PREFIX ; String printout; if (node.isVisible()) { printout = prefix + node.getProject().getName(); } else { printout = prefix + NOT_VISIBLE_PROJECT; } stdout.print(printout + "\n"); } if (node.isLeaf()) { return; } else { final List<TreeNode> children = node.getChildren(); ++level; for(TreeNode treeNode : children) { final boolean isLastIndex = children.indexOf(treeNode) == children.size() - 1; printElement(stdout, treeNode, level, isLastIndex, lastParentNode); } } }
Source:
<code>public Image apply(VirtualGuest from) { checkNotNull(from, "from"); ImageBuilder builder = new ImageBuilder().ids(from.getId() + "") .name(from.getHostname()) .status(Image.Status.AVAILABLE); <START> if(from.getOperatingSystem() == null) { <END> return builder.operatingSystem( OperatingSystem.builder().description("UNRECOGNIZED").build()) .build(); } SoftwareLicense softwareLicense = from.getOperatingSystem().getSoftwareLicense(); String referenceCode = softwareLicense.getSoftwareDescription().getReferenceCode(); OsFamily osFamily = osFamily().apply(referenceCode); if (osFamily == OsFamily.UNRECOGNIZED) { logger.debug("Cannot determine os family for item: %s", from); } Integer bits = OperatingSystems.bits().apply(referenceCode); if (bits == null) { logger.debug("Cannot determine os bits for item: %s", from); } String osVersion = OperatingSystems.version().apply(softwareLicense.getSoftwareDescription().getVersion()); if (osVersion == null) { logger.debug("Cannot determine os version for item: %s", from); } OperatingSystem os = OperatingSystem.builder() .description(softwareLicense.getSoftwareDescription().getLongDescription()) .family(osFamily) .version(osVersion) .is64Bit(Objects.equal(bits, 64)) .build(); return builder.operatingSystem(os).build(); }</code><technical_language>[minor] space if</technical_language>

Target:
public Image apply(VirtualGuest from) { checkNotNull(from, "from"); if (from.getOperatingSystem() == null) { return new ImageBuilder().ids(from.getId() + "") .name(from.getHostname()) .status(Image.Status.UNRECOGNIZED) .operatingSystem(OperatingSystem.builder() .family(OsFamily.UNRECOGNIZED) .version(UNRECOGNIZED) .description(UNRECOGNIZED) .build()) .build(); } else { return operatingSystemToImage.apply(from.getOperatingSystem()); } }
Source:
<code>protected TimeEvent createEvent(Object tuple) { int idx = 0; if (!isLeft) { idx = 1; } if (timeFields != null) { return new TimeEventImpl(getKeyValue(keys[idx], tuple), (Long)getTime(timeFields[idx], tuple), tuple); } else { <START> return new TimeEventImpl(getKeyValue(keys[idx], tuple), Calendar.getInstance().getTimeInMillis(), tuple); <END> } }</code><technical_language>If I do join multiple fields? If supporting join multiple fields please mention in Java doc List contains items... check size in populateKeyFields populateTimeFields</technical_language>

Target:
protected TimeEvent createEvent(Object tuple) { String key = leftStore.getKeys(); String timeField = leftStore.getTimeFields(); if (!isLeft) { key = rightStore.getKeys(); timeField = rightStore.getTimeFields(); } if (timeField != null) { return new TimeEventImpl(getKeyValue(key, tuple), (Long)getTime(timeField, tuple), tuple); } else { return new TimeEventImpl(getKeyValue(key, tuple), Calendar.getInstance().getTimeInMillis(), tuple); } }
Source:
<code>public IId<?> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, <START> JsonProcessingException { <END> return m_idExternalFormatter.get().fromExternalForm(p.readValueAs(String.class)); }</code><technical_language>JsonProcessingExceptio is sublass of IOException -> remove</technical_language>

Target:
public IId<?> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { return m_idExternalFormatter.get().fromExternalForm(p.readValueAs(String.class)); }
Source:
<code>private String effectiveRegistryName(DockerImageName dockerImageName) { <START> if (isNullOrEmpty(dockerImageName.getRegistry())) { <END> return DEFAULT_REGISTRY_NAME; } else { return dockerImageName.getRegistry(); } }</code><technical_language>return StringUtils.defaultIfEmpty(dockerImageName.getRegistry(), DEFAULT_REGISTRY_NAME)</technical_language>

Target:
private String effectiveRegistryName(DockerImageName dockerImageName) { return StringUtils.defaultIfEmpty(dockerImageName.getRegistry(), DEFAULT_REGISTRY_NAME); }
Source:
<code><START> public String removeBraces(OMAttribute atr){ <END> String trimmed = atr.getAttributeValue().trim(); String path = trimmed.substring(1, trimmed.length()-1); return path; }}</code><technical_language>Formatting issue</technical_language>

Target:
public String removeBraces(OMAttribute atr) { String trimmed = atr.getAttributeValue().trim(); String path = trimmed.substring(1, trimmed.length() - 1); return path; }
Source:
<code>protected Object decode( ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception { int endIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ']') + 1; if (endIndex > 0) { ByteBuf frame = Unpooled.buffer(); while (buf.readerIndex() < endIndex) { byte b = buf.readByte(); if (b == '}') { <START> byte c = buf.readByte(); <END> switch (c) { case 0x01: frame.writeByte('}'); break; case 0x02: frame.writeByte('['); break; case 0x03: frame.writeByte(']'); break; case 0x04: frame.writeByte(','); break; case 0x05: frame.writeByte('*'); break; default: throw new IllegalArgumentException(String.format( "unexpected byte at %d: 0x%02x", buf.readerIndex() - 1, c)); } } else { frame.writeByte(b); } } return frame; } return null; }</code><technical_language>need names</technical_language>

Target:
protected Object decode( ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception { int endIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ']') + 1; if (endIndex > 0) { ByteBuf frame = Unpooled.buffer(); while (buf.readerIndex() < endIndex) { byte b1 = buf.readByte(); if (b1 == '}') { byte b2 = buf.readByte(); switch (b2) { case 0x01: frame.writeByte('}'); break; case 0x02: frame.writeByte('['); break; case 0x03: frame.writeByte(']'); break; case 0x04: frame.writeByte(','); break; case 0x05: frame.writeByte('*'); break; default: throw new IllegalArgumentException(String.format( "unexpected byte at %d: 0x%02x", buf.readerIndex() - 1, b2)); } } else { frame.writeByte(b1); } } return frame; } return null; }
Source:
<code>public void testUnRecommendPost() { JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID); JsonJavaObject json = previewPage.getJson(); <START> System.out.println("aaaaaaaaaaaa "+json.getString("status")); <END> Assert.assertTrue(json.getString("status").equals("204.0")); }</code><technical_language>sysout</technical_language>

Target:
public void testUnRecommendPost() { JavaScriptPreviewPage previewPage = executeSnippet(SNIPPET_ID); JsonJavaObject json = previewPage.getJson(); Assert.assertTrue(json.getString("status").equals("204.0")); }
Source:
<code>public PackingPlan pack() { int adjustments = this.numAdjustments; Map<Integer, List<InstanceId>> containerInstances = getResourceCompliantRRAllocation(); while (containerInstances == null) { if (this.numAdjustments > adjustments) { adjustments++; containerInstances = getResourceCompliantRRAllocation(); } else { return null; } } Map<String, Long> ramMap = TopologyUtils.getComponentRamMapConfig(topology); List<TopologyAPI.Config.KeyValue> topologyConfig = topology.getTopologyConfig().getKvsList(); <START> this.paddingPercentage = TopologyUtils.getConfigWithDefault( <END> topologyConfig, com.twitter.heron.api.Config.TOPOLOGY_CONTAINER_PADDING_PERCENTAGE, DEFAULT_CONTAINER_PADDING_PERCENTAGE); Set<PackingPlan.ContainerPlan> containerPlans = PackingUtils.buildContainerPlans( containerInstances, ramMap, this.defaultInstanceResources, paddingPercentage); return new PackingPlan(topology.getId(), containerPlans); }</code><technical_language>set class member values initialization, instead of a side effect a logic method</technical_language>

Target:
public PackingPlan pack() { int adjustments = this.numAdjustments; Map<Integer, List<InstanceId>> containerInstances = getResourceCompliantRRAllocation(); while (containerInstances == null) { if (this.numAdjustments > adjustments) { adjustments++; containerInstances = getResourceCompliantRRAllocation(); } else { return null; } } Map<String, Long> ramMap = TopologyUtils.getComponentRamMapConfig(topology); Set<PackingPlan.ContainerPlan> containerPlans = PackingUtils.buildContainerPlans( containerInstances, ramMap, this.defaultInstanceResources, paddingPercentage); return new PackingPlan(topology.getId(), containerPlans); }
Source:
<code>public QueryIterator(QueryBuilder query, int scrollSize, int maxSize, JestClient client, Parser<E> parser, String... indices) throws IOException { this.scrollSize = scrollSize; this.client = client; this.parser = parser; <START> this.gson = new Gson(); <END> SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder() .query(query); Search.Builder searchBuilder = new Search.Builder(searchSourceBuilder.toString()) .addIndex(Seq.of(indices).toList()); if(maxSize == -1) maxSize = 10000; if (scrollSize > 0) { searchBuilder.setParameter(Parameters.SCROLL, new TimeValue(60000)); searchBuilder.setParameter(Parameters.SIZE, Math.min(maxSize, scrollSize)); } else { searchBuilder.setParameter(Parameters.SIZE, maxSize); } Search search = searchBuilder.build(); this.scrollResponse = client.execute(search); this.hits = this.scrollResponse.getJsonObject().getAsJsonObject("hits").getAsJsonArray("hits").iterator(); }</code><technical_language>Is Gson current JSON library using? open issue for future standardize Unipop a single library..</technical_language>

Target:
public QueryIterator(QueryBuilder query, int scrollSize, int maxSize, JestClient client, Parser<E> parser, String... indices) throws IOException { this.scrollSize = scrollSize; this.client = client; this.parser = parser; this.gson = new Gson(); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder() .query(query); Search.Builder searchBuilder = new Search.Builder(searchSourceBuilder.toString()) .addIndex(Lists.newArrayList(indices)); if(maxSize == -1) maxSize = 10000; if (scrollSize > 0) { searchBuilder.setParameter(Parameters.SCROLL, new TimeValue(60000)); searchBuilder.setParameter(Parameters.SIZE, Math.min(maxSize, scrollSize)); } else { searchBuilder.setParameter(Parameters.SIZE, maxSize); } Search search = searchBuilder.build(); this.scrollResponse = client.execute(search); this.hits = this.scrollResponse.getJsonObject().getAsJsonObject("hits").getAsJsonArray("hits").iterator(); }
Source:
<code>private void shouldConvertConsistentlyWithThriftStructConverter(Class scroogeClass) { try { Class<? extends TBase<?, ?>> thriftClass = (Class<? extends TBase<?, ?>>)Class.forName(scroogeClass.getName().replaceFirst("parquet.scrooge.test", "parquet.thrift.test")); ThriftType.StructType structFromThriftSchemaConverter = new ThriftSchemaConverter().toStructType(thriftClass); ThriftType.StructType structFromScroogeSchemaConverter = new ScroogeStructConverter().convert(scroogeClass); assertEquals(structFromThriftSchemaConverter, structFromScroogeSchemaConverter); assertEquals(toParquetSchema(structFromThriftSchemaConverter), toParquetSchema(structFromScroogeSchemaConverter)); } catch (ClassNotFoundException e) { fail("ClassNotFoundException: " + e.getMessage()); <START> } <END> }</code><technical_language>exception propagate up? correct stacktrace</technical_language>

Target:
private void shouldConvertConsistentlyWithThriftStructConverter(Class scroogeClass) throws ClassNotFoundException { Class<? extends TBase<?, ?>> thriftClass = (Class<? extends TBase<?, ?>>)Class.forName(scroogeClass.getName().replaceFirst("parquet.scrooge.test", "parquet.thrift.test")); ThriftType.StructType structFromThriftSchemaConverter = new ThriftSchemaConverter().toStructType(thriftClass); ThriftType.StructType structFromScroogeSchemaConverter = new ScroogeStructConverter().convert(scroogeClass); assertEquals(toParquetSchema(structFromThriftSchemaConverter), toParquetSchema(structFromScroogeSchemaConverter)); }
Source:
<code>private void peekEventsFromIncompleteTransactions(List<AsyncEvent<?, ?>> batch, long lastKey) { if (!mustGroupTransactionEvents()) { return; } Set<TransactionId> incompleteTransactionIdsInBatch = getIncompleteTransactionsInBatch(batch); if (incompleteTransactionIdsInBatch.size() == 0) { return; } <START> boolean areAllEventsForTransactionsInBatch = true; <END> for (TransactionId transactionId : incompleteTransactionIdsInBatch) { boolean areAllEventsForTransactionInBatch = false; int retries = 0; long lastKeyForTransaction = lastKey; while (!areAllEventsForTransactionInBatch && retries++ < GET_TRANSACTION_EVENTS_FROM_QUEUE_RETRIES) { EventsAndLastKey eventsAndKey = peekEventsWithTransactionId(transactionId, lastKeyForTransaction); for (Object object : eventsAndKey.events) { GatewaySenderEventImpl event = (GatewaySenderEventImpl) object; batch.add(event); areAllEventsForTransactionInBatch = event.isLastEventInTransaction(); if (logger.isDebugEnabled()) { logger.debug( "Peeking extra event: {}, isLastEventInTransaction: {}, batch size: {}", event.getKey(), event.isLastEventInTransaction(), batch.size()); } } lastKeyForTransaction = eventsAndKey.lastKey; } if (!areAllEventsForTransactionInBatch) { areAllEventsForTransactionsInBatch = false; logger.warn("Not able to retrieve all events for transaction after tries", transactionId, retries); } } if (!areAllEventsForTransactionsInBatch) { stats.incBatchesWithIncompleteTransactions(); } }</code><technical_language>name of this variable is similar existing areAllEventsForTransactionInBatch, is confusing. Please rename of clearer keeping track of</technical_language>

Target:
private void peekEventsFromIncompleteTransactions(List<AsyncEvent<?, ?>> batch, long lastKey) { if (!mustGroupTransactionEvents()) { return; } Set<TransactionId> incompleteTransactionIdsInBatch = getIncompleteTransactionsInBatch(batch); if (incompleteTransactionIdsInBatch.size() == 0) { return; } boolean batchHasIncompleteTransactions = true; for (TransactionId transactionId : incompleteTransactionIdsInBatch) { boolean areAllEventsForTransactionInBatch = false; int retries = 0; long lastKeyForTransaction = lastKey; while (!areAllEventsForTransactionInBatch && retries++ < GET_TRANSACTION_EVENTS_FROM_QUEUE_RETRIES) { EventsAndLastKey eventsAndKey = peekEventsWithTransactionId(transactionId, lastKeyForTransaction); for (Object object : eventsAndKey.events) { GatewaySenderEventImpl event = (GatewaySenderEventImpl) object; batch.add(event); areAllEventsForTransactionInBatch = event.isLastEventInTransaction(); if (logger.isDebugEnabled()) { logger.debug( "Peeking extra event: {}, isLastEventInTransaction: {}, batch size: {}", event.getKey(), event.isLastEventInTransaction(), batch.size()); } } lastKeyForTransaction = eventsAndKey.lastKey; } if (!areAllEventsForTransactionInBatch) { batchHasIncompleteTransactions = true; logger.warn("Not able to retrieve all events for transaction after tries", transactionId, retries); } } if (batchHasIncompleteTransactions) { stats.incBatchesWithIncompleteTransactions(); } }
Source:
<code>public static List<URL> getFilesInPath(URL fileURL) throws MalformedURLException { List<URL> urls = new ArrayList<>(); File file = new File(fileURL.getPath()); if (file.isDirectory()) { File[] files = file.listFiles(); if (files != null) { for (File innerFile : files) { if (innerFile.isFile()) { <START> if (!innerFile.toString().endsWith("crc")) { <END> urls.add(innerFile.toURI().toURL()); } } else { urls.addAll(getFilesInPath(file.toURI().toURL())); } } } if (!fileURL.toString().endsWith("/")) { fileURL = new URL(fileURL.toString() + "/"); } } urls.add(fileURL); return urls; }</code><technical_language>do need filter out this? issue? other temp hidden files too? If filtering, need filter out too</technical_language>

Target:
public static List<URL> getFilesInPath(URL fileURL) throws MalformedURLException { List<URL> urls = new ArrayList<>(); File file = new File(fileURL.getPath()); if (file.isDirectory()) { File[] files = file.listFiles(); if (files != null) { for (File innerFile : files) { if (innerFile.isFile()) { urls.add(innerFile.toURI().toURL()); } else { urls.addAll(getFilesInPath(file.toURI().toURL())); } } } if (!fileURL.toString().endsWith("/")) { fileURL = new URL(fileURL.toString() + "/"); } } urls.add(fileURL); return urls; }
Source:
<code>public void onProjectIndexingFinishedEvent(@Observes IndexingFinishedEvent event) { newProjectIndexed = true; if (newProjectPath != null && newProjectPath.equals(event.getPath())) { projectService.call((WorkspaceProject project) -> { endProjectCreation(); getSuccessCallback().execute(project); }).resolveProject(event.getPath()); } <START> } <END></code><technical_language>path add event if newProjectPath set yet? (newProjectPath is null)</technical_language>

Target:
public void onProjectIndexingFinishedEvent(@Observes IndexingFinishedEvent event) { projectsIndexed.add(event.getPath()); if (newProjectPath != null && newProjectPath.equals(event.getPath())) { projectService.call((WorkspaceProject project) -> { endProjectCreation(); getSuccessCallback().execute(project); }, (o, throwable) -> { logger.info("Project path " + event.getPath().toURI() + " not found."); return false; }).resolveProject(event.getPath()); } }
Source:
<code>public void processLeftData(final MistDataEvent input) { <START> inputTimestampCheck(input.getTimestamp()); <END> final Iterator<Window<T>> itr = windowQueue.iterator(); while (itr.hasNext()) { final Window<T> window = itr.next(); window.putData(input); } }</code><technical_language>please separate this method</technical_language>

Target:
public void processLeftData(final MistDataEvent input) { createWindow(input.getTimestamp()); emitElapsedWindow(input.getTimestamp()); final Iterator<Window<T>> itr = windowQueue.iterator(); while (itr.hasNext()) { final Window<T> window = itr.next(); window.putData(input); } }
Source:
<code>public RuleModel unmarshal( final String str, final List<String> globals, final PackageDataModelOracle dmo ) { <START> return unmarshal( str, globals, dmo, null ); <END> }</code><technical_language>Collections.emptySet() of Optional preferential</technical_language>

Target:
public RuleModel unmarshal(final String str, final List<String> globals, final PackageDataModelOracle dmo) { return unmarshal(str, globals, dmo, Collections.emptyList()); }
Source:
<code>private static void usage() { <START> log.debug("usage: [-namespace namespace] [-dump] [-extentSize dstJournalSize] propertyFile"); <END> System.exit(1); }</code><technical_language>I want stderr put in logs... console user is interested in that</technical_language>

Target:
private static void usage() { System.err.println("Usage: [-namespace namespace] [-dump] [-verify] [-extentSize dstJournalSize] propertyFile"); System.exit(1); }
Source:
<code>public static String format(Throwable t) { StringWriter sw = new StringWriter(); log.error(t); <START> return t + "\n" + sw.toString(); <END> }</code><technical_language>This call log.error(t);. return t + "\n" + ExceptionUtil.getStackTrace(t);</technical_language>

Target:
public static String format(Throwable t) { return t + "\n" + ExceptionUtils.getStackTrace(t); }
Source:
<code>public void updateDynamicData(VdsDynamic dynamicData) { <START> vdsDynamicDao.update(dynamicData); <END> cachedVds.setDynamicData(dynamicData); cachedDynamicDataHash = dynamicData.dbFieldsHash(); }</code><technical_language>replaced updateIfneeded, equals comparison hashcode usage, is prone collision. code works fine for preventing record update. this patch wants achieve</technical_language>

Target:
public void updateDynamicData(VdsDynamic dynamicData) { vdsDynamicDao.updateIfNeeded(dynamicData); cachedVds.setDynamicData(dynamicData); }
Source:
<code>private void addAllCustomLayoutChildDescriptors(Collection<Object> newChildDescriptors) { Map<String, GenericLayoutProviderSupplier> layoutProviderRegistry = DiagramUIPlugin.getPlugin().getLayoutProviderRegistry(); <START> Set<Entry<String, GenericLayoutProviderSupplier>> layoutProviders = layoutProviderRegistry.entrySet(); for (Entry<String, GenericLayoutProviderSupplier> layoutProviderEntry : layoutProviders) { GenericLayout newGenericLayout = DescriptionFactory.eINSTANCE.createGenericLayout(); newGenericLayout.setID(layoutProviderEntry.getKey()); newGenericLayout.setLabel(layoutProviderEntry.getValue().getLabel()); newChildDescriptors.add(createChildParameter(org.eclipse.sirius.diagram.description.DescriptionPackage.Literals.DIAGRAM_DESCRIPTION__LAYOUT, newGenericLayout)); } <END> }</code><technical_language>I propose a simplier code: layoutProviderRegistry.forEach((key,value)->{ GenericLayout newGenericLayout = DescriptionFactory.eINSTANCE.createGenericLayout(); newGenericLayout.setID(key); newGenericLayout.setLabel(value.getLabel()); newChildDescriptors.add(createChildParameter(org.eclipse.sirius.diagram.description.DescriptionPackage.Literals.DIAGRAM_DESCRIPTION__LAYOUT, newGenericLayout)); });</technical_language>

Target:
private void addAllCustomLayoutChildDescriptors(Collection<Object> newChildDescriptors) { Map<String, GenericLayoutProviderSupplier> layoutProviderRegistry = DiagramUIPlugin.getPlugin().getLayoutProviderRegistry(); layoutProviderRegistry.forEach((key, value) -> { CustomLayoutConfiguration customConfiguration = DescriptionFactory.eINSTANCE.createCustomLayoutConfiguration(); customConfiguration.setId(key); customConfiguration.setLabel(value.getLabel()); newChildDescriptors.add(createChildParameter(org.eclipse.sirius.diagram.description.DescriptionPackage.Literals.DIAGRAM_DESCRIPTION__LAYOUT, customConfiguration)); }); }
Source:
<code>public String open() { checkOperationMode(); prepareOpen(); <START> <END> if (this.clientFiles!=null){ handleFileDrop( clientFiles ); } runEventLoop( shell ); return returnCode == SWT.OK ? getFileName() : null; }</code><technical_language>Please remove empty lines adjust RAP coding style (whitespace brackets != operator)</technical_language>

Target:
public String open() { checkOperationMode(); prepareOpen(); beforeOpen(); runEventLoop( shell ); return returnCode == SWT.OK ? getFileName() : null; }
Source:
<code>public void testCombineMany() { int n = RxRingBuffer.SIZE * 3; <START> Observable<Integer> source = Observable.just(1); <END> List<Observable<Integer>> sources = new ArrayList<Observable<Integer>>(); for (int i = 0; i < n; i++) { sources.add(source); } TestSubscriber<Integer> ts = TestSubscriber.create(); Observable.combineLatest(sources, new FuncN<Integer>() { @Override public Integer call(Object... args) { int sum = 0; for (Object o : args) { sum += (Integer)o; } return sum; } }).subscribe(ts); ts.assertNoErrors(); ts.assertValue(n); ts.assertCompleted(); }</code><technical_language>@akarnokd this play bad "joke" operator needs combine result (first, second, etc) correct amount of times pass test! please create unique observables a source? Strings prevent effects mathematical operations (equality of sum fixed order in this case)</technical_language>

Target:
public void testCombineMany() { int n = RxRingBuffer.SIZE * 3; List<Observable<Integer>> sources = new ArrayList<Observable<Integer>>(); StringBuilder expected = new StringBuilder(n * 2); for (int i = 0; i < n; i++) { sources.add(Observable.just(i)); expected.append(i); } TestSubscriber<String> ts = TestSubscriber.create(); Observable.combineLatest(sources, new FuncN<String>() { @Override public String call(Object... args) { StringBuilder b = new StringBuilder(); for (Object o : args) { b.append(o); } return b.toString(); } }).subscribe(ts); ts.assertNoErrors(); ts.assertValue(expected.toString()); ts.assertCompleted(); }
Source:
<code>private IAction findContributedAction(String actionID) { List<IConfigurationElement> actions= new ArrayList<>(); IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(PlatformUI.PLUGIN_ID, "editorActions"); for (int i= 0; i < elements.length; i++) { IConfigurationElement element= elements[i]; if (TAG_CONTRIBUTION_TYPE.equals(element.getName())) { if <START> (getSite() != <END> null && !getSite().getId().equals(element.getAttribute("targetID"))) continue; IConfigurationElement[] children= element.getChildren("action"); for (int j= 0; j < children.length; j++) { IConfigurationElement child= children[j]; if (actionID.equals(child.getAttribute("actionID"))) actions.add(child); } } } int actionSize= actions.size(); if (actionSize > 0) { IConfigurationElement element; if (actionSize > 1) { IConfigurationElement[] actionArray= actions.toArray(new IConfigurationElement[actionSize]); ConfigurationElementSorter sorter= new ConfigurationElementSorter() { @Override public IConfigurationElement getConfigurationElement(Object object) { return (IConfigurationElement)object; } }; sorter.sort(actionArray); element= actionArray[0]; } else element= actions.get(0); try { return new ContributedAction(getSite(), element); } catch (CommandNotMappedException e) { } } return null; }</code><technical_language>I extract this variable move of loop. that, check if site == null return null</technical_language>

Target:
private IAction findContributedAction(String actionID) { List<IConfigurationElement> actions= new ArrayList<>(); IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(PlatformUI.PLUGIN_ID, "editorActions"); for (int i= 0; i < elements.length; i++) { IConfigurationElement element= elements[i]; if (TAG_CONTRIBUTION_TYPE.equals(element.getName())) { IWorkbenchPartSite site = getSite(); if (site != null && !site.getId().equals(element.getAttribute("targetID"))) continue; IConfigurationElement[] children= element.getChildren("action"); for (int j= 0; j < children.length; j++) { IConfigurationElement child= children[j]; if (actionID.equals(child.getAttribute("actionID"))) actions.add(child); } } } int actionSize= actions.size(); if (actionSize > 0) { IConfigurationElement element; if (actionSize > 1) { IConfigurationElement[] actionArray= actions.toArray(new IConfigurationElement[actionSize]); ConfigurationElementSorter sorter= new ConfigurationElementSorter() { @Override public IConfigurationElement getConfigurationElement(Object object) { return (IConfigurationElement)object; } }; sorter.sort(actionArray); element= actionArray[0]; } else element= actions.get(0); try { return new ContributedAction(getSite(), element); } catch (CommandNotMappedException e) { } } return null; }
Source:
<code>public int getItemViewType(int position) { if (position == 0) { return RowType.RESPONSE; <START> } <END> if (progressVisible && position == getItemCount() - 1) { return RowType.PROGRESS; } return RowType.COMMENT; }</code><technical_language>move this case progress bar row check, conceivably load response server in future</technical_language>

Target:
public int getItemViewType(int position) { if (progressVisible && position == getItemCount() - 1) { return RowType.PROGRESS; } if (position == 0) { return RowType.RESPONSE; } return RowType.COMMENT; }
Source:
<code>private AbstractTextEditor getActiveTextEditor() { IWorkbench workbench = PlatformUI.getWorkbench(); <START> IEditorPart editor = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor(); <END> AbstractTextEditor textEditor = null; if (editor instanceof AbstractTextEditor) { textEditor = (AbstractTextEditor)editor; } else if ((editor instanceof AbstractMultiEditor) && ((AbstractMultiEditor)editor).getActiveEditor() instanceof AbstractTextEditor) { textEditor = (AbstractTextEditor) ((AbstractMultiEditor)editor).getActiveEditor(); } else if ((editor instanceof MultiPageEditorPart) && ((MultiPageEditorPart)editor).getSelectedPage() instanceof AbstractTextEditor) { textEditor = (AbstractTextEditor) ((MultiPageEditorPart)editor).getSelectedPage(); } return textEditor; }</code><technical_language>Potential NPE, textEditor.getSite().getWorkbenchWindow()</technical_language>

Target:
private AbstractTextEditor getActiveTextEditor() { IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow(); if (activeWorkbenchWindow == null) { return null; } IPartService partService = activeWorkbenchWindow.getPartService(); if (partService == null) { return null; } IWorkbenchPart part = partService.getActivePart(); AbstractTextEditor textEditor = null; if (part instanceof AbstractTextEditor) { textEditor = (AbstractTextEditor)part; } else if ((part instanceof AbstractMultiEditor) && ((AbstractMultiEditor)part).getActiveEditor() instanceof AbstractTextEditor) { textEditor = (AbstractTextEditor) ((AbstractMultiEditor)part).getActiveEditor(); } else if ((part instanceof MultiPageEditorPart) && ((MultiPageEditorPart)part).getSelectedPage() instanceof AbstractTextEditor) { textEditor = (AbstractTextEditor) ((MultiPageEditorPart)part).getSelectedPage(); } return textEditor; }
Source:
<code><START> public static ColumnValueSelector makeColumnValueSelectorWithLongDefault( <END> final ColumnSelectorFactory metricFactory, final ExprMacroTable macroTable, final String fieldName, final String fieldExpression, final long nullValue ) { if (fieldName != null && fieldExpression == null) { return metricFactory.makeColumnValueSelector(fieldName); } if (fieldName == null && fieldExpression != null) { final Expr expr = Parser.parse(fieldExpression, macroTable); final ColumnValueSelector<ExprEval> baseSelector = ExpressionSelectors.makeExprEvalSelector(metricFactory, expr); class ExpressionLongColumnSelector implements LongColumnSelector { @Override public long getLong() { final ExprEval exprEval = baseSelector.getObject(); return exprEval.isNumericNull() ? nullValue : exprEval.asLong(); } @Override public void inspectRuntimeShape(RuntimeShapeInspector inspector) { inspector.visit("baseSelector", baseSelector); } @Override public boolean isNull() { final ExprEval exprEval = baseSelector.getObject(); return exprEval == null || exprEval.isNumericNull(); } } return new ExpressionLongColumnSelector(); } throw new IllegalArgumentException("Must have a valid, non-null fieldName or expression"); }</code><technical_language>makeColumnValueSelectorWithFloatDefault() signature changed this method doesn't</technical_language>

Target:
public static BaseLongColumnValueSelector makeColumnValueSelectorWithLongDefault( final ColumnSelectorFactory metricFactory, final ExprMacroTable macroTable, final String fieldName, final String fieldExpression, final long nullValue ) { if (fieldName != null && fieldExpression == null) { return metricFactory.makeColumnValueSelector(fieldName); } if (fieldName == null && fieldExpression != null) { final Expr expr = Parser.parse(fieldExpression, macroTable); final ColumnValueSelector<ExprEval> baseSelector = ExpressionSelectors.makeExprEvalSelector(metricFactory, expr); class ExpressionLongColumnSelector implements LongColumnSelector { @Override public long getLong() { final ExprEval exprEval = baseSelector.getObject(); return exprEval.isNumericNull() ? nullValue : exprEval.asLong(); } @Override public void inspectRuntimeShape(RuntimeShapeInspector inspector) { inspector.visit("baseSelector", baseSelector); } @Override public boolean isNull() { final ExprEval exprEval = baseSelector.getObject(); return exprEval == null || exprEval.isNumericNull(); } } return new ExpressionLongColumnSelector(); } throw new IllegalArgumentException("Must have a valid, non-null fieldName or expression"); }
Source:
<code>public void set_project_without_branch() { IssueChangeNotification result = notification.setProject("MyService", "My Service", null, ""); assertThat(result.getFieldValue("projectKey")).isEqualTo("MyService"); assertThat(result.getFieldValue("projectName")).isEqualTo("My Service"); assertThat(result.getFieldValue("branch")).isNull(); <START> } <END></code><technical_language>a test of field "projectUuid' missing here</technical_language>

Target:
public void set_project_without_branch() { IssueChangeNotification result = notification.setProject("MyService", "My Service", null, "uuid1"); assertThat(result.getFieldValue("projectKey")).isEqualTo("MyService"); assertThat(result.getFieldValue("projectUuid")).isEqualTo("uuid1"); assertThat(result.getFieldValue("projectName")).isEqualTo("My Service"); assertThat(result.getFieldValue("branch")).isNull(); }
Source:
<code>public void testFactoryFailedToCreateDriver() { final Configuration config = new Configuration(); final String driverFactoryClassName = TestingFailedExternalResourceDriverFactory.class.getName(); final Map<Class<?>, Iterator<?>> plugins = new HashMap<>(); plugins.put(ExternalResourceDriverFactory.class, IteratorUtils.singletonIterator(new TestingFailedExternalResourceDriverFactory())); final PluginManager testingPluginManagerPluginManager = new TestingPluginManager(plugins); config.set(ExternalResourceOptions.EXTERNAL_RESOURCE_LIST, Collections.singletonList(RESOURCE_NAME_1)); config.setString(ExternalResourceOptions.keyWithResourceNameAndSuffix(RESOURCE_NAME_1, ExternalResourceOptions.EXTERNAL_RESOURCE_DRIVER_FACTORY_SUFFIX), driverFactoryClassName); final Map<String, ExternalResourceDriver> externalResourceDrivers = ExternalResourceUtils.externalResourceDriversFromConfig(config, testingPluginManagerPluginManager); <START> assertThat(externalResourceDrivers.size(), is(0)); <END> }</code><technical_language>suggestion assertThat(externalResourceDrivers, empty());</technical_language>

Target:
public void testFactoryFailedToCreateDriver() { final Configuration config = new Configuration(); final String driverFactoryClassName = TestingFailedExternalResourceDriverFactory.class.getName(); final Map<Class<?>, Iterator<?>> plugins = new HashMap<>(); plugins.put(ExternalResourceDriverFactory.class, IteratorUtils.singletonIterator(new TestingFailedExternalResourceDriverFactory())); final PluginManager testingPluginManager = new TestingPluginManager(plugins); config.set(ExternalResourceOptions.EXTERNAL_RESOURCE_LIST, Collections.singletonList(RESOURCE_NAME_1)); config.setString(ExternalResourceOptions.getExternalResourceDriverFactoryConfigOptionForResource(RESOURCE_NAME_1), driverFactoryClassName); final Map<String, ExternalResourceDriver> externalResourceDrivers = ExternalResourceUtils.externalResourceDriversFromConfig(config, testingPluginManager); assertThat(externalResourceDrivers.entrySet(), is(empty())); }
Source:
<code>protected void stopProcessing(IgniteCheckedException stopErr) { try { busyLock.block(); ctx.event().removeDiscoveryEventListener(discoLsnr); ctx.io().removeMessageListener(commLsnr); U.cancel(depWorker); U.join(depWorker, log); depWorker.tasksQueue.clear(); pendingEvts.clear(); tasks.values().forEach(t -> t.completeError(stopErr)); tasks.clear(); } catch (Exception e) { <START> log.error("Error occurred during stopping deployment worker.", e); <END> } }</code><technical_language>I want propagate exception upwards, killing node. Swallowing exception good</technical_language>

Target:
void stopProcessing(IgniteCheckedException stopErr) { busyLock.block(); ctx.event().removeDiscoveryEventListener(discoLsnr); ctx.io().removeMessageListener(commLsnr); U.cancel(depWorker); U.join(depWorker, log); depWorker.tasksQueue.clear(); pendingEvts.clear(); tasks.values().forEach(t -> t.completeError(stopErr)); tasks.clear(); }
Source:
<code>private LogMessage convertBean(final LogEntryBean bean) { <START> final LogMessage message = new LogMessage(); <END> message.setMessage(bean.getMessage()); message.setLevel(bean.getLogLevel()); message.setTimestamp(bean.getLogTimestamp()); return message; }</code><technical_language>Add null-check for bean</technical_language>

Target:
private LogMessage convertBean(final LogEntryBean bean) { Assert.requireNonNull(bean, "bean"); final LogMessage message = new LogMessage(); message.setMessage(bean.getMessage()); message.setLevel(bean.getLogLevel()); message.setTimestamp(bean.getLogTimestamp()); return message; }
Source:
<code>public void testInsertTemplateToUnregisteredEntity() { dao = dbFacade.getUnregisteredOVFDataDao(); final String ovfExtraData = "<ovf> Some extra OVF data </ovf>"; dao.insertOVFDataForEntities(FixturesTool.VM_TEMPLATE_RHEL5, "Stam", "TEMPLATE", 1, <START> "3.4", <END> FixturesTool.STORAGE_DOAMIN_NFS2_1, ovfExtraData); OvfEntityData ovfEntityData = dao.getByEntityIdAndStorageDomain(FixturesTool.VM_TEMPLATE_RHEL5, FixturesTool.STORAGE_DOAMIN_NFS2_1); assertNotNull(ovfEntityData); assertTrue("The entity type should be template", ovfEntityData.getEntityType().equals("TEMPLATE")); assertTrue("The entity OVF extra data should be updated", ovfEntityData.getOvfExtraData() .equals(ovfExtraData)); }</code><technical_language>Please Version.3_4.toString()</technical_language>

Target:
public void testInsertTemplateToUnregisteredEntity() { final String ovfExtraData = "<ovf> Some extra OVF data </ovf>"; OvfEntityData ovfEntityData = new OvfEntityData(FixturesTool.VM_TEMPLATE_RHEL5, "AnyVM", VmEntityType.TEMPLATE, ArchitectureType.x86_64, Version.v3_4, FixturesTool.STORAGE_DOAMIN_NFS2_1, null, ovfExtraData); dao.insertOVFDataForEntities(ovfEntityData); OvfEntityData fetchedOvfEntityData = dao.getByEntityIdAndStorageDomain(FixturesTool.VM_TEMPLATE_RHEL5, FixturesTool.STORAGE_DOAMIN_NFS2_1); assertNotNull(fetchedOvfEntityData); assertTrue("The entity type should be template", fetchedOvfEntityData.getEntityType().isTemplateType()); assertTrue("The entity OVF extra data should be updated", fetchedOvfEntityData.getOvfExtraData() .equals(ovfExtraData)); }
Source:
<code>public <T, Q> SearchQueryResultContext<Q> queryAsProjections( SessionContextImplementor sessionContext, ObjectLoader<R, O> objectLoader, Function<List<?>, T> hitTransformer, Function<SearchQuery<T>, Q> searchQueryWrapperFactory, SearchProjection<?>... projections) { HitAggregator<ProjectionHitCollector, List<T>> hitAggregator = <START> new MultipleProjectionHitAggregator<>( documentReferenceTransformer, objectLoader, hitTransformer, <END> projections.length ); SearchQueryBuilder<T, C> builder = searchTargetContext.getSearchQueryBuilderFactory() .asProjections( sessionContext, hitAggregator, projections ); return new SearchQueryResultContextImpl<>( searchTargetContext, builder, searchQueryWrapperFactory ); }</code><technical_language>In this case, MultipleProjectionsHitAggregator? weird Multiple a singular word</technical_language>

Target:
public <T, Q> SearchQueryResultContext<Q> queryAsProjections( SessionContextImplementor sessionContext, ObjectLoader<R, O> objectLoader, Function<List<?>, T> hitTransformer, Function<SearchQuery<T>, Q> searchQueryWrapperFactory, SearchProjection<?>... projections) { HitAggregator<ProjectionHitCollector, List<T>> hitAggregator = new MultipleProjectionsHitAggregator<>( documentReferenceTransformer, objectLoader, hitTransformer, projections.length ); SearchQueryBuilder<T, C> builder = searchTargetContext.getSearchQueryBuilderFactory() .asProjections( sessionContext, hitAggregator, projections ); return new SearchQueryResultContextImpl<>( searchTargetContext, builder, searchQueryWrapperFactory ); }
Source:
<code>public void untrackedFileIncluded() throws Exception { String trackedPath = "tracked.txt"; writeTrashFile(trackedPath, "content2"); git.add().addFilepattern(trackedPath).call(); RevCommit stashed = git.stashCreate() .setIncludeUntracked(true).call(); <START> assertNotNull(stashed); <END> validateStashedCommitWithAdditionalParent(stashed); assertEquals( "Expected commits for workingDir,stashedIndex and untrackedFiles.", 3, stashed.getParentCount()); assertFalse("untracked file should be deleted.", untrackedFile.exists()); }</code><technical_language>this is included in validateCoreStashedCommit()</technical_language>

Target:
public void untrackedFileIncluded() throws Exception { String trackedPath = "tracked.txt"; writeTrashFile(trackedPath, "content2"); git.add().addFilepattern(trackedPath).call(); RevCommit stashed = git.stashCreate() .setIncludeUntracked(true).call(); validateStashedCommit(stashed, 3); assertEquals( "Expected commits for workingDir,stashedIndex and untrackedFiles.", 3, stashed.getParentCount()); assertFalse("untracked file should be deleted.", untrackedFile.exists()); }
Source:
<code>public int compare(Integer index1, Integer index2) { if (dataArr[index2] > dataArr[index1]) { return -1; } else if (dataArr[index2] < dataArr[index1]) { return 1; } else { <START> return 0; <END> } }</code><technical_language>I simplify: @Override public int compare(Integer index1, Integer index2) { return Double.compare(dataArr[index2], dataArr[index1]) }</technical_language>

Target:
public int compare(Integer index1, Integer index2) { return Double.compare(dataArr[index1], dataArr[index2]); }