auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void vmTypeChanged(VmType vmType) { if (basedOnCustomInstanceType()) { getModel().getIsSoundcardEnabled().setEntity(vmType == VmType.Desktop && !clusterHasPpcArchitecture()); } getModel().getAllowConsoleReconnect().setEntity(vmType == VmType.Server); if (vmType == VmType.Server) { getModel().getIoThreadsEnabled().setEntity(true); } if (vmType == VmType.HighPerformance) { getModel().getIsHeadlessModeEnabled().setEntity(true); getModel().getIsConsoleDeviceEnabled().setEntity(true); getModel().getUsbPolicy().setSelectedItem(UsbPolicy.DISABLED); getModel().getIsSmartcardEnabled().setEntity(false); getModel().getWatchdogModel().setSelectedItem(null); getModel().getWatchdogAction().setSelectedItem(getModel().getWatchdogAction().getItems().iterator().next()); getModel().getIsRngEnabled().setEntity(true); if (!clusterHasPpcArchitecture()) { getModel().getHostCpu().setEntity(true); } getModel().getMemoryBalloonDeviceEnabled().setEntity(false); getModel().getIoThreadsEnabled().setEntity(true); if (getModel().getMultiQueues().getIsAvailable()) { getModel().getMultiQueues().setEntity(true); } } else { getModel().getHostCpu().setEntity(false); } if (vmType == VmType.HighPerformance || isVmPinningConfigurationEnabled()) { getModel().getMigrationMode().setSelectedItem(MigrationSupport.IMPLICITLY_NON_MIGRATABLE); <START> } else { <END> getModel().getMigrationMode().setSelectedItem(MigrationSupport.MIGRATABLE); } }</code><technical_language>sense change migration mode MIGRATABLE if VM type is changed 'desktop' 'server'? I confusing, if user sets VM non-migratable changes type desktop server, change migration mode too</technical_language>

Target:
public void vmTypeChanged(VmType vmType) { if (basedOnCustomInstanceType()) { getModel().getIsSoundcardEnabled().setEntity(vmType == VmType.Desktop && !clusterHasPpcArchitecture()); } getModel().getAllowConsoleReconnect().setEntity(vmType == VmType.Server); if (vmType == VmType.Server) { getModel().getIoThreadsEnabled().setEntity(true); } if (vmType == VmType.HighPerformance) { getModel().getIsHeadlessModeEnabled().setEntity(true); getModel().getIsConsoleDeviceEnabled().setEntity(true); getModel().getUsbPolicy().setSelectedItem(UsbPolicy.DISABLED); getModel().getIsSmartcardEnabled().setEntity(false); getModel().getWatchdogModel().setSelectedItem(null); getModel().getWatchdogAction().setSelectedItem(getModel().getWatchdogAction().getItems().iterator().next()); getModel().getIsRngEnabled().setEntity(true); if (!clusterHasPpcArchitecture()) { getModel().getHostCpu().setEntity(true); } getModel().getMemoryBalloonDeviceEnabled().setEntity(false); getModel().getIoThreadsEnabled().setEntity(true); if (getModel().getMultiQueues().getIsAvailable()) { getModel().getMultiQueues().setEntity(true); } } else { getModel().getHostCpu().setEntity(false); } if (isVmHpOrPinningConfigurationEnabled()) { getModel().getMigrationMode().setSelectedItem(MigrationSupport.IMPLICITLY_NON_MIGRATABLE); } else { getModel().getMigrationMode().setSelectedItem(MigrationSupport.MIGRATABLE); } }
Source:
<code>private TimePartitionedShardReaderPolicy(Factory.Builder builder, MessageQueueMetadata metadata) { this.settings = metadata; this.pollingInterval = builder.pollingInterval; <START> catchupPollingInterval = builder.catchupPollingInterval; <END> shards = Lists.newArrayListWithCapacity(metadata.getPartitionCount() * metadata.getShardCount()); for (int i = 0; i < metadata.getPartitionCount(); i++) { for (int j = 0; j < metadata.getShardCount(); j++) { shards.add(new MessageQueueShard(metadata.getQueueName() + SEPARATOR + i + SEPARATOR + j, i, j)); } } List<MessageQueueShard> queues = Lists.newArrayList(); shardStats = Maps.newHashMapWithExpectedSize(shards.size()); for (MessageQueueShard shard : shards) { queues.add(shard); shardStats.put(shard.getName(), shard); } Collections.shuffle(queues); workQueue.addAll(queues); }</code><technical_language>add this. match :)</technical_language>

Target:
private TimePartitionedShardReaderPolicy(Factory.Builder builder, MessageQueueMetadata metadata) { this.settings = metadata; this.pollingInterval = builder.pollingInterval; this.catchupPollingInterval = builder.catchupPollingInterval; shards = Lists.newArrayListWithCapacity(metadata.getPartitionCount() * metadata.getShardCount()); for (int i = 0; i < metadata.getPartitionCount(); i++) { for (int j = 0; j < metadata.getShardCount(); j++) { shards.add(new MessageQueueShard(metadata.getQueueName() + SEPARATOR + i + SEPARATOR + j, i, j)); } } List<MessageQueueShard> queues = Lists.newArrayList(); shardStats = Maps.newHashMapWithExpectedSize(shards.size()); for (MessageQueueShard shard : shards) { queues.add(shard); shardStats.put(shard.getName(), shard); } Collections.shuffle(queues); workQueue.addAll(queues); }
Source:
<code>public Value nodeGetProperty( long nodeId, int propertyKeyId ) throws EntityNotFoundException { statement.assertOpen(); if ( propertyKeyId == StatementConstants.NO_SUCH_PROPERTY_KEY ) { return Values.NO_VALUE; } try ( Cursor<NodeItem> node = dataRead().nodeCursorById( statement, nodeId ) ) { <START> if ( propertyIsAllowed( propertyKeyId ) ) <END> { return dataRead().nodeGetProperty( statement, node.get(), propertyKeyId ); } else { return Values.NO_VALUE; } } }</code><technical_language>This check node cursor. need spend more time in OperationsFacade though... 3.4 out</technical_language>

Target:
public Value nodeGetProperty( long nodeId, int propertyKeyId ) throws EntityNotFoundException { statement.assertOpen(); if ( propertyKeyId == StatementConstants.NO_SUCH_PROPERTY_KEY ) { return Values.NO_VALUE; } try ( Cursor<NodeItem> node = dataRead().nodeCursorById( statement, nodeId ) ) { return dataRead().nodeGetProperty( statement, node.get(), propertyKeyId ); } }
Source:
<code>private void connectAllPlayersAndMonitors() { <START> logger.debug("MPD testing"); <END> for (String playerId : playerConfigCache.keySet()) { connect(playerId); } }</code><technical_language>please replace reasonable log statement</technical_language>

Target:
private void connectAllPlayersAndMonitors() { logger.debug("MPD binding connecting to players"); for (String playerId : playerConfigCache.keySet()) { connect(playerId); } }
Source:
<code>private static boolean derivesFrom(ICPPClassType derived, ICPPClassType target, IASTNode point, int maxdepth) { if (derived == target || derived.isSameType(target)) { return true; } if (maxdepth > 0) { for (ICPPBase cppBase : ClassTypeHelper.getBases(derived, point)) { IBinding base = cppBase.getBaseClass(); if (!(target instanceof ICPPSpecialization) && <START> (base instanceof ICPPSpecialization)) { <END> base = ((ICPPSpecialization) base).getSpecializedBinding(); } if (base instanceof ICPPClassType) { ICPPClassType tbase = (ICPPClassType) base; if (tbase.isSameType(target)) { return true; } if (derivesFrom(tbase, target, point, maxdepth - 1)) return true; } } } return false; }</code><technical_language>Remove redundant parentheses condition</technical_language>

Target:
private static boolean derivesFrom(ICPPClassType derived, ICPPClassType target, IASTNode point, int maxdepth) { if (derived == target || derived.isSameType(target)) { return true; } if (maxdepth > 0) { for (ICPPBase cppBase : ClassTypeHelper.getBases(derived, point)) { IBinding base = cppBase.getBaseClass(); if (!(target instanceof ICPPSpecialization) && base instanceof ICPPSpecialization) { base = ((ICPPSpecialization) base).getSpecializedBinding(); } if (base instanceof ICPPClassType) { ICPPClassType tbase = (ICPPClassType) base; if (tbase.isSameType(target)) { return true; } if (derivesFrom(tbase, target, point, maxdepth - 1)) return true; } } } return false; }
Source:
<code>@Test public void worksWithOldSchema() throws Exception { Schema.applyCqlFile(keyspace(), session(), "/zipkin2-schema.cql"); Schema.applyCqlFile(keyspace(), session(), "/zipkin2-schema-indexes-original.cql"); InetSocketAddress contactPoint = contactPoint(); try (CassandraStorage storage = CassandraStorage.newBuilder() .contactPoints(contactPoint.getHostString() + ":" + contactPoint.getPort()) .ensureSchema(false) .autocompleteKeys(asList("environment")) .keyspace(keyspace()).build()) { <START> storage.spanConsumer().accept(TestObjects.TRACE).execute(); <END> assertThat(storage.spanStore().getTrace(TestObjects.TRACE.get(0).traceId()).execute()) .containsExactlyInAnyOrderElementsOf(TestObjects.TRACE); assertThat(storage.autocompleteTags().getValues("environment").execute()) .isEmpty(); String serviceName = TestObjects.TRACE.get(0).localServiceName(); assertThat(storage.serviceAndSpanNames().getRemoteServiceNames(serviceName).execute()) .isEmpty(); } }</code><technical_language>) I totally forgot this</technical_language>

Target:
@Test public void worksWithOldSchema() throws Exception { Schema.applyCqlFile(keyspace(), session(), "/zipkin2-schema.cql"); Schema.applyCqlFile(keyspace(), session(), "/zipkin2-schema-indexes-original.cql"); InetSocketAddress contactPoint = contactPoint(); try (CassandraStorage storage = CassandraStorage.newBuilder() .contactPoints(contactPoint.getHostString() + ":" + contactPoint.getPort()) .ensureSchema(false) .autocompleteKeys(asList("environment")) .keyspace(keyspace()).build()) { storage.spanConsumer().accept(TestObjects.TRACE).execute(); assertThat(storage.spanStore().getTrace(TestObjects.TRACE.get(0).traceId()).execute()) .containsExactlyInAnyOrderElementsOf(TestObjects.TRACE); assertThat(storage.autocompleteTags().getValues("environment").execute()) .isEmpty(); String serviceName = TestObjects.TRACE.get(0).localServiceName(); assertThat(storage.serviceAndSpanNames().getRemoteServiceNames(serviceName).execute()) .isEmpty(); try { storage.spanStore().getTraces(QueryRequest.newBuilder() .endTs(TODAY) .lookback(DAY) .limit(10) .serviceName(serviceName) .remoteServiceName(CLIENT_SPAN.remoteServiceName()).build()).execute(); failBecauseExceptionWasNotThrown(IllegalArgumentException.class); } catch (IllegalArgumentException e) { assertThat(e).hasMessage( "remoteService=backend unsupported due to missing table remote_service_by_service"); } } }
Source:
<code>private void split() { mChildren = new ArrayList<PointQuadTree<T>>(); mChildren.add(new PointQuadTree<T>(mBounds.minX, mBounds.midX, mBounds.minY, mBounds.midY, mDepth + 1)); mChildren.add(new PointQuadTree<T>(mBounds.midX, mBounds.maxX, mBounds.minY, mBounds.midY, mDepth + 1)); mChildren.add(new PointQuadTree<T>(mBounds.minX, mBounds.midX, mBounds.midY, mBounds.maxY, mDepth + 1)); <START> mChildren.add(new PointQuadTree<T>(mBounds.midX, mBounds.maxX, mBounds.midY, mBounds.maxY, mDepth + 1)); <END> List<T> items = mItems; mItems = null; for (T item : items) { add(item); } }</code><technical_language>convinced this adds :) I set size 4. indent lines spaces instead of tabs</technical_language>

Target:
private void split() { mChildren = new ArrayList<PointQuadTree<T>>(4); mChildren.add(new PointQuadTree<T>(mBounds.minX, mBounds.midX, mBounds.minY, mBounds.midY, mDepth + 1)); mChildren.add(new PointQuadTree<T>(mBounds.midX, mBounds.maxX, mBounds.minY, mBounds.midY, mDepth + 1)); mChildren.add(new PointQuadTree<T>(mBounds.minX, mBounds.midX, mBounds.midY, mBounds.maxY, mDepth + 1)); mChildren.add(new PointQuadTree<T>(mBounds.midX, mBounds.maxX, mBounds.midY, mBounds.maxY, mDepth + 1)); List<T> items = mItems; mItems = null; for (T item : items) { add(item); } }
Source:
<code>public void test() throws Exception { TestSupportBinder binder = (TestSupportBinder) this.binderFactory.getBinder(null); Message<?> message = MessageBuilder.withPayload("hello").setHeader("route", "baz").build(); this.channels.input().send(message); <START> MessageChannel baz = binder.getChannelForName("baz"); <END> assertNotNull(baz); assertThat(collector.forChannel(baz), receivesPayloadThat(is("hello"))); message = MessageBuilder.withPayload("world").setHeader("route", "qux").build(); this.channels.input().send(message); MessageChannel qux = binder.getChannelForName("qux"); assertNotNull(qux); assertThat(collector.forChannel(qux), receivesPayloadThat(is("world"))); }</code><technical_language>commited: ![binder](<LINK_0> guess: Binder improvements</technical_language>

Target:
public void test() throws Exception { TestSupportBinder binder = (TestSupportBinder) this.binderFactory.getBinder(null); Message<?> message = MessageBuilder.withPayload("hello").setHeader("routeTo", "baz").build(); this.channels.input().send(message); MessageChannel baz = binder.getChannelForName("baz"); assertNotNull(baz); assertThat(collector.forChannel(baz), receivesPayloadThat(is("hello"))); message = MessageBuilder.withPayload("world").setHeader("routeTo", "qux").build(); this.channels.input().send(message); MessageChannel qux = binder.getChannelForName("qux"); assertNotNull(qux); assertThat(collector.forChannel(qux), receivesPayloadThat(is("world"))); }
Source:
<code>public void testPackageWithMainlineNetworkStackPermission() throws Exception { final PackageManager packageManager = mContext.getPackageManager(); assertNotNull(packageManager); int packageCount = 0; final PermissionInfo permissioninfo = packageManager.getPermissionInfo(PERMISSION_MAINLINE_NETWORK_STACK, 0); <START> assertNotNull(permissioninfo); <END> PackageInfo packageInfo = packageManager.getPackageInfo(permissioninfo.packageName, PackageManager.MATCH_SYSTEM_ONLY | PackageManager.GET_PERMISSIONS); assertNotNull(packageInfo.permissions); for (PermissionInfo permission : packageInfo.permissions) { if (PERMISSION_MAINLINE_NETWORK_STACK.equals(permission.name)) { packageCount++; } } assertTrue("Package count that declares " + PERMISSION_MAINLINE_NETWORK_STACK + " should be " + EXPECTED_DECLARATION_PERMISSION_COUNT + " but " + packageCount, (packageCount == EXPECTED_DECLARATION_PERMISSION_COUNT)); }</code><technical_language>Add error message : "network stack permission is defined"</technical_language>

Target:
public void testPackageWithMainlineNetworkStackPermission() throws Exception { final PackageManager packageManager = mContext.getPackageManager(); assertNotNull("Network stack permission is not defined.", packageManager); final PermissionInfo permissioninfo = packageManager.getPermissionInfo(PERMISSION_MAINLINE_NETWORK_STACK, 0); assertNotNull("Package defining the network stack permission is not a system package.", permissioninfo); PackageInfo packageInfo = packageManager.getPackageInfo(permissioninfo.packageName, PackageManager.MATCH_SYSTEM_ONLY | PackageManager.GET_PERMISSIONS); assertNotNull(packageInfo.permissions); for (PermissionInfo permission : packageInfo.permissions) { if (PERMISSION_MAINLINE_NETWORK_STACK.equals(permission.name)) { return; } } fail("Expect a system package defining " + PERMISSION_MAINLINE_NETWORK_STACK + " is installed."); }
Source:
<code>public String answeredBy(Actor actor) { String results = Text.of(Results.RESULT_FIELD).viewedBy(actor).asString(); ReadCacheResult readCacheResult = ResultsMapper.GetReadCacheResultFromString(results); String accessToken = null; if (readCacheResult != null) { User user = (User) actor; for (TokenCacheItemReadResult readResult : readCacheResult.tokenCacheItems) { if (readResult.accessToken != null) { if (TextUtils.isEmpty(clientId) || (!TextUtils.isEmpty(clientId) && clientId.equals(readResult.clientId))) { accessToken = readResult.accessToken; <START> user.setCacheResult(readResult); <END> break; } } } } return accessToken; }</code><technical_language>meaning ask this. comfortable questions side affects user state. I prefer state changes occur inline in test. I this debugging error recently.... i figure out set cacheResult user... digging. this is refactor in a separate PR though</technical_language>

Target:
public String answeredBy(Actor actor) { String results = Text.of(Results.RESULT_FIELD).viewedBy(actor).asString(); ReadCacheResult readCacheResult = ResultsMapper.GetReadCacheResultFromString(results); String accessToken = null; if (readCacheResult != null) { for (TokenCacheItemReadResult readResult : readCacheResult.tokenCacheItems) { if (readResult.accessToken != null) { if (TextUtils.isEmpty(clientId) || (!TextUtils.isEmpty(clientId) && clientId.equals(readResult.clientId))) { accessToken = readResult.accessToken; break; } } } } return accessToken; }
Source:
<code>public FacebookProvider(Context appContext, IdpConfig idpConfig) { mCallbackManager = CallbackManager.Factory.create(); if (appContext.getResources().getIdentifier( "google_permissions", "array", appContext.getPackageName()) != 0) { <START> Log.w(TAG, "DEVELOPER WARNING: You have defined R.array.facebook_permissions but that" <END> + " is no longer respected as of FirebaseUI 1.0.0. Please see README for IDP" + " scope configuraton instructions."); } List<String> scopes = idpConfig.getScopes(); if (scopes == null) { mScopes = new ArrayList<>(); } else { mScopes = scopes; } String applicationId = appContext.getString(R.string.facebook_application_id); FacebookSdk.sdkInitialize(appContext); FacebookSdk.setApplicationId(applicationId); }</code><technical_language>This facebook_permissions in place google_permissions in another</technical_language>

Target:
public FacebookProvider(Context appContext, IdpConfig idpConfig) { mCallbackManager = CallbackManager.Factory.create(); if (appContext.getResources().getIdentifier( "facebook_permissions", "array", appContext.getPackageName()) != 0) { Log.w(TAG, "DEVELOPER WARNING: You have defined R.array.facebook_permissions but that" + " is no longer respected as of FirebaseUI 1.0.0. Please see README for IDP" + " scope configuration instructions."); } List<String> scopes = idpConfig.getScopes(); if (scopes == null) { mScopes = new ArrayList<>(); } else { mScopes = scopes; } String applicationId = appContext.getString(R.string.facebook_application_id); FacebookSdk.sdkInitialize(appContext); FacebookSdk.setApplicationId(applicationId); }
Source:
<code>public int hashCode() { final int prime = 31; int result = 1; <START> result = prime * result + ((getVolumeId() == null) ? 0 : getVolumeId().hashCode()); <END> return result; }</code><technical_language>hash code</technical_language>

Target:
public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((getVolumeId() == null) ? 0 : getVolumeId().hashCode()); result = prime * result + ((getBrickProfileDetails() == null) ? 0 : getBrickProfileDetails().hashCode()); result = prime * result + ((getNfsProfileDetails() == null) ? 0 : getNfsProfileDetails().hashCode()); return result; }
Source:
<code>public String formatPerformanceNumbers(String testCaseId) { PerformanceState performanceState = get(testCaseId); if (performanceState.isEmpty() || performanceState.getOperationCount() < 1) { return ""; } String latencyUnit = "µs"; <START> long avgLatencyValue = round(performanceState.getIntervalAvgLatency() / MICROSECONDS.toNanos(1)); <END> long percentileLatencyValue = performanceState.getIntervalPercentileLatency() / MICROSECONDS.toNanos(1); long maxLatencyValue = performanceState.getIntervalMaxLatency() / MICROSECONDS.toNanos(1); if (avgLatencyValue > DISPLAY_LATENCY_AS_MICROS_MAX_VALUE) { latencyUnit = "ms"; avgLatencyValue = MICROSECONDS.toMillis(avgLatencyValue); percentileLatencyValue = MICROSECONDS.toMillis(percentileLatencyValue); maxLatencyValue = MICROSECONDS.toMillis(maxLatencyValue); } return String.format("%s ops %s ops/s %s %s (avg) %s %s (%sth) %s %s (max)", formatLong(performanceState.getOperationCount(), OPERATION_COUNT_FORMAT_LENGTH), formatDouble(performanceState.getIntervalThroughput(), THROUGHPUT_FORMAT_LENGTH), formatLong(avgLatencyValue, LATENCY_FORMAT_LENGTH), latencyUnit, formatLong(percentileLatencyValue, LATENCY_FORMAT_LENGTH), latencyUnit, INTERVAL_LATENCY_PERCENTILE, formatLong(maxLatencyValue, LATENCY_FORMAT_LENGTH), latencyUnit ); }</code><technical_language>This confusing now. latency values rounded, dividing again. this NANOS.toMicros(round(...));</technical_language>

Target:
public String formatPerformanceNumbers(String testCaseId) { PerformanceState performanceState = get(testCaseId); if (performanceState.isEmpty() || performanceState.getOperationCount() < 1) { return ""; } String latencyUnit = "µs"; long latencyAvg = NANOSECONDS.toMicros(round(performanceState.getIntervalLatencyAvgNanos())); long latency999Percentile = NANOSECONDS.toMicros(performanceState.getIntervalLatency999PercentileNanos()); long latencyMax = NANOSECONDS.toMicros(performanceState.getIntervalLatencyMaxNanos()); if (latencyAvg > DISPLAY_LATENCY_AS_MICROS_MAX_VALUE) { latencyUnit = "ms"; latencyAvg = MICROSECONDS.toMillis(latencyAvg); latency999Percentile = MICROSECONDS.toMillis(latency999Percentile); latencyMax = MICROSECONDS.toMillis(latencyMax); } return String.format("%s ops %s ops/s %s %s (avg) %s %s (%sth) %s %s (max)", formatLong(performanceState.getOperationCount(), OPERATION_COUNT_FORMAT_LENGTH), formatDouble(performanceState.getIntervalThroughput(), THROUGHPUT_FORMAT_LENGTH), formatLong(latencyAvg, LATENCY_FORMAT_LENGTH), latencyUnit, formatLong(latency999Percentile, LATENCY_FORMAT_LENGTH), latencyUnit, INTERVAL_LATENCY_PERCENTILE, formatLong(latencyMax, LATENCY_FORMAT_LENGTH), latencyUnit ); }
Source:
<code><START> public DbStoredProcedureCall newStoredProcedureCall(String name, DbParameterAccessor[] accessors) { <END> return new DefaultDbStoredProcedureCall(this, name, accessors); }</code><technical_language>glimpse sense</technical_language>

Target:
public DbCommand newStoredProcedureCall(String name, DbParameterAccessor[] accessors) throws SQLException { return new DbStoredProcedureCall(this, name, accessors).toStatementExecution(); }
Source:
<code>public int appendIndicator(Indicator indicator, boolean paramBoolean) { <START> return 0; <END> }</code><technical_language>implementing this; removing notification</technical_language>

Target:
public int appendIndicator(Indicator indicator, boolean paramBoolean) { if (paramBoolean) { System.out.println("IndicatorManager.appendIndicator(L...Indicator;Z)I unexpected value"); } return 0; }
Source:
<code>public static void writeOpenTag(final Response response, IValueMap attributes) { response.write(INLINE_OPEN_TAG_START); if (attributes != null) { <START> response.write(" "+attributes.toString()); <END> } response.write(">\n"); }</code><technical_language>toString() call is redundant here, missing white-spaces</technical_language>

Target:
public static void writeOpenTag(final Response response, IValueMap attributes) { response.write(INLINE_OPEN_TAG_START); if (attributes != null) { response.write(" " + attributes); } response.write(">\n"); }
Source:
<code>public HudsonModelJob getDownstreamJob(final HudsonModelJob job, final String id, final IOperationMonitor monitor) throws HudsonException { return new HudsonOperation<HudsonModelJob>(client) { @Override protected HudsonModelJob execute() throws IOException, HudsonException, JAXBException { <START> String jobTreeContent = String.format( <END> "buildable,color,description,displayName,healthReport[score,description],inQueue,name,url"); String tree = String.format("%1$s", jobTreeContent); String url = HudsonUrl.create(getJobUrl(job) + id).tree(tree).toUrl(); HttpRequestBase request = createGetRequest(url); CommonHttpResponse response = execute(request, monitor); return processAndRelease(response, monitor); } @Override protected HudsonModelJob doProcess(CommonHttpResponse response, IOperationMonitor monitor) throws IOException, HudsonException, JAXBException { InputStream in = response.getResponseEntityAsStream(); HudsonModelJob buildPlan = unmarshal(parse(in, response.getRequestPath()), HudsonModelJob.class); return buildPlan; } }.run(); }</code><technical_language>need for String.format</technical_language>

Target:
public HudsonModelJob getDownstreamJob(final HudsonModelJob job, final String id, final IOperationMonitor monitor) throws HudsonException { return new HudsonOperation<HudsonModelJob>(client) { @Override protected HudsonModelJob execute() throws IOException, HudsonException, JAXBException { String tree = "buildable,color,description,displayName,healthReport[score,description],inQueue,name,url"; String url = HudsonUrl.create(getJobUrl(job) + id).tree(tree).toUrl(); HttpRequestBase request = createGetRequest(url); CommonHttpResponse response = execute(request, monitor); return processAndRelease(response, monitor); } @Override protected HudsonModelJob doProcess(CommonHttpResponse response, IOperationMonitor monitor) throws IOException, HudsonException, JAXBException { InputStream in = response.getResponseEntityAsStream(); HudsonModelJob buildPlan = unmarshal(parse(in, response.getRequestPath()), HudsonModelJob.class); return buildPlan; } }.run(); }
Source:
<code>public LocalizationUtils(final String fileName) { log.info("Start initializing {}", getClass().getSimpleName()); messageSource = fileName.endsWith(".properties") ? fileName.substring(0, fileName.lastIndexOf(".properties")) <START> : fileName; <END> resourceBundlesByLocale = new HashMap<>(); getResourceBundle(Locale.getDefault()); log.info("Finished initializing {}", getClass().getSimpleName()); }</code><technical_language>replaceAll? messageSource = fileName.replaceAll("\\.properties$", "");</technical_language>

Target:
public LocalizationUtils(final String fileName) { log.info("Start initializing {}", getClass().getSimpleName()); messageSource = fileName.replaceAll("\\.properties$", ""); resourceBundlesByLocale = new HashMap<>(); for (Locale locale : Locale.getAvailableLocales()) { getResourceBundle(locale); } log.info("Finished initializing {}", getClass().getSimpleName()); }
Source:
<code>public void testExecuteQueryGetUnregisteredTemplateNotFound() { setUpQueryEntitiesNotFound(); getQuery().executeQueryCommand(); @SuppressWarnings("unchecked") VmTemplate result = getQuery().getQueryReturnValue().getReturnValue(); <START> assertEquals(null, <END> result, "Wrong Templates entity in result"); }</code><technical_language>assertNull</technical_language>

Target:
public void testExecuteQueryGetUnregisteredTemplateNotFound() { setUpQueryEntitiesNotFound(); getQuery().executeQueryCommand(); @SuppressWarnings("unchecked") VmTemplate result = getQuery().getQueryReturnValue().getReturnValue(); assertNull(result, "Wrong Templates entity in result"); }
Source:
<code>public List<QuotaConsumptionParameter> getQuotaStorageConsumptionParameters() { List<QuotaConsumptionParameter> list = new ArrayList<>(); if (isDiskImage()) { DiskImage oldDiskImage = (DiskImage) getOldDisk(); DiskImage newDiskImage = (DiskImage) getNewDisk(); boolean emptyOldQuota = oldDiskImage.getQuotaId() == null || Guid.Empty.equals(oldDiskImage.getQuotaId()); boolean differentNewQuota = !emptyOldQuota && !oldDiskImage.getQuotaId().equals(newDiskImage.getQuotaId()); <START> long diskExtendingDiff = newDiskImage.getSizeInGigabytes() - oldDiskImage.getSizeInGigabytes(); <END> if (emptyOldQuota || differentNewQuota ) { list.add(generateQuotaConsumeParameters(newDiskImage, newDiskImage.getSizeInGigabytes())); } else if (diskExtendingDiff != 0) { list.add(generateQuotaConsumeParameters(newDiskImage, diskExtendingDiff)); } if (differentNewQuota) { list.add(new QuotaStorageConsumptionParameter( oldDiskImage.getQuotaId(), null, QuotaStorageConsumptionParameter.QuotaAction.RELEASE, oldDiskImage.getStorageIds().get(0), (double)oldDiskImage.getSizeInGigabytes())); } } return list; }</code><technical_language>if user insert new size size, attempt consume quota negative (and fail canDoAction()). system acts scenario? (consumption of negative quota)</technical_language>

Target:
public List<QuotaConsumptionParameter> getQuotaStorageConsumptionParameters() { List<QuotaConsumptionParameter> list = new ArrayList<>(); if (isDiskImage()) { DiskImage oldDiskImage = (DiskImage) getOldDisk(); DiskImage newDiskImage = (DiskImage) getNewDisk(); boolean emptyOldQuota = oldDiskImage.getQuotaId() == null || Guid.Empty.equals(oldDiskImage.getQuotaId()); boolean differentNewQuota = !emptyOldQuota && !oldDiskImage.getQuotaId().equals(newDiskImage.getQuotaId()); long diskExtendingDiff = newDiskImage.getSizeInGigabytes() - oldDiskImage.getSizeInGigabytes(); if (emptyOldQuota || differentNewQuota ) { list.add(generateQuotaConsumeParameters(newDiskImage, newDiskImage.getSizeInGigabytes())); } else if (diskExtendingDiff > 0L) { list.add(generateQuotaConsumeParameters(newDiskImage, diskExtendingDiff)); } if (differentNewQuota) { list.add(new QuotaStorageConsumptionParameter( oldDiskImage.getQuotaId(), null, QuotaStorageConsumptionParameter.QuotaAction.RELEASE, oldDiskImage.getStorageIds().get(0), (double)oldDiskImage.getSizeInGigabytes())); } } return list; }
Source:
<code>public void fail_when_missing_administer_quality_gate_permission() { OrganizationDto organization = db.organizations().insert(); userSession.addPermission(ADMINISTER_QUALITY_PROFILES, organization); QGateWithOrgDto qualityGate = db.qualityGates().insertQualityGate(organization); expectedException.expect(ForbiddenException.class); QualityGate response = ws.newRequest() .setParam(PARAM_ID, qualityGate.getId().toString()) .setParam(PARAM_NAME, "new-name") .setParam(PARAM_ORGANIZATION, organization.getKey()) .executeProtobuf(QualityGate.class); <START> assertThat(response).isNotNull(); <END> assertThat(response.getId()).isNotEqualTo(qualityGate.getId()); assertThat(response.getName()).isEqualTo("new-name"); }</code><technical_language>Unreachable code</technical_language>

Target:
public void fail_when_missing_administer_quality_gate_permission() { OrganizationDto organization = db.organizations().insert(); userSession.addPermission(ADMINISTER_QUALITY_PROFILES, organization); QGateWithOrgDto qualityGate = db.qualityGates().insertQualityGate(organization); expectedException.expect(ForbiddenException.class); ws.newRequest() .setParam(PARAM_ID, qualityGate.getId().toString()) .setParam(PARAM_NAME, "new-name") .setParam(PARAM_ORGANIZATION, organization.getKey()) .execute(); }
Source:
<code>public String generateFragment() { if (!DownloadSettings.usePostBack()) { return ""; } if (neverUpdate) return ""; if (doesNotSupportPostMessage()) return ""; StringBuilder buf = new StringBuilder(); if(Jenkins.getInstance().hasPermission(Jenkins.READ)) { long now = System.currentTimeMillis(); for (Downloadable d : Downloadable.all()) { <START> if(d.getDue()<now && d.lastAttempt+10*1000<now) { <END> buf.append("<script>") .append("Behaviour.addLoadEvent(function() {") .append(" downloadService.download(") .append(QuotedStringTokenizer.quote(d.getId())) .append(',') .append(QuotedStringTokenizer.quote(mapHttps(d.getUrl()))) .append(',') .append("{version:"+QuotedStringTokenizer.quote(Jenkins.VERSION)+'}') .append(',') .append(QuotedStringTokenizer.quote(Stapler.getCurrentRequest().getContextPath()+'/'+getUrl()+"/byId/"+d.getId()+"/postBack")) .append(',') .append("null);") .append("});") .append("</script>"); d.lastAttempt = now; } } } return buf.toString(); }</code><technical_language>suggestion if(d.getDue()<now && d.lastAttempt+TimeUnit.SECONDS.toMillis(10)<now) {</technical_language>

Target:
public String generateFragment() { if (!DownloadSettings.usePostBack()) { return ""; } if (neverUpdate) return ""; if (doesNotSupportPostMessage()) return ""; StringBuilder buf = new StringBuilder(); if(Jenkins.getInstance().hasPermission(Jenkins.READ)) { long now = System.currentTimeMillis(); for (Downloadable d : Downloadable.all()) { if(d.getDue()<now && d.lastAttempt+TimeUnit.SECONDS.toMillis(10)<now) { buf.append("<script>") .append("Behaviour.addLoadEvent(function() {") .append(" downloadService.download(") .append(QuotedStringTokenizer.quote(d.getId())) .append(',') .append(QuotedStringTokenizer.quote(mapHttps(d.getUrl()))) .append(',') .append("{version:"+QuotedStringTokenizer.quote(Jenkins.VERSION)+'}') .append(',') .append(QuotedStringTokenizer.quote(Stapler.getCurrentRequest().getContextPath()+'/'+getUrl()+"/byId/"+d.getId()+"/postBack")) .append(',') .append("null);") .append("});") .append("</script>"); d.lastAttempt = now; } } } return buf.toString(); }
Source:
<code>protected boolean canDoAction() { boolean retValue=true; OVirtNodeInfo[] info = OVirtNodeInfo.get(); if (getVdsId() == null || getVdsId().equals(Guid.Empty)) { addCanDoActionMessage(VdcBllMessages.VDS_INVALID_SERVER_ID); retValue = false; } else if (getVds() == null) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_HOST_NOT_EXIST); retValue = false; } else if (isOvirtReInstallOrUpgrade()) { String isoFile = getParameters().getoVirtIsoFile(); if (getVds().getStatus() == VDSStatus.NonOperational) { addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_INSTALL_STATUS_ILLEGAL); retValue = false; } RpmVersion ovirtHostOsVersion = VdsHandler.getOvirtHostOsVersion(getVds()); <START> retValue = isIsoFileValid(isoFile, info, ovirtHostOsVersion); <END> } return retValue; }</code><technical_language>Martin Perina introduced a VdsValidator class. Please provide validation methods in canDoAction of host related commands. StoragePoolValidator MultiStorageDomainValidator classes for reference - isIsoFile valid moved class IMHO</technical_language>

Target:
protected boolean canDoAction() { boolean retValue = true; List<OVirtNodeInfo> info = OVirtNodeInfo.get(); if (getVdsId() == null || getVdsId().equals(Guid.Empty)) { addCanDoActionMessage(VdcBllMessages.VDS_INVALID_SERVER_ID); retValue = false; } else if (getVds() == null) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_HOST_NOT_EXIST); retValue = false; } else if (isOvirtReInstallOrUpgrade()) { StringBuilder isoFile = new StringBuilder(getParameters().getoVirtIsoFile()); if (getVds().getStatus() == VDSStatus.NonOperational) { addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_INSTALL_STATUS_ILLEGAL); retValue = false; } VdsValidator.IsoValidStatus isoStat; RpmVersion ovirtHostOsVersion = VdsHandler.getOvirtHostOsVersion(getVds()); VdsValidator validator = new VdsValidator(getVds()); isoStat = validator.isIsoFileValid(isoFile, info, ovirtHostOsVersion); switch(isoStat) { case VALID: _isoFullPath = isoFile.toString(); retValue = true; break; case NOTCOMPATIBLE: addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_UPGRADE_BETWEEN_MAJOR_VERSION); addCanDoActionMessage(String.format("$IsoVersion %1$s", ovirtHostOsVersion.getMajor())); retValue = false; break; case MISSINGFILE: addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_INSTALL_MISSING_IMAGE_FILE); retValue = true; break; } } return retValue; }
Source:
<code><START> private PDOMFile getBestFile(int linkageID, IIndexFileLocation location, ITranslationUnit tu) throws CoreException { <END> IIndexFile[] files = getFiles(linkageID, location); IIndexFile best = null; int bestScore = -1; for (IIndexFile file : files) { int score = file.getMacros().length * 2; if (TranslationUnit.isSourceFile(TranslationUnit.getParsedInContext(file), tu)) score++; if (score > bestScore) { bestScore = score; best = file; } } return (PDOMFile) best; }</code><technical_language>Code contained in a header completely invalid of a source file context. real compiler parses headers of a source file context, risk in CDT</technical_language>

Target:
private PDOMFile getBestFile(int linkageID, IIndexFileLocation location, ITranslationUnit tu) throws CoreException { IIndexFile[] files = getFiles(linkageID, location); IIndexFile best = null; int bestScore = -1; for (IIndexFile file : files) { int score = file.getMacros().length * 2; if (TranslationUnit.isSourceFile(TranslationUnit.getParsedInContext(file), tu.getCProject().getProject())) score++; if (score > bestScore) { bestScore = score; best = file; } } return (PDOMFile) best; }
Source:
<code>public boolean equals(Object o) { if ( this == o ) { return true; } if ( o == null || getClass() != o.getClass() ) { return false; } LocalizedMessage that = (LocalizedMessage) o; <START> if ( message != null ? !message.equals( that.message ) : that.message != null ) { <END> return false; } if ( locale != null ? !locale.equals( that.locale ) : that.locale != null ) { return false; } return true; }</code><technical_language>of value, LocalizedMessage is locale message null if statement above: java if ( o == null || getClass() != o.getClass() ) { return false; } I remember done in previous case, removed them, not</technical_language>

Target:
public boolean equals(Object o) { if ( this == o ) { return true; } if ( o == null || getClass() != o.getClass() ) { return false; } LocalizedMessage that = (LocalizedMessage) o; if ( !message.equals( that.message ) ) { return false; } if ( !locale.equals( that.locale ) ) { return false; } return true; }
Source:
<code>private void configureImageTable() { if (imageTable.getColumnCount() > NUMBER_OF_VISIBLE_COLUMNS) { TableColumn columnToHide = imageTable.getColumn(imageTableModel.getColumnName(NUMBER_OF_VISIBLE_COLUMNS)); if (columnToHide != null) { imageTable.removeColumn(columnToHide); } imageTable.getRowSorter().addRowSorterListener(new RowSorterListener() { @Override public void sorterChanged(RowSorterEvent e) { imageTableSelect(); } }); imageTable.getRowSorter().toggleSortOrder(COLUMN_TO_SORT_ON_INDEX); <START> imageTable.getRowSorter().toggleSortOrder(COLUMN_TO_SORT_ON_INDEX); <END> } }</code><technical_language>Duplicated code</technical_language>

Target:
private void configureImageTable() { if (imageTable.getColumnCount() > NUMBER_OF_VISIBLE_COLUMNS) { TableColumn columnToHide = imageTable.getColumn(imageTableModel.getColumnName(NUMBER_OF_VISIBLE_COLUMNS)); if (columnToHide != null) { imageTable.removeColumn(columnToHide); } imageTable.getRowSorter().toggleSortOrder(COLUMN_TO_SORT_ON_INDEX); imageTable.getRowSorter().toggleSortOrder(COLUMN_TO_SORT_ON_INDEX); } }
Source:
<code>public static ScrollBarPolicy getHorizontalBarPolicy(final View view) { final String verticalPolicy = NotationUtils.getStringValue(view, "horizontalScrollBar", null); ScrollBarPolicy scrollBarPolicy = ScrollBarPolicy.NEVER; if (verticalPolicy != null) { if ("always".equals(verticalPolicy)) { scrollBarPolicy = ScrollBarPolicy.ALWAYS; } else <START> if ("asNeeded".equals(verticalPolicy)) { <END> scrollBarPolicy = ScrollBarPolicy.AS_NEEDED; } else if ("never".equals(verticalPolicy)) { scrollBarPolicy = ScrollBarPolicy.NEVER; } } return scrollBarPolicy; }</code><technical_language>constants ensure consistency (auto asNeeded)</technical_language>

Target:
public static ScrollBarPolicy getHorizontalBarPolicy(final View view) { final String verticalPolicy = NotationUtils.getStringValue(view, HORIZONTAL_SCROLL_BAR, null); ScrollBarPolicy scrollBarPolicy = ScrollBarPolicy.NEVER; if (verticalPolicy != null) { if (SCROLL_BAR_ALWAYS.equals(verticalPolicy)) { scrollBarPolicy = ScrollBarPolicy.ALWAYS; } else if (SCROLL_BAR_AUTO.equals(verticalPolicy)) { scrollBarPolicy = ScrollBarPolicy.AS_NEEDED; } else if (SCROLL_BAR_NEVER.equals(verticalPolicy)) { scrollBarPolicy = ScrollBarPolicy.NEVER; } } return scrollBarPolicy; }
Source:
<code><START> public List<InvoiceItem> createExternalCharges(final Iterable<InvoiceItem> externalCharges, @Nullable final LocalDate requestedDate, final Boolean autoPay, final Boolean autoCommit, final String createdBy, final String reason, final String comment) throws KillBillClientException { <END> return createExternalCharges(externalCharges, requestedDate, autoPay, autoCommit, null, null, RequestOptions.builder() .withCreatedBy(createdBy) .withReason(reason) .withComment(comment).build()); }</code><technical_language>@Deprecated (no RequestOptions)</technical_language>

Target:
public List<InvoiceItem> createExternalCharges(final Iterable<InvoiceItem> externalCharges, @Nullable final LocalDate requestedDate, final Boolean autoPay, final Boolean autoCommit, final String createdBy, final String reason, final String comment) throws KillBillClientException { return createExternalCharges(externalCharges, requestedDate, autoPay, autoCommit, RequestOptions.builder() .withCreatedBy(createdBy) .withReason(reason) .withComment(comment).build()); }
Source:
<code>protected void onDoneImpl(Exception e) { if (e != null) Exceptions.propagateIfFatal(e); List<Exception> allExceptions = Lists.newArrayList(); if (e != null) { allExceptions.add(e); } if (danglingRefFailureMode != RebindFailureMode.CONTINUE) { if (missingEntities.size() > 0) { allExceptions.add(new IllegalStateException("Missing referenced entit"+(missingEntities.size() == 1 ? "y" : "ies")+": "+missingEntities)); } if (missingLocations.size() > 0) { allExceptions.add(new IllegalStateException("Missing referenced location"+(missingLocations.size() == 1 ? "" : "s")+": "+missingLocations)); } if (missingPolicies.size() > 0) { <START> allExceptions.add(new IllegalStateException("Missing referenced policy"+(missingPolicies.size() == 1 ? "" : "s")+": "+missingPolicies)); <END> } if (missingEnrichers.size() > 0) { allExceptions.add(new IllegalStateException("Missing referenced enricher"+(missingEnrichers.size() == 1 ? "" : "s")+": "+missingEnrichers)); } } if (rebindFailureMode != RebindFailureMode.CONTINUE) { allExceptions.addAll(exceptions); } if (allExceptions.isEmpty()) { return; } else { CompoundRuntimeException compoundException = new CompoundRuntimeException("Problem"+(allExceptions.size() == 1 ? "" : "s")+" rebinding", allExceptions); LOG.info("RebindManager failed (throwing): "+compoundException.toString()); throw compoundException; } }</code><technical_language>Cf. L261 for _entity_ vs. _entities_</technical_language>

Target:
protected void onDoneImpl(Exception e) { if (e != null) Exceptions.propagateIfFatal(e); List<Exception> allExceptions = Lists.newArrayList(); if (e != null) { allExceptions.add(e); } if (danglingRefFailureMode != RebindFailureMode.CONTINUE) { if (missingEntities.size() > 0) { allExceptions.add(new IllegalStateException("Missing referenced entit"+(missingEntities.size() == 1 ? "y" : "ies")+": "+missingEntities)); } if (missingLocations.size() > 0) { allExceptions.add(new IllegalStateException("Missing referenced location"+(missingLocations.size() == 1 ? "" : "s")+": "+missingLocations)); } if (missingPolicies.size() > 0) { allExceptions.add(new IllegalStateException("Missing referenced polic"+(missingPolicies.size() == 1 ? "y" : "ies")+": "+missingPolicies)); } if (missingEnrichers.size() > 0) { allExceptions.add(new IllegalStateException("Missing referenced enricher"+(missingEnrichers.size() == 1 ? "" : "s")+": "+missingEnrichers)); } } if (rebindFailureMode != RebindFailureMode.CONTINUE) { allExceptions.addAll(exceptions); } if (allExceptions.isEmpty()) { return; } else { CompoundRuntimeException compoundException = new CompoundRuntimeException("Problem"+(allExceptions.size() == 1 ? "" : "s")+" rebinding", allExceptions); LOG.info("RebindManager failed (throwing): "+compoundException.toString()); throw compoundException; } }
Source:
<code>protected void handleTMasterRegisterRequest( REQID rid, SocketChannel channel, CheckpointManager.RegisterTMasterRequest request ) { LOG.info("Got a register request from TMaster host:port " + channel.socket().getRemoteSocketAddress()); CheckpointManager.RegisterTMasterResponse.Builder responseBuilder = CheckpointManager.RegisterTMasterResponse.newBuilder(); <START> if (!request.getTopologyName().equals(topologyName)) { <END> LOG.severe("The register message was from a different topology: " + request.getTopologyName()); responseBuilder.setStatus(Common.Status.newBuilder().setStatus(Common.StatusCode.NOTOK)); } else if (!request.getTopologyId().equals(topologyId)) { LOG.severe("The register message was from a different topology id: " + request.getTopologyName()); responseBuilder.setStatus(Common.Status.newBuilder().setStatus(Common.StatusCode.NOTOK)); } else if (connection != null) { LOG.warning("We already have an active connection from the tmaster " + "Closing existing connection..."); try { connection.close(); } catch (IOException e) { LOG.warning("Failed to close connection from: " + connection.socket().getRemoteSocketAddress()); } connection = null; responseBuilder.setStatus(Common.Status.newBuilder().setStatus(Common.StatusCode.NOTOK)); } else { connection = channel; responseBuilder.setStatus(Common.Status.newBuilder().setStatus(Common.StatusCode.OK)); } sendResponse(rid, channel, responseBuilder.build()); }</code><technical_language>This assertion logic is copied in this class. Please a generic assertValidRequest method get code reuse. assertion of valid topologyName topologyId in some methods all? (I a broader question is is topologyName/topologyId passed all, startup time static.)</technical_language>

Target:
protected void handleTMasterRegisterRequest( REQID rid, SocketChannel channel, CheckpointManager.RegisterTMasterRequest request ) { LOG.info("Got a TMaster register request from TMaster host:port " + channel.socket().getRemoteSocketAddress()); CheckpointManager.RegisterTMasterResponse.Builder responseBuilder = CheckpointManager.RegisterTMasterResponse.newBuilder(); if (!checkRegistrationValidity(request.getTopologyName(), request.getTopologyId())) { String errorMessage = String.format("The TMaster register message came with a different " + "topologyName: %s and/or topologyId: %s", request.getTopologyName(), request.getTopologyId()); LOG.severe(errorMessage); responseBuilder.setStatus(Common.Status.newBuilder().setStatus(Common.StatusCode.NOTOK) .setMessage(errorMessage)); } else if (!checkExistingConnection()) { String errorMessage = "Please try again"; responseBuilder.setStatus(Common.Status.newBuilder().setStatus(Common.StatusCode.NOTOK) .setMessage(errorMessage)); } else { connection = channel; responseBuilder.setStatus(Common.Status.newBuilder().setStatus(Common.StatusCode.OK)); } sendResponse(rid, channel, responseBuilder.build()); }
Source:
<code>public void testEnvironmentVariables() throws Exception { <START> BundleContext bundleContext = CoreTestsActivator.getDefault().getBundleContext(); <END> final String identifier = "getenv"; String filter = '(' + SystemSummaryStreamer.STREAMER_IDENTIFIER + '=' + identifier + ')'; Optional<ServiceReference<SystemSummaryStreamer>> first = bundleContext .getServiceReferences(SystemSummaryStreamer.class, filter).stream().findFirst(); assertTrue(first.isPresent()); ServiceReference<SystemSummaryStreamer> reference = first.get(); assertEquals(identifier, reference.getProperty(SystemSummaryStreamer.STREAMER_IDENTIFIER)); SystemSummaryStreamer service = bundleContext.getService(reference); String collected = service.stream().collect(Collectors.joining("\n")); System.getenv().keySet().forEach(key -> assertTrue(collected.contains(key))); }</code><technical_language>Please prefer FameworkUtil access bundleContext, avoid activators delay startup. target get rid of possible</technical_language>

Target:
public void testEnvironmentVariables() throws Exception { BundleContext bundleContext = FrameworkUtil.getBundle(AboutTest.class).getBundleContext(); Optional<ServiceReference<ESystemInformationService>> first = bundleContext .getServiceReferences(ESystemInformationService.class, About.createSectionFilter(About.SECTION_ENVIRONMENT)).stream().findFirst(); assertTrue(first.isPresent()); ServiceReference<ESystemInformationService> reference = first.get(); assertEquals(About.SECTION_ENVIRONMENT, reference.getProperty(About.SECTION)); ESystemInformationService service = bundleContext.getService(reference); String collected = service.stream().collect(Collectors.joining("\n")); System.getenv().keySet().forEach(key -> assertTrue(collected.contains(key))); }