auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void salvageUnit(int i) { <START> TestUnit salvageUnit = getPotentialSalvage().get(i); <END> getActualSalvage().add(salvageUnit); }</code><technical_language>public include a check i</technical_language>

Target:
public void salvageUnit(int i) { if (i < getPotentialSalvage().size()) { TestUnit salvageUnit = getPotentialSalvage().get(i); getActualSalvage().add(salvageUnit); } }
Source:
<code>private List<ProcessorNode> getAllProcessorNodes() { List<String> processorZNodes = getSortedActiveProcessorsZnodes(); LOG.debug("Active ProcessorZNodes in zookeeper: {}.", processorZNodes); return processorZNodes.stream() .map(processorZNode -> { String ephemeralProcessorPath = String.format("%s/%s", keyBuilder.getProcessorsPath(), processorZNode); <START> String data = zkClient.readData(ephemeralProcessorPath); <END> return new ProcessorNode(new ProcessorData(data), ephemeralProcessorPath); }).collect(Collectors.toList()); }</code><technical_language>Is ZkUtils#readProcessorData instead of zkclient ? Metrics is lost wrapper methods for zkClient. other places in this PR this way. in existing code. I create wrapper methods for zkclient api for sake of metrics</technical_language>

Target:
private List<ProcessorNode> getAllProcessorNodes() { List<String> processorZNodes = getSortedActiveProcessorsZnodes(); LOG.debug("Active ProcessorZNodes in zookeeper: {}.", processorZNodes); return processorZNodes.stream() .map(processorZNode -> { String ephemeralProcessorPath = String.format("%s/%s", keyBuilder.getProcessorsPath(), processorZNode); String data = readProcessorData(ephemeralProcessorPath); return new ProcessorNode(new ProcessorData(data), ephemeralProcessorPath); }).collect(Collectors.toList()); }
Source:
<code>public void testNonStraddlingJoinExpression() { assertPlan("SELECT * FROM orders JOIN lineitem ON orders.orderkey = lineitem.orderkey AND cast(lineitem.linenumber AS varchar) = '2'", anyTree( join(INNER, ImmutableList.of(equiJoinClause("ORDERS_OK", "LINEITEM_OK")), anyTree( <START> filter("ORDERS_OK IS NOT NULL", <END> tableScan("orders", ImmutableMap.of("ORDERS_OK", "orderkey")))), anyTree( filter("LINEITEM_OK IS NOT NULL AND cast(LINEITEM_LINENUMBER as varchar) = cast('2' as varchar)", tableScan("lineitem", ImmutableMap.of( "LINEITEM_OK", "orderkey", "LINEITEM_LINENUMBER", "linenumber"))))))); }</code><technical_language>Formatting here</technical_language>

Target:
public void testNonStraddlingJoinExpression() { assertPlan("SELECT * FROM orders JOIN lineitem ON orders.orderkey = lineitem.orderkey AND cast(lineitem.linenumber AS varchar) = '2'", anyTree( join(INNER, ImmutableList.of(equiJoinClause("ORDERS_OK", "LINEITEM_OK")), any( tableScan("orders", ImmutableMap.of("ORDERS_OK", "orderkey"))), anyTree( filter("cast('2' as varchar) = cast(LINEITEM_LINENUMBER as varchar)", tableScan("lineitem", ImmutableMap.of( "LINEITEM_OK", "orderkey", "LINEITEM_LINENUMBER", "linenumber"))))))); }
Source:
<code>public void write(ResultSet resultSet) throws SQLException { while (resultSet.next()) { connection.setAutoCommit(false); try (PreparedStatement statement = connection.prepareStatement("INSERT INTO " + indexedEntriesTableName + "(ENTRY) VALUES(?)")) { statement.setObject(1, jsonbObject(resultSet.getBytes("ENTRY"))); statement.executeUpdate(); } try (PreparedStatement statement = connection.prepareStatement("UPDATE " + waterMarkTableName + " SET ID = ID + 1, time=now()")) { statement.executeUpdate(); } <START> connection.setAutoCommit(true); <END> } }</code><technical_language>this connection.commit()</technical_language>

Target:
public void write(ResultSet resultSet) throws SQLException { while (resultSet.next()) { connection.setAutoCommit(false); try (PreparedStatement statement = connection.prepareStatement("INSERT INTO " + indexedEntriesTableName + "(ENTRY) VALUES(?)")) { statement.setObject(1, jsonbObject(resultSet.getBytes("ENTRY"))); statement.executeUpdate(); } try (PreparedStatement statement = connection.prepareStatement("UPDATE " + waterMarkTableName + " SET ID = ID + 1, time=now()")) { statement.executeUpdate(); } connection.commit(); } }
Source:
<code>private List<ActivityLogEntry> filterLogsForActivityLogPage(List<AppLogLine> appLogLines, AdminActivityLogPageData data) { List<ActivityLogEntry> appLogs = new LinkedList<ActivityLogEntry>(); for (AppLogLine appLog : appLogLines) { String logMsg = appLog.getLogMessage(); boolean isNotTeammatesLog = !logMsg.contains("TEAMMATESLOG"); boolean isLogFromAdminActivityLogPage = logMsg.contains("adminActivityLogPage"); if (isNotTeammatesLog || isLogFromAdminActivityLogPage) { continue; } ActivityLogEntry activityLogEntry = new ActivityLogEntry(appLog); if (!data.filterLogs(activityLogEntry)) { continue; } <START> if (activityLogEntry.isTestingData() && !data.getIfShowTestData()) { <END> continue; } appLogs.add(activityLogEntry); } return appLogs; }</code><technical_language>this block previous contains continue. if combine conditionals</technical_language>

Target:
private List<ActivityLogEntry> filterLogsForActivityLogPage(List<AppLogLine> appLogLines, AdminActivityLogPageData data) { List<ActivityLogEntry> appLogs = new LinkedList<ActivityLogEntry>(); for (AppLogLine appLog : appLogLines) { String logMsg = appLog.getLogMessage(); boolean isNotTeammatesLog = !logMsg.contains("TEAMMATESLOG"); boolean isLogFromAdminActivityLogPage = logMsg.contains("adminActivityLogPage"); if (isNotTeammatesLog || isLogFromAdminActivityLogPage) { continue; } ActivityLogEntry activityLogEntry = new ActivityLogEntry(appLog); boolean isToShow = data.filterLog(activityLogEntry) && (!activityLogEntry.isTestingData() || data.getIfShowTestData()); if (!isToShow) { continue; } appLogs.add(activityLogEntry); } return appLogs; }
Source:
<code>public void testListTags_404() throws Exception { server.enqueue(response404()); <START> api.getTagApi().listTags(PaginationOptions.Builder.pageSize(100)); <END> assertSent(GET, "/caas/2.4/6ac1e746-b1ea-4da5-a24e-caf1a978789d/tag/tag?pageSize=100"); }</code><technical_language>Verify returned is empty iterable</technical_language>

Target:
public void testListTags_404() throws Exception { server.enqueue(response404()); final ImmutableList<Tag> emptyList = api.getTagApi().listTags().concat().toList(); assertSent(GET, expectedListTagsUriBuilder().toString()); assertTrue(emptyList.isEmpty()); }
Source:
<code>private boolean isKitSpecialVariants(Alteration alteration) { boolean isSpecial = false; if (alteration != null && alteration.getGene().getEntrezGeneId() == 3815) { <START> if (!isSpecial) { <END> String[] speicalVariants = {"V654A", "T670I"}; VariantConsequence consequence = VariantConsequenceUtils.findVariantConsequenceByTerm("missense_variant"); for (int i = 0; i < speicalVariants.length; i++) { if (alteration.getGene() != null && alteration.getGene().getEntrezGeneId() == 3815 && alteration.getAlteration() != null && alteration.getAlteration().equals(speicalVariants[i]) && alteration.getConsequence().equals(consequence)) { isSpecial = true; } } } if(!isSpecial) { isSpecial = isInExon17(alteration); } } return isSpecial; }</code><technical_language>unnecessary</technical_language>

Target:
private boolean isKitSpecialVariants(Alteration alteration) { boolean isSpecial = false; if (alteration != null && alteration.getGene().getEntrezGeneId() == 3815) { String[] speicalVariants = {"V654A", "T670I"}; VariantConsequence consequence = VariantConsequenceUtils.findVariantConsequenceByTerm("missense_variant"); for (int i = 0; i < speicalVariants.length; i++) { if (alteration.getGene() != null && alteration.getGene().getEntrezGeneId() == 3815 && alteration.getAlteration() != null && alteration.getAlteration().equals(speicalVariants[i]) && alteration.getConsequence().equals(consequence)) { isSpecial = true; break; } } if(!isSpecial) { isSpecial = isInExon17(alteration); } } return isSpecial; }
Source:
<code>public void listOverlapModifyingBatch() { Date startDate = createDate(2010, 1, 1); Date endDate = createDate(2050, 1, 1); Entitlement ent = setUpModifyingEntitlements(startDate, endDate, 3, "1"); Date startDate1 = createDate(2030, 1, 1); Date endDate1 = createDate(2040, 1, 1); Entitlement ent1 = setUpModifyingEntitlements(startDate1, endDate1, 2, "2"); Set<Entitlement> ents = entitlementCurator.listModifying(Arrays.asList(ent, ent1)); assertEquals(5, ents.size()); assertTrue(!ents.contains(ent)); assertTrue(!ents.contains(ent1)); <START> <END> }</code><technical_language>Extraneous whitespace</technical_language>

Target:
public void listOverlapModifyingBatch() { Date startDate = createDate(2010, 1, 1); Date endDate = createDate(2050, 1, 1); Entitlement ent = setUpModifyingEntitlements(startDate, endDate, 3, "1"); Date startDate1 = createDate(2030, 1, 1); Date endDate1 = createDate(2040, 1, 1); Entitlement ent1 = setUpModifyingEntitlements(startDate1, endDate1, 2, "2"); Set<Entitlement> ents = entitlementCurator.listModifying(Arrays.asList(ent, ent1)); assertEquals(5, ents.size()); assertThat(ents, not(hasItems(ent))); assertThat(ents, not(hasItems(ent1))); }
Source:
<code>public HiveBasicStatistics( OptionalLong fileCount, OptionalLong rowCount, OptionalLong inMemoryDataSizeInBytes, OptionalLong onDiskDataSizeInBytes) { this.fileCount = requireNonNull(fileCount, "fileCount is null"); <START> fileCount.ifPresent(count -> checkArgument(count >= 0, "fileCount must be greater or equal than zero")); <END> this.rowCount = requireNonNull(rowCount, "rowCount is null"); rowCount.ifPresent(count -> checkArgument(count >= 0, "rowCount must be greater or equal than zero")); this.inMemoryDataSizeInBytes = requireNonNull(inMemoryDataSizeInBytes, "inMemoryDataSizeInBytes is null"); inMemoryDataSizeInBytes.ifPresent(size -> checkArgument(size >= 0, "inMemoryDataSizeInBytes must be greater or equal than zero")); this.onDiskDataSizeInBytes = requireNonNull(onDiskDataSizeInBytes, "onDiskDataSizeInBytes is null"); onDiskDataSizeInBytes.ifPresent(size -> checkArgument(size >= 0, "onDiskDataSizeInBytes must be greater or equal than zero")); }</code><technical_language>I searched for checkArgument\(.* >= 0 in Presto code base. In cases, write error message this fileCount is negative. Ditto for next lines</technical_language>

Target:
public HiveBasicStatistics( OptionalLong fileCount, OptionalLong rowCount, OptionalLong inMemoryDataSizeInBytes, OptionalLong onDiskDataSizeInBytes) { this.fileCount = requireNonNull(fileCount, "fileCount is null"); fileCount.ifPresent(count -> checkArgument(count >= 0, "fileCount is negative: %d", count)); this.rowCount = requireNonNull(rowCount, "rowCount is null"); rowCount.ifPresent(count -> checkArgument(count >= 0, "rowCount is negative: %d", count)); this.inMemoryDataSizeInBytes = requireNonNull(inMemoryDataSizeInBytes, "inMemoryDataSizeInBytes is null"); inMemoryDataSizeInBytes.ifPresent(size -> checkArgument(size >= 0, "inMemoryDataSizeInBytes is negative: %d", size)); this.onDiskDataSizeInBytes = requireNonNull(onDiskDataSizeInBytes, "onDiskDataSizeInBytes is null"); onDiskDataSizeInBytes.ifPresent(size -> checkArgument(size >= 0, "onDiskDataSizeInBytes is negative: %d", size)); }
Source:
<code>public <VT> MessageOut<T> withParameter(ParameterType type, VT value) { <START> List<Object> newParameters = new ArrayList<>(parameters.size() + 3); <END> newParameters.addAll(parameters); newParameters.add(type); newParameters.add(value); return new MessageOut<T>(verb, payload, serializer, newParameters); }</code><technical_language>I tuple size 3. fix it</technical_language>

Target:
public <VT> MessageOut<T> withParameter(ParameterType type, VT value) { List<Object> newParameters = new ArrayList<>(parameters.size() + 2); newParameters.addAll(parameters); newParameters.add(type); newParameters.add(value); return new MessageOut<T>(verb, payload, serializer, newParameters); }
Source:
<code>public MapValue properties() { MapValue m = properties; if ( m == null ) { <START> synchronized ( propLock ) <END> { m = properties; if ( m == null ) { m = properties = ValueUtils.asMapValue( node.getAllProperties() ); } } } return m; }</code><technical_language>I remember talking decoupling synchronization this class, I completely remove synchronization solve regression benchmarks I ran, i september something. I messed up, I love some benchmark result confirm this fix</technical_language>

Target:
public MapValue properties() { MapValue m = properties; if ( m == null ) { synchronized ( this ) { m = properties; if ( m == null ) { m = properties = ValueUtils.asMapValue( node.getAllProperties() ); } } } return m; }
Source:
<code>private void onComplete() { try { final MetricsFile<IlluminaBasecallingMetrics, Comparable<?>> file = getMetricsFile(); final IlluminaMetricCounts allLaneCounts = new IlluminaMetricCounts(null, null, LANE); for (final String s : barcodeToMetricCounts.keySet()) { final IlluminaMetricCounts counts = barcodeToMetricCounts.get(s); counts.addMetricsToFile(file); allLaneCounts.addIlluminaMetricCounts(counts); } <START> if (!barcodeToMetricCounts.keySet().contains("")) <END> allLaneCounts.addMetricsToFile(file); file.write(OUTPUT); } catch (final Exception ex) { throw new PicardException("Error writing output file " + OUTPUT.getPath(), ex); } }</code><technical_language>{ }</technical_language>

Target:
private void onComplete() { try { final MetricsFile<IlluminaBasecallingMetrics, Comparable<?>> file = getMetricsFile(); final IlluminaMetricCounts allLaneCounts = new IlluminaMetricCounts(null, null, LANE); for (final String s : barcodeToMetricCounts.keySet()) { final IlluminaMetricCounts counts = barcodeToMetricCounts.get(s); counts.addMetricsToFile(file); allLaneCounts.addIlluminaMetricCounts(counts); } if (!barcodeToMetricCounts.keySet().contains("")) { allLaneCounts.addMetricsToFile(file); } file.write(OUTPUT); } catch (final Exception ex) { throw new PicardException("Error writing output file " + OUTPUT.getPath(), ex); } }
Source:
<code>buildJobUUID(Configuration conf, JobID jobId) throws PathCommitException { String jobUUID = conf.getTrimmed(FS_S3A_COMMITTER_UUID, ""); if (!jobUUID.isEmpty()) { return Pair.of(jobUUID, JobUUIDSource.CommitterUUIDProperty); } jobUUID = conf.getTrimmed(SPARK_WRITE_UUID, ""); if (!jobUUID.isEmpty()) { return Pair.of(jobUUID, JobUUIDSource.SparkWriteUUID); } if (conf.getBoolean(FS_S3A_COMMITTER_REQUIRE_UUID, false)) { throw new PathCommitException("", E_NO_SPARK_UUID); } if (conf.getBoolean(FS_S3A_COMMITTER_GENERATE_UUID, false)) { String newId = UUID.randomUUID().toString(); <START> LOG.warn("No job ID in configuration; generating a randem ID: {}", <END> newId); return Pair.of(newId, JobUUIDSource.GeneratedLocally); } return Pair.of(jobId.toString(), JobUUIDSource.JobID); }</code><technical_language>nit: typo in "random"</technical_language>

Target:
buildJobUUID(Configuration conf, JobID jobId) throws PathCommitException { String jobUUID = conf.getTrimmed(FS_S3A_COMMITTER_UUID, ""); if (!jobUUID.isEmpty()) { return Pair.of(jobUUID, JobUUIDSource.CommitterUUIDProperty); } jobUUID = conf.getTrimmed(SPARK_WRITE_UUID, ""); if (!jobUUID.isEmpty()) { return Pair.of(jobUUID, JobUUIDSource.SparkWriteUUID); } if (conf.getBoolean(FS_S3A_COMMITTER_REQUIRE_UUID, DEFAULT_S3A_COMMITTER_REQUIRE_UUID)) { throw new PathCommitException("", E_NO_SPARK_UUID); } if (conf.getBoolean(FS_S3A_COMMITTER_GENERATE_UUID, DEFAULT_S3A_COMMITTER_GENERATE_UUID)) { String newId = UUID.randomUUID().toString(); LOG.warn("No job ID in configuration; generating a random ID: {}", newId); return Pair.of(newId, JobUUIDSource.GeneratedLocally); } return Pair.of(jobId.toString(), JobUUIDSource.JobID); }
Source:
<code>private static Filter[] partitionFilterWith(Filter current, Predicate<Filter> predicate) { if (current == null) { return new Filter[]{null, null}; } <START> System.out.println("[Filters/partitionFilterWith] 1 " + current); <END> current = pushDownNot(current); System.out.println("[Filters/partitionFilterWith] 2 " + current); current = convertToCNF(current); System.out.println("[Filters/partitionFilterWith] 3 " + current); List<Filter> support = Lists.newArrayList(); List<Filter> notSupport = Lists.newArrayList(); traverse(current, predicate, support, notSupport) ; return new Filter[]{andFilter(support), andFilter(notSupport)}; }</code><technical_language>this is test code? If so, remove please</technical_language>

Target:
private static Filter[] partitionFilterWith(Filter current, Predicate<Filter> predicate) { if (current == null) { return null; } current = pushDownNot(current); current = flatten(current); current = convertToCNF(current); current = flatten(current); List<Filter> bitmapIndexSupported = Lists.newArrayList(); List<Filter> bitmapIndexNotSupported = Lists.newArrayList(); traverse(current, predicate, bitmapIndexSupported, bitmapIndexNotSupported); return new Filter[]{andFilter(bitmapIndexSupported), andFilter(bitmapIndexNotSupported)}; }
Source:
<code>public void testTimeout() throws DatabaseFactoryException, ClassNotFoundException, InterruptedException, RecoveryException, RetryLimitExceededException, SQLException { final int socketTimeout = 60; final int loginTimeout = 30; final Properties properties = new Properties() { { setProperty(JDBC, config.jdbc); setProperty(USERNAME, config.username); setProperty(PASSWORD, config.password); setProperty(ENGINE, config.engine); setProperty(SCHEMA_POLICY, "create"); setProperty(SOCKET_TIMEOUT, Integer.toString(socketTimeout)); setProperty(LOGIN_TIMEOUT, Integer.toString(loginTimeout)); } }; final DatabaseEngine de = DatabaseFactory.getConnection(properties); final int connectionTimeoutInMs = de.getConnection().getNetworkTimeout(); <START> assertEquals("timeout in db connection ok?", socketTimeout * 1000, connectionTimeoutInMs); <END> }</code><technical_language>Error message more specific: "Is timeout of DB connection expected?"</technical_language>

Target:
public void testTimeout() throws DatabaseFactoryException, ClassNotFoundException, InterruptedException, RecoveryException, RetryLimitExceededException, SQLException { final int socketTimeout = 60; final int loginTimeout = 30; final Properties properties = new Properties() { { setProperty(JDBC, config.jdbc); setProperty(USERNAME, config.username); setProperty(PASSWORD, config.password); setProperty(ENGINE, config.engine); setProperty(SCHEMA_POLICY, "create"); setProperty(SOCKET_TIMEOUT, Integer.toString(socketTimeout)); setProperty(LOGIN_TIMEOUT, Integer.toString(loginTimeout)); } }; final DatabaseEngine de = DatabaseFactory.getConnection(properties); final int connectionTimeoutInMs = de.getConnection().getNetworkTimeout(); assertEquals("Is the timeout of the DB connection the expected?", socketTimeout * 1000, connectionTimeoutInMs); }
Source:
<code>public boolean shouldThrottle(RestRequest restRequest) { boolean shouldThrottle; RejectThrottler throttler = quotaMap.get(restRequest.getRestMethod()); shouldThrottle = (throttler != null && throttler.shouldThrottle(1)); if (!shouldThrottle && hardwareThresholdMap.containsKey(HardwareResource.MEMORY)) { shouldThrottle = !hardwareThresholdMap.get(HardwareResource.MEMORY) .meetRequirement((long) hardwareUsageMeter.getMemoryPercentage()); if (shouldThrottle) { logger.warn("Throttle because of Memory: {}%", hardwareUsageMeter.getMemoryPercentage()); } } if (!shouldThrottle && hardwareThresholdMap.containsKey(HardwareResource.CPU)) { <START> shouldThrottle = !hardwareThresholdMap.get(HardwareResource.MEMORY) <END> .meetRequirement((long) hardwareUsageMeter.getCpuPercentage()); if (shouldThrottle) { logger.warn("Throttle because of CPU: {}%", hardwareUsageMeter.getCpuPercentage()); } } return shouldThrottle; }</code><technical_language>do hardwareThresholdMap.get(HardwareResource.CPU)</technical_language>

Target:
public boolean shouldThrottle(RestRequest restRequest) { boolean shouldThrottle; RejectThrottler throttler = quotaMap.get(restRequest.getRestMethod()); shouldThrottle = (throttler != null && throttler.shouldThrottle(1)); for (HardwareResource hardwareResource : HardwareResource.values()) { if (!shouldThrottle && hardwareThresholdMap.containsKey(hardwareResource)) { shouldThrottle = !hardwareThresholdMap.get(hardwareResource) .meetRequirement((long) hardwareUsageMeter.getHardwareResourcePercentage(hardwareResource)); if (shouldThrottle) { logger.warn("Throttle because of : {}%", hardwareResource, hardwareUsageMeter.getHardwareResourcePercentage(hardwareResource)); } } } return shouldThrottle; }
Source:
<code>public void search_shouldReturnAllRadiologyReportsIncludingDiscontinuedMatchingTheSearchQueryIfIncludeAllIsSet() throws Exception { MockHttpServletRequest request = request(RequestMethod.GET, getURI()); request.setParameter(RadiologyReportSearchHandler.REQUEST_PARAM_PRINCIPAL_RESULT_INTERPRETER, PROVIDER_WITH_RADIOLOGY_REPORTS); request.setParameter(RestConstants.REQUEST_PROPERTY_FOR_INCLUDE_ALL, "true"); SimpleObject result = deserialize(handle(request)); assertNotNull(result); List<Object> hits = (List<Object>) result.get("results"); <START> assertThat(hits.size(), is(3)); <END> }</code><technical_language>@Schwasrz94 test get discontinued reports in dataset should. remark in service</technical_language>

Target:
public void search_shouldReturnAllRadiologyReportsIncludingDiscontinuedMatchingTheSearchQueryIfIncludeAllIsSet() throws Exception { MockHttpServletRequest request = request(RequestMethod.GET, getURI()); request.setParameter(RadiologyReportSearchHandler.REQUEST_PARAM_PRINCIPAL_RESULT_INTERPRETER, PROVIDER_WITH_RADIOLOGY_REPORTS); request.setParameter(RestConstants.REQUEST_PROPERTY_FOR_INCLUDE_ALL, "true"); request.setParameter("v", Representation.FULL.getRepresentation()); SimpleObject result = deserialize(handle(request)); assertNotNull(result); List<Object> hits = (List<Object>) result.get("results"); assertThat(hits.size(), is(3)); assertThat(PropertyUtils.getProperty(hits.get(2), "uuid"), is(RADIOLOGY_REPORT_UUID_OF_DISCONTINUED)); assertThat(PropertyUtils.getProperty(hits.get(2), "reportStatus"), is(RadiologyReportStatus.DISCONTINUED.toString())); }
Source:
<code>public void testProcessCommonProperties() { NodeDetailsDeriver deriver = new NodeDetailsDeriver(); Trace trace = new Trace(); Consumer consumer = new Consumer(); consumer.setEndpointType("HTTP"); consumer.getProperties().add(new Property(Constants.PROP_BUILD_STAMP, "myBuild")); consumer.getProperties().add(new Property(Constants.PROP_PRINCIPAL, "jdoe")); trace.getNodes().add(consumer); Component component = new Component(); component.getProperties().add(new Property(Constants.PROP_SERVICE_NAME, "myService")); component.getProperties().add(new Property("LocalProp", "LocalValue")); consumer.getNodes().add(component); List<NodeDetails> details = null; try { details = deriver.processOneToMany(null, trace); <START> } catch (Exception e) { <END> fail("Failed: " + e); } assertNotNull(details); assertEquals(2, details.size()); assertEquals(3, details.get(0).getProperties().size()); assertEquals(4, details.get(1).getProperties().size()); }</code><technical_language>This test error</technical_language>

Target:
public void testProcessCommonProperties() throws RetryAttemptException { NodeDetailsDeriver deriver = new NodeDetailsDeriver(); Trace trace = new Trace(); Property p1 = new Property(Constants.PROP_BUILD_STAMP, "myBuild"); Property p2 = new Property(Constants.PROP_PRINCIPAL, "jdoe"); Property p3 = new Property(Constants.PROP_SERVICE_NAME, "myService"); Property p4 = new Property("LocalProp", "LocalValue"); Consumer consumer = new Consumer(); consumer.setEndpointType("HTTP"); consumer.getProperties().add(p1); consumer.getProperties().add(p2); trace.getNodes().add(consumer); Component component1 = new Component(); component1.getProperties().add(p3); consumer.getNodes().add(component1); Component component2 = new Component(); component2.getProperties().add(p4); component1.getNodes().add(component2); List<NodeDetails> details = deriver.processOneToMany(null, trace); assertEquals(3, details.size()); assertEquals(new HashSet<>(Arrays.asList(p1,p2,p3,p4)), details.get(0).getProperties()); assertEquals(new HashSet<>(Arrays.asList(p1,p2,p3)), details.get(1).getProperties()); assertEquals(new HashSet<>(Arrays.asList(p1,p2,p3,p4)), details.get(2).getProperties()); }
Source:
<code>public static <START> HashMap<String, <END> Integer> getLoginUserIds() { TypeToken<HashMap<String, Integer>> type = new TypeToken<HashMap<String, Integer>>(){}; return GsonUnmarshaller.unmarshal(type, getString(R.string.preference_key_login_user_id_map, "{}")); }</code><technical_language>this return a Map instead of a HashMap implementation</technical_language>

Target:
public static Map<String, Integer> getLoginUserIds() { TypeToken<HashMap<String, Integer>> type = new TypeToken<HashMap<String, Integer>>(){}; return GsonUnmarshaller.unmarshal(type, getString(R.string.preference_key_login_user_id_map, "{}")); }
Source:
<code>public void construct() throws InvalidGridFileException { builder.createNewEmptyGrid(); GridDimension gridDim = readGridFromFile(); placeItemsOnBoard(startingCoordinates, gridDim.getWidth(), gridDim.getHeight()); if (!isValidGrid(grid)) { <START> builder.createNewEmptyGrid(); <END> throw new InvalidGridFileException("The specified grid was not valid"); } }</code><technical_language>reset instance fields</technical_language>

Target:
public void construct() throws InvalidGridFileException { try { reset(); } catch (FileNotFoundException e1) { throw new InvalidGridFileException("file not found"); } GridDimension gridDim = readGridFromFile(); placeItemsOnBoard(startingCoordinates, gridDim.getWidth(), gridDim.getHeight()); if (!isValidGrid(grid)) { try { reset(); } catch (FileNotFoundException e) { } throw new InvalidGridFileException("The specified grid was not valid"); } }
Source:
<code>public void testGetAllWithQuery() { List<NetworkView> result = dao.getAllWithQuery(String.format("SELECT * FROM network_view where network_id = '%s'", FixturesTool.EXISTING_NETWORK_ID)); <START> assertEquals(FixturesTool.EXISTING_NETWORK_ID, result.get(0).getNetwork().getId()); <END> }</code><technical_language>check list is empty</technical_language>

Target:
public void testGetAllWithQuery() { List<NetworkView> result = dao.getAllWithQuery(String.format("SELECT * FROM network_view where id = '%s'", FixturesTool.EXISTING_NETWORK_ID)); assertFalse(result.isEmpty()); assertEquals(FixturesTool.EXISTING_NETWORK_ID, result.get(0).getNetwork().getId()); }
Source:
<code>public RowIterator(GroupByQuery query, final Cursor cursor, ByteBuffer metricsBuffer, GroupByQueryConfig config) { this.query = query; this.cursor = cursor; this.metricsBuffer = metricsBuffer; this.config = config; unprocessedKeys = null; delegate = Iterators.emptyIterator(); dimensionSpecs = query.getDimensions(); dimensions = Lists.newArrayListWithExpectedSize(dimensionSpecs.size()); dimNames = Lists.newArrayListWithExpectedSize(dimensionSpecs.size()); <START> final Set<String> optimizedDims = optimizedExtractionDims(query, true); <END> for (int i = 0; i < dimensionSpecs.size(); ++i) { final DimensionSpec dimSpec = dimensionSpecs.get(i); final String dimension = dimSpec.getDimension(); final DimensionSelector selector = cursor.makeDimensionSelector( dimension, optimizedDims.contains(dimension) ? null : dimSpec.getExtractionFn() ); if (selector != null) { dimensions.add(selector); dimNames.add(dimSpec.getOutputName()); } } aggregatorSpecs = query.getAggregatorSpecs(); aggregators = new BufferAggregator[aggregatorSpecs.size()]; metricNames = new String[aggregatorSpecs.size()]; sizesRequired = new int[aggregatorSpecs.size()]; for (int i = 0; i < aggregatorSpecs.size(); ++i) { AggregatorFactory aggregatorSpec = aggregatorSpecs.get(i); aggregators[i] = aggregatorSpec.factorizeBuffered(cursor); metricNames[i] = aggregatorSpec.getName(); sizesRequired[i] = aggregatorSpec.getMaxIntermediateSize(); } }</code><technical_language>I changes required if rewrite query</technical_language>

Target:
public RowIterator(GroupByQuery query, final Cursor cursor, ByteBuffer metricsBuffer, GroupByQueryConfig config) { this.query = query; this.cursor = cursor; this.metricsBuffer = metricsBuffer; this.config = config; unprocessedKeys = null; delegate = Iterators.emptyIterator(); dimensionSpecs = query.getDimensions(); dimensions = Lists.newArrayListWithExpectedSize(dimensionSpecs.size()); dimNames = Lists.newArrayListWithExpectedSize(dimensionSpecs.size()); for (int i = 0; i < dimensionSpecs.size(); ++i) { final DimensionSpec dimSpec = dimensionSpecs.get(i); final DimensionSelector selector = cursor.makeDimensionSelector( dimSpec.getDimension(), dimSpec.getExtractionFn() ); if (selector != null) { dimensions.add(selector); dimNames.add(dimSpec.getOutputName()); } } aggregatorSpecs = query.getAggregatorSpecs(); aggregators = new BufferAggregator[aggregatorSpecs.size()]; metricNames = new String[aggregatorSpecs.size()]; sizesRequired = new int[aggregatorSpecs.size()]; for (int i = 0; i < aggregatorSpecs.size(); ++i) { AggregatorFactory aggregatorSpec = aggregatorSpecs.get(i); aggregators[i] = aggregatorSpec.factorizeBuffered(cursor); metricNames[i] = aggregatorSpec.getName(); sizesRequired[i] = aggregatorSpec.getMaxIntermediateSize(); } }
Source:
<code>protected String getPackageLocation() throws IOException { <START> return "com/puppycrawl/tools/checkstyle"; <END> }</code><technical_language>checkstyleanttask folder ant, this package location be: com/puppycrawl/tools/checkstyle/ant/checkstyleanttask</technical_language>

Target:
protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/ant/checkstyleanttask/"; }
Source:
<code>public void writeWithDefaultConfiguration() throws Exception { TAQ.Quote quote = new TAQ.Quote(); quote.date = "2016-01-01"; quote.timestampMillis = 8 * 60 * 60 * 1000; quote.instrument = "FOO"; quote.bidPrice = 100.50; quote.bidSize = 1000; quote.askPrice = 100.75; quote.askSize = 250; try ( ByteArrayOutputStream out = new ByteArrayOutputStream(); <START> TAQWriter writer = new TAQWriter(out);) { <END> writer.write(quote); writer.flush(); String output = "" + "Date\t" + "Timestamp\t" + "Instrument\t" + "Record Type\t" + "Bid Price\t" + "Bid Size\t" + "Ask Price\t" + "Ask Size\t" + "Trade Price\t" + "Trade Size\t" + "Trade Side\n" + "2016-01-01\t" + "08:00:00.000\t" + "FOO\t" + "Q\t" + "100.50\t" + "1000\t" + "100.75\t" + "250\t" + "\t" + "\t" + "\n"; assertEquals(output, out.toString("US-ASCII")); } }</code><technical_language>I prefer this formatted follows: java try (ByteArrayOutputStream out = new ByteArrayOutputStream(); TAQWriter writer = new TAQWriter(out)) { writer.write(quote); writer.flush(); ... do think</technical_language>

Target:
public void writeWithDefaultConfiguration() throws Exception { TAQ.Quote quote = new TAQ.Quote(); quote.date = "2016-01-01"; quote.timestampMillis = 8 * 60 * 60 * 1000; quote.instrument = "FOO"; quote.bidPrice = 100.50; quote.bidSize = 1000; quote.askPrice = 100.75; quote.askSize = 250; try (ByteArrayOutputStream out = new ByteArrayOutputStream(); TAQWriter writer = new TAQWriter(out)) { writer.write(quote); writer.flush(); String output = "" + "Date\t" + "Timestamp\t" + "Instrument\t" + "Record Type\t" + "Bid Price\t" + "Bid Size\t" + "Ask Price\t" + "Ask Size\t" + "Trade Price\t" + "Trade Size\t" + "Trade Side\n" + "2016-01-01\t" + "08:00:00.000\t" + "FOO\t" + "Q\t" + "100.50\t" + "1000\t" + "100.75\t" + "250\t" + "\t" + "\t" + "\n"; assertEquals(output, out.toString("US-ASCII")); } }
Source:
<code>private GatewayAccountEntity buildTestGatewayAccountWith3DSEntity() { GatewayAccountEntity gatewayAccount = new GatewayAccountEntity(); gatewayAccount.setId(1L); gatewayAccount.setGatewayName("epdq"); gatewayAccount.setRequires3ds(true); gatewayAccount.setIntegrationVersion3ds(1); <START> gatewayAccount.setCredentials(ImmutableMap.of( <END> CREDENTIALS_MERCHANT_ID, "merchant-id", CREDENTIALS_USERNAME, "username", CREDENTIALS_PASSWORD, "password", CREDENTIALS_SHA_IN_PASSPHRASE, "sha-passphrase" )); gatewayAccount.setType(TEST); return gatewayAccount; }</code><technical_language>built-in Map.of( ) here</technical_language>

Target:
private GatewayAccountEntity buildTestGatewayAccountWith3DSEntity() { GatewayAccountEntity gatewayAccount = new GatewayAccountEntity(); gatewayAccount.setId(1L); gatewayAccount.setGatewayName("epdq"); gatewayAccount.setRequires3ds(true); gatewayAccount.setIntegrationVersion3ds(1); gatewayAccount.setCredentials(Map.of( CREDENTIALS_MERCHANT_ID, "merchant-id", CREDENTIALS_USERNAME, "username", CREDENTIALS_PASSWORD, "password", CREDENTIALS_SHA_IN_PASSPHRASE, "sha-passphrase" )); gatewayAccount.setType(TEST); return gatewayAccount; }
Source:
<code>Subject cacheAndReturnSubject(ServerSession session) throws SecurityServiceException { UPAuthenticationToken usernamePasswordToken = new UPAuthenticationToken(session.getUsername(), session.getPassword()); Subject subject = securityManager.getSubject(usernamePasswordToken); <START> SUBJECT_CACHE.put(session.getUsername(), subject); <END> return subject; }</code><technical_language>is cache modified here? This is loader function Guava update cache returned here</technical_language>

Target:
Subject cacheAndReturnSubject(ServerSession session) throws SecurityServiceException { UPAuthenticationToken usernamePasswordToken = new UPAuthenticationToken(session.getUsername(), session.getPassword()); return securityManager.getSubject(usernamePasswordToken); }
Source:
<code>public Sequence<T> run(final Query<T> query, final Map<String, Object> responseContext) { final int priority = QueryContexts.getPriority(query, 0); final ListenableFuture<Sequence<T>> future = executor.submit(new AbstractPrioritizedCallable<Sequence<T>>(priority) { @Override public Sequence<T> call() throws Exception { return baseRunner.run(query, responseContext); } }); queryWatcher.registerQuery(query, future); return new LazySequence<>(new Supplier<Sequence<T>>() { @Override public Sequence<T> get() { try { final long timeout = QueryContexts.getTimeout(query); <START> if (timeout == 0) { <END> return future.get(); } else { return future.get(timeout, TimeUnit.MILLISECONDS); } } catch (ExecutionException | InterruptedException | TimeoutException ex) { throw Throwables.propagate(ex); } } }); }</code><technical_language>QueryContexts.DEFAULT_TIMEOUT? add a method QueryContext.isNoTimeout(timeout)</technical_language>

Target:
public Sequence<T> run(final Query<T> query, final Map<String, Object> responseContext) { final int priority = QueryContexts.getPriority(query); final ListenableFuture<Sequence<T>> future = executor.submit(new AbstractPrioritizedCallable<Sequence<T>>(priority) { @Override public Sequence<T> call() throws Exception { return baseRunner.run(query, responseContext); } }); queryWatcher.registerQuery(query, future); return new LazySequence<>(new Supplier<Sequence<T>>() { @Override public Sequence<T> get() { try { if (QueryContexts.hasTimeout(query)) { return future.get(QueryContexts.getTimeout(query), TimeUnit.MILLISECONDS); } else { return future.get(); } } catch (ExecutionException | InterruptedException | TimeoutException ex) { throw Throwables.propagate(ex); } } }); }
Source:
<code>CustomizingStatementHandler(Class<?> type, Method method) { this.sqlObjectType = type; this.method = method; final Stream<BoundCustomizer> typeCustomizers = concat(Stream.of(type.getInterfaces()), Stream.of(type)) .flatMap(t -> annotationsFor(t)) .map(a -> instantiateFactory(a).createForType(a, type)) .map(BoundCustomizer::of); final Stream<BoundCustomizer> methodCustomizers = annotationsFor(method) .map(a -> instantiateFactory(a).createForMethod(a, type, method)) .map(BoundCustomizer::of); final Stream<BoundCustomizer> parameterCustomizers = parameterCustomizers(type, method); statementCustomizers = Stream.of(typeCustomizers, methodCustomizers, parameterCustomizers) <START> .flatMap(Function.identity()) <END> .collect(Collectors.toList()); }</code><technical_language>For personal taste, .reduce(Stream.empty(), Stream::concat) more natural</technical_language>

Target:
CustomizingStatementHandler(Class<?> type, Method method) { this.sqlObjectType = type; this.method = method; final Stream<BoundCustomizer> typeCustomizers = concat(Stream.of(type.getInterfaces()), Stream.of(type)) .flatMap(t -> annotationsFor(t)) .map(a -> instantiateFactory(a).createForType(a, type)) .map(BoundCustomizer::of); final Stream<BoundCustomizer> methodCustomizers = annotationsFor(method) .map(a -> instantiateFactory(a).createForMethod(a, type, method)) .map(BoundCustomizer::of); final Stream<BoundCustomizer> parameterCustomizers = parameterCustomizers(type, method); statementCustomizers = Stream.of(typeCustomizers, methodCustomizers, parameterCustomizers) .reduce(Stream.empty(), Stream::concat) .collect(Collectors.toList()); }
Source:
<code>public void shouldNotifyEventWhenUpdateAnnotation() { Annotation annotation = createAnnotationAndAddSubscription("CommentUpdated", "Modification"); captureAndVerifyAnnotationEventNotification(() -> { annotation.setText("I update the annotation"); annotationService.updateAnnotation(session, annotation.getId(), annotation); return session.getDocument(new IdRef(annotation.getId())); <START> <END> }, COMMENT_UPDATED, DOCUMENT_UPDATED, 1); }</code><technical_language>Useless blank line</technical_language>

Target:
public void shouldNotifyEventWhenUpdateAnnotation() { Annotation annotation = createAnnotationAndAddSubscription("CommentUpdated", "Modification"); captureAndVerifyAnnotationEventNotification(() -> { annotation.setText("I update the annotation"); annotationService.updateAnnotation(session, annotation.getId(), annotation); return session.getDocument(new IdRef(annotation.getId())); }, COMMENT_UPDATED, DOCUMENT_UPDATED); }
Source:
<code>public void stop() { startStopLock.writeLock().lock(); if (started) { try { LOG.info("LookupReferencesManager is stopping."); started = false; if (exec != null) { exec.shutdownNow(); exec = null; } for (Map.Entry<String, LookupExtractorFactoryContainer> e : lookupMap.entrySet()) { try { LOG.info("Closing lookup [%s]", e.getKey()); if (!e.getValue().getLookupExtractorFactory().close()) { LOG.error("Failed to close lookup [%s]."); } } catch (Exception ex) { LOG.error(ex, "Failed to close lookup [%s].", e.getKey()); } } lookupMap.clear(); } <START> finally { <END> startStopLock.writeLock().unlock(); } LOG.info("LookupReferencesManager is stopped."); } else { startStopLock.writeLock().unlock(); } }</code><technical_language>finally block if statement</technical_language>

Target:
public void stop() { if (!lifecycleLock.canStop()) { throw new ISE("can't stop."); } LOG.info("LookupReferencesManager is stopping."); if (!testMode) { mainThread.interrupt(); try { mainThread.join(); } catch (InterruptedException ex) { throw new ISE("failed to stop, mainThread couldn't finish."); } } for (Map.Entry<String, LookupExtractorFactoryContainer> e : stateRef.get().lookupMap.entrySet()) { try { LOG.info("Closing lookup [%s]", e.getKey()); if (!e.getValue().getLookupExtractorFactory().close()) { LOG.error("Failed to close lookup [%s].", e.getKey()); } } catch (Exception ex) { LOG.error(ex, "Failed to close lookup [%s].", e.getKey()); } } LOG.info("LookupReferencesManager is stopped."); }
Source:
<code><START> public final byte[] getRawGpgSignature() { <END> final byte[] raw = buffer; final byte[] header = {'g', 'p', 'g', 's', 'i', 'g'}; final int start = RawParseUtils.headerStart(header, raw, 0); if (start < 0) return null; final int end = RawParseUtils.headerEnd(raw, start); return Arrays.copyOfRange(raw, start, end); }</code><technical_language>this method need public</technical_language>

Target:
public final @Nullable byte[] getRawGpgSignature() { final byte[] raw = buffer; final byte[] header = {'g', 'p', 'g', 's', 'i', 'g'}; final int start = RawParseUtils.headerStart(header, raw, 0); if (start < 0) { return null; } final int end = RawParseUtils.headerEnd(raw, start); return Arrays.copyOfRange(raw, start, end); }
Source:
<code>public boolean isCompact() { return compact; <START> } <END></code><technical_language>wondering if reuse reference for this: java private static final COMPACT = new Object(); ... this.reference = (offset == 0 && length == base.length) ? COMPACT : null; ... public boolean isCompact() { return reference == COMPACT; }</technical_language>

Target:
public boolean isCompact() { return reference == COMPACT; }
Source:
<code>private static boolean isCorrectJavadocPosition(DetailAST blockComment) { DetailAST sibling = blockComment; <START> do { <END> sibling = sibling.getNextSibling(); if (sibling != null) { if (sibling.getType() == TokenTypes.BLOCK_COMMENT_BEGIN) { if (isJavadocComment(getBlockCommentContent(sibling))) { break; } } else if (sibling.getType() != TokenTypes.SINGLE_LINE_COMMENT) { sibling = null; } } } while (sibling != null); return sibling == null && (BlockCommentPosition.isOnType(blockComment) || BlockCommentPosition.isOnMember(blockComment)); }</code><technical_language>more sense change this do while() while () {}? if weird if (sibling != null) { } while (sibling != null);</technical_language>

Target:
private static boolean isCorrectJavadocPosition(DetailAST blockComment) { DetailAST sibling = blockComment.getNextSibling(); while (sibling != null) { if (sibling.getType() == TokenTypes.BLOCK_COMMENT_BEGIN) { if (isJavadocComment(getBlockCommentContent(sibling))) { break; } sibling = sibling.getNextSibling(); } else if (sibling.getType() == TokenTypes.SINGLE_LINE_COMMENT) { sibling = sibling.getNextSibling(); } else { sibling = null; } } return sibling == null && (BlockCommentPosition.isOnType(blockComment) || BlockCommentPosition.isOnMember(blockComment)); }
Source:
<code>public void gerritEvent(GerritEvent event) { if (!isSupported()) { return; } if (event instanceof GerritTriggeredEvent) { logger.info("Recording timestamp due to an event for server: {}", event, serverName); GerritTriggeredEvent triggeredEvent = (GerritTriggeredEvent)event; persist(triggeredEvent); if (!playBackComplete) { <START> if (!receivedEventCache.contains(event)) { <END> receivedEventCache.add((ChangeBasedEvent)event); logger.debug("Added event to received cache for server: {}", event, serverName); } else { logger.debug("Event ALREADY in received cache for server: {}", event, serverName); } } else { receivedEventCache = new Vector<ChangeBasedEvent>(); logger.debug("Playback complete...will NOT add event to received cache for server: {}" , event, serverName); } } }</code><technical_language>a synchronizedSet instead complexity</technical_language>

Target:
public void gerritEvent(GerritEvent event) { if (!isSupported()) { return; } if (event instanceof GerritTriggeredEvent) { logger.debug("Recording timestamp due to an event for server: {}", event, serverName); GerritTriggeredEvent triggeredEvent = (GerritTriggeredEvent)event; persist(triggeredEvent); if (!playBackComplete) { boolean receivedEvtFound = false; synchronized (receivedEventCache) { Iterator<GerritTriggeredEvent> i = receivedEventCache.iterator(); while (i.hasNext()) { GerritTriggeredEvent rEvt = i.next(); if (rEvt.equals(triggeredEvent)) { receivedEvtFound = true; break; } } } if (!receivedEvtFound) { receivedEventCache.add(triggeredEvent); logger.debug("Added event to received cache for server: {}", event, serverName); } else { logger.debug("Event ALREADY in received cache for server: {}", event, serverName); } } else { receivedEventCache = Collections.synchronizedList(new ArrayList<GerritTriggeredEvent>()); logger.debug("Playback complete...will NOT add event to received cache for server: {}" , event, serverName); } } }
Source:
<code><START> private EditPreferencesPage openEmailSection(String wikiURL) { <END> getUrl(wikiURL + URLsContent.SPECIAL_EDITING_PREFERENCES_EMAIL); return this; }</code><technical_language>![MAJOR](<LINK_0> 'Severity: MAJOR') Remove this unused private "openEmailSection" method. [![rule](<LINK_1>](http://sonar-s4/coding_rules#rule_key=squid%3AUnusedPrivateMethod)</technical_language>

Target:
private EditPreferencesPage openEmailSection(String wikiURL) { getUrl(wikiURL + URLsContent.WIKI_DIR + URLsContent.SPECIAL_EDITING_PREFERENCES_EMAIL); return this; }
Source:
<code><START> public List<OrganizationMembership> getOrganizationMemberships(long id) { <END> return complete(submit(req("GET", tmpl("/users/{id}/organization_memberships.json").set("id", id)), handleList(OrganizationMembership.class, "organization_memberships"))); }</code><technical_language>PagedIterable instead of List? API return a next_page entry in JSON record, return a partial result for users organizations (e.g. consultants)</technical_language>

Target:
public Iterable<OrganizationMembership> getOrganizationMemberships(long id) { return new PagedIterable<OrganizationMembership>( tmpl("/users/{id}/organization_memberships.json").set("id", id), handleList(OrganizationMembership.class, "organization_memberships")); }
Source:
<code>public void testRestServerPrefixedSslConfigs() { Map<String, String> httpsListenerProps = new HashMap<String, String>() { { put(HTTPS_LISTENER_PREFIX + SslConfigs.SSL_KEY_PASSWORD_CONFIG, "ssl_key_password"); put(HTTPS_LISTENER_PREFIX + SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, "ssl_keystore"); put(HTTPS_LISTENER_PREFIX + SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, "ssk_keystore_password"); put(HTTPS_LISTENER_PREFIX + SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, "ssl_truststore"); put(HTTPS_LISTENER_PREFIX + SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, "ssl_truststore_password"); } }; Set<String> passwordConfigs = Stream.of( SslConfigs.SSL_KEY_PASSWORD_CONFIG, SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG ).map(key -> HTTPS_LISTENER_PREFIX + key) .collect(Collectors.toSet()); Map<String, Object> expectedListenerProps = httpsListenerProps.entrySet().stream() .collect(Collectors.toMap( entry -> entry.getKey().substring(HTTPS_LISTENER_PREFIX.length()), entry -> passwordConfigs.contains(entry.getKey()) ? new Password(entry.getValue()) : entry.getValue() )); Map<String, String> props = new HashMap<String, String>() { { put(WorkerConfig.KEY_CONVERTER_CLASS_CONFIG, "org.apache.kafka.connect.json.JsonConverter"); put(WorkerConfig.VALUE_CONVERTER_CLASS_CONFIG, "org.apache.kafka.connect.json.JsonConverter"); <START> put(StandaloneConfig.OFFSET_STORAGE_FILE_FILENAME_CONFIG, "/tmp/foad"); <END> putAll(httpsListenerProps); } }; StandaloneConfig config = new StandaloneConfig(props); Map<String, Object> actualHttpsListenerProps = config.valuesWithPrefixAllOrNothing(HTTPS_LISTENER_PREFIX); assertEquals(expectedListenerProps, actualHttpsListenerProps); }</code><technical_language>suggestion put(StandaloneConfig.OFFSET_STORAGE_FILE_FILENAME_CONFIG, "/tmp/foo");</technical_language>

Target:
public void testRestServerPrefixedSslConfigs() { Map<String, String> workerProps = baseWorkerProps(); Map<String, Object> expectedSslProps = sslProps(); workerProps.putAll(withStringValues(expectedSslProps, HTTPS_LISTENER_PREFIX)); StandaloneConfig config = new StandaloneConfig(workerProps); assertEquals(expectedSslProps, config.valuesWithPrefixAllOrNothing(HTTPS_LISTENER_PREFIX)); }
Source:
<code>void localVars() { boolean a; Object b; manyStatementsLater(); <START> inTheGalaxyFarAway(); <END> variablesAreInitialized(); a = true; if (a) { } b = new Object(); if (b != null) { } try { Thread.sleep(10); } catch (Exception ex) { if (ex != null) { } } for (Integer i : Arrays.asList(1,2,null)) { if (i == null) { } if (i != null) { } } }</code><technical_language>Missing a "Far" <LINK_0> :wink:</technical_language>

Target:
void localVars() { boolean a; Object b; manyStatementsLater(); inTheGalaxyFarFarAway(); variablesAreInitialized(); a = true; if (a) { } b = new Object(); if (b != null) { } try { Thread.sleep(10); } catch (Exception ex) { if (ex != null) { } } for (Integer i : Arrays.asList(1,2,null)) { if (i == null) { } if (i != null) { } } }
Source:
<code>public boolean equals(Object obj) { <START> if (obj instanceof ApplicationCredentials) { <END> ApplicationCredentials other = (ApplicationCredentials) obj; return Objects.equal(this.getApiKey(), other.getApiKey()); } return false; }</code><technical_language>instance equality. sense credentials API key</technical_language>

Target:
public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof ApplicationCredentials) { ApplicationCredentials other = (ApplicationCredentials) obj; return this.getApiKey().equals(other.getApiKey()); } return false; }