auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testNoPathFilter() throws Exception { <START> final BackgroundHiveSplitLoader backgroundHiveSplitLoader = getBackgroundHiveSplitLoader(getFiles(), TupleDomain.none()); <END> final HiveSplitSource hiveSplitSource = new HiveSplitSource(1, backgroundHiveSplitLoader, mockExecutor); backgroundHiveSplitLoader.start(hiveSplitSource); assertEquals(2, hiveSplitSource.getOutstandingSplitCount()); }</code><technical_language>final for local variables some lambda execution demands it</technical_language>

Target:
public void testNoPathFilter() throws Exception { BackgroundHiveSplitLoader backgroundHiveSplitLoader = backgroundHiveSplitLoader( TEST_FILES, TupleDomain.none()); HiveSplitSource hiveSplitSource = hiveSplitSource(backgroundHiveSplitLoader); backgroundHiveSplitLoader.start(hiveSplitSource); assertEquals(2, hiveSplitSource.getOutstandingSplitCount()); }
Source:
<code><START> public User addUserCreatedOnBuddyRequest(UserDTO buddyUserResource, String tempPassword) <END> { UUID savedUserID = CryptoSession.execute(Optional.of(tempPassword), null, () -> tempEncryptionContextExecutor .addUserCreatedOnBuddyRequestFlush(buddyUserResource).getID()); return getEntityByID(savedUserID); }</code><technical_language>this transactional</technical_language>

Target:
public User addUserCreatedOnBuddyRequest(UserDTO buddyUserResource, String tempPassword) { UUID savedUserID = CryptoSession.execute(Optional.of(tempPassword), null, () -> tempEncryptionContextExecutor.addUserCreatedOnBuddyRequest(buddyUserResource).getID()); return getEntityByID(savedUserID); }
Source:
<code>public void onRenamed(I item, String oldName, String newName) throws IOException { items.remove(oldName); <START> items.put(newName, (I) item); <END> for (View v : views) { v.onJobRenamed(item, oldName, newName); } save(); }</code><technical_language>Remove cast</technical_language>

Target:
public void onRenamed(I item, String oldName, String newName) throws IOException { items.remove(oldName); items.put(newName, item); for (View v : views) { v.onJobRenamed(item, oldName, newName); } save(); }
Source:
<code>private boolean fileTimeStampIsWanted(File f) throws IOException { <START> long timestamp = f.lastModified(); <END> LocalDateTime fileEndTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()); LocalDateTime fileStartTime = inferFileStartTime(f); if (fileStartTime == null) { fileStartTime = LocalDateTime.MIN; } if (mStartTime != null && mStartTime.isAfter(fileEndTime)) { return false; } if (mEndTime != null && mEndTime.isBefore(fileStartTime)) { return false; } return true; }</code><technical_language>guard this if (mEndTime != null) in block, return false if fails</technical_language>

Target:
private boolean fileTimeStampIsWanted(File f) throws IOException { if (mStartTime != null) { long timestamp = f.lastModified(); LocalDateTime fileEndTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()); if (mStartTime.isAfter(fileEndTime)) { return false; } } if (mEndTime != null) { LocalDateTime fileStartTime = inferFileStartTime(f); if (fileStartTime == null) { fileStartTime = LocalDateTime.MIN; } if (mEndTime.isBefore(fileStartTime)) { return false; } } return true; }
Source:
<code>public NetworkCidr getNetworkCidr(Network network, CloudCredential credential) { String subnetId = network.getStringParameter(GcpStackUtil.SUBNET_ID); String region = network.getStringParameter(GcpStackUtil.REGION); String sharedProjectId = network.getStringParameter(GcpStackUtil.SHARED_PROJECT_ID); LOGGER.debug("Getting network cidrs for subnet in region {}", subnetId, region); Compute compute = GcpStackUtil.buildCompute(credential); String projectId = GcpStackUtil.getProjectId(credential); Subnetwork subnet = null; try { SubnetworkList ownProjectSubnets = compute.subnetworks().list(projectId, region).execute(); Set<Subnetwork> collect = ownProjectSubnets.getItems() .stream() .filter(e -> e.getName().equals(subnetId)) .collect(Collectors.toSet()); if (collect.isEmpty()) { subnet = compute.subnetworks().get(sharedProjectId, region, subnetId).execute(); } else { <START> subnet = compute.subnetworks().get(projectId, region, subnetId).execute(); <END> } String ipCidrRange = subnet.getIpCidrRange(); return new NetworkCidr(ipCidrRange, Collections.singletonList(ipCidrRange)); } catch (IOException e) { throw new GcpResourceException("Describe subnets failed due to IO exception", GCP_NETWORK, subnetId); } }</code><technical_language>query subnetwor GCP's API? I assume in collect set content, it</technical_language>

Target:
public NetworkCidr getNetworkCidr(Network network, CloudCredential credential) { String subnetId = network.getStringParameter(GcpStackUtil.SUBNET_ID); String region = network.getStringParameter(GcpStackUtil.REGION); String sharedProjectId = network.getStringParameter(GcpStackUtil.SHARED_PROJECT_ID); LOGGER.debug("Getting network cidrs for subnet in region {}", subnetId, region); Compute compute = GcpStackUtil.buildCompute(credential); String projectId = GcpStackUtil.getProjectId(credential); Subnetwork subnet = null; try { SubnetworkList ownProjectSubnets = compute.subnetworks().list(projectId, region).execute(); Set<Subnetwork> collect = ownProjectSubnets.getItems() .stream() .filter(e -> e.getName().equals(subnetId)) .collect(Collectors.toSet()); if (collect.isEmpty()) { subnet = compute.subnetworks().get(sharedProjectId, region, subnetId).execute(); } else { subnet = collect .stream() .findFirst() .orElse(null); } if (subnet == null) { throw new GcpResourceException(String.format("Subnet with id %s did not found.", subnetId)); } String ipCidrRange = subnet.getIpCidrRange(); return new NetworkCidr(ipCidrRange, Collections.singletonList(ipCidrRange)); } catch (IOException e) { throw new GcpResourceException("Describe subnets failed due to IO exception", GCP_NETWORK, subnetId); } }
Source:
<code>protected ImmutableSet<String> functionNames() { return ImmutableSet.<String>builder() .addAll(NEW_BY_DEPRECATED_FUNCTIONS.keySet()) .add(SET_LOCALE_FUNCTION) .add(PARSE_STR_FUNCTION) .add(ASSERT_FUNCTION) .add(DEFINE_FUNCTION) <START> .add(STREAM_FILTER_APPEND_FUNCTION) <END> .build(); }</code><technical_language>stream_filter_prepend in ticket ?! I for this case, I prefer raise issue time string.strip_tags is literally, context</technical_language>

Target:
protected ImmutableSet<String> functionNames() { return ImmutableSet.<String>builder() .addAll(NEW_BY_DEPRECATED_FUNCTIONS.keySet()) .addAll(SEARCHING_STRING_FUNCTIONS) .add(SET_LOCALE_FUNCTION) .add(PARSE_STR_FUNCTION) .add(ASSERT_FUNCTION) .add(DEFINE_FUNCTION) .build(); }
Source:
<code>void setBackgroundColor (long context, long handle, GdkRGBA rgba) { <START> if (OS.GTK_VERSION < OS.VERSION(3, 10, 10) && (style & (SWT.CHECK | SWT.RADIO)) != 0) { <END> super.setBackgroundColor (context, handle, rgba); return; } String css ="* {\n"; if (rgba != null) { String color = gtk_rgba_to_css_string (rgba); css += "background: " + color + ";\n"; } css += "}\n"; gtk_css_provider_load_from_css (context, css); }</code><technical_language>Is this 3.10.10 a typo? I find gtk version</technical_language>

Target:
void setBackgroundColor (long context, long handle, GdkRGBA rgba) { if (OS.GTK_VERSION < OS.VERSION(3, 10, 0) && (style & (SWT.CHECK | SWT.RADIO)) != 0) { super.setBackgroundColor (context, handle, rgba); return; } String css ="* {\n"; if (rgba != null) { String color = gtk_rgba_to_css_string (rgba); css += "background: " + color + ";\n"; } css += "}\n"; gtk_css_provider_load_from_css (context, css); }
Source:
<code>public static Method[] listSMDMethods(Class clazz, boolean ignoreInterfaces) { final List<Method> methods = new LinkedList<>(); if (ignoreInterfaces) { <START> Method[] SMDMethods = clazz.getMethods(); <END> Arrays.sort(SMDMethods, (a, b) -> a.toString().compareTo(b.toString())); for (Method method : SMDMethods) { SMDMethod smdMethodAnnotation = method.getAnnotation(SMDMethod.class); if (smdMethodAnnotation != null) { methods.add(method); } } } else { JSONUtil.visitInterfaces(clazz, new JSONUtil.ClassVisitor() { public boolean visit(Class aClass) { Method[] SMDMethods = aClass.getMethods(); Arrays.sort(SMDMethods, (a, b) -> a.toString().compareTo(b.toString())); for (Method method : SMDMethods) { SMDMethod smdMethodAnnotation = method.getAnnotation(SMDMethod.class); if ((smdMethodAnnotation != null) && !methods.contains(method)) { methods.add(method); } } return true; } }); } Method[] methodResult = new Method[methods.size()]; return methods.toArray(methodResult); }</code><technical_language>methods instead of SMDMethods</technical_language>

Target:
public static Method[] listSMDMethods(Class clazz, boolean ignoreInterfaces) { final List<Method> methods = new LinkedList<>(); if (ignoreInterfaces) { Method[] classMethods = clazz.getMethods(); Arrays.sort(classMethods, (a, b) -> a.toString().compareTo(b.toString())); for (Method method : classMethods) { SMDMethod smdMethodAnnotation = method.getAnnotation(SMDMethod.class); if (smdMethodAnnotation != null) { methods.add(method); } } } else { JSONUtil.visitInterfaces(clazz, new JSONUtil.ClassVisitor() { public boolean visit(Class aClass) { Method[] classMethods = aClass.getMethods(); Arrays.sort(classMethods, (a, b) -> a.toString().compareTo(b.toString())); for (Method method : classMethods) { SMDMethod smdMethodAnnotation = method.getAnnotation(SMDMethod.class); if ((smdMethodAnnotation != null) && !methods.contains(method)) { methods.add(method); } } return true; } }); } Method[] methodResult = new Method[methods.size()]; return methods.toArray(methodResult); }
Source:
<code>public void deleteSubpopulationPermanently(StudyIdentifier studyId, SubpopulationGuid subpopGuid) { checkNotNull(studyId); checkNotNull(subpopGuid); <START> studyConsentService.deleteAllConsentsPermanently(subpopGuid); <END> subpopDao.deleteSubpopulationPermanently(studyId, subpopGuid); cacheProvider.removeObject(CacheKey.subpop(subpopGuid, studyId)); cacheProvider.removeObject(CacheKey.subpopList(studyId)); }</code><technical_language>If do this first, a tiny window loading subpopulation throw error for lack of a consent... ? Do after</technical_language>

Target:
public void deleteSubpopulationPermanently(StudyIdentifier studyId, SubpopulationGuid subpopGuid) { checkNotNull(studyId); checkNotNull(subpopGuid); subpopDao.deleteSubpopulationPermanently(studyId, subpopGuid); studyConsentService.deleteAllConsentsPermanently(subpopGuid); cacheProvider.removeObject(CacheKey.subpop(subpopGuid, studyId)); cacheProvider.removeObject(CacheKey.subpopList(studyId)); }
Source:
<code>public Object evaluate(DeferredObject[] arguments) throws HiveException { result.clear(); try { if (arguments.length == 1 && argumentOI != null && arguments[0] != null) { String ip = ((StringObjectInspector) argumentOI).getPrimitiveJavaObject(arguments[0].get()); result.set(geocode.getCountryCode(ip)); } <START> } catch (Exception ex) { <END> LOG.error(ex); } return result; }</code><technical_language>log rethrow this exception, correct</technical_language>

Target:
public Object evaluate(DeferredObject[] arguments) throws HiveException { result.clear(); if (arguments.length == 1 && argumentOI != null && arguments[0] != null) { String ip = ((StringObjectInspector) argumentOI).getPrimitiveJavaObject(arguments[0].get()); result.set(geocode.getCountryCode(ip)); } return result; }
Source:
<code>private void init() { application = this; registerActivityLifecycleCallbacks(new MyActivityLifecycleCallbacks()); injector = RoboGuice.getOrCreateBaseApplicationInjector((Application) this, RoboGuice.DEFAULT_STAGE, (Module) RoboGuice.newDefaultRoboModule(this), (Module) new EdxDefaultModule(this)); injector.injectMembers(this); if (config.getFabricConfig().isEnabled() && !BuildConfig.DEBUG) { Fabric.with(this, new CrashlyticsCore(), new Answers()); EventBus.getDefault().register(new CrashlyticsCrashReportObserver()); } if (config.getNewRelicConfig().isEnabled()) { NewRelic.withApplicationToken(config.getNewRelicConfig().getNewRelicKey()) .withCrashReportingEnabled(false) .start(this); } <START> registerReceiver(new NetworkConnectivityReceiver(), new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE")); <END> registerReceiver(new NetworkConnectivityReceiver(), new IntentFilter("android.net.wifi.WIFI_STATE_CHANGED")); boolean isOnZeroRatedNetwork = NetworkUtil.isOnZeroRatedNetwork(getApplicationContext(), config); if (!isOnZeroRatedNetwork && config.getFacebookConfig().isEnabled()) { com.facebook.Settings.setApplicationId(config.getFacebookConfig().getFacebookAppId()); } if (needVersionUpgrade(this)) { injector.getInstance(IStorage.class).repairDownloadCompletionData(); } Iconify.with(new FontAwesomeModule()); CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() .setDefaultFontPath("fonts/OpenSans-Regular.ttf") .setFontAttrId(R.attr.fontPath) .build() ); }</code><technical_language>String changed ConnectivityManager.CONNECTIVITY_ACTION</technical_language>

Target:
private void init() { application = this; registerActivityLifecycleCallbacks(new MyActivityLifecycleCallbacks()); injector = RoboGuice.getOrCreateBaseApplicationInjector((Application) this, RoboGuice.DEFAULT_STAGE, (Module) RoboGuice.newDefaultRoboModule(this), (Module) new EdxDefaultModule(this)); injector.injectMembers(this); if (config.getFabricConfig().isEnabled() && !BuildConfig.DEBUG) { Fabric.with(this, new CrashlyticsCore(), new Answers()); EventBus.getDefault().register(new CrashlyticsCrashReportObserver()); } if (config.getNewRelicConfig().isEnabled()) { NewRelic.withApplicationToken(config.getNewRelicConfig().getNewRelicKey()) .withCrashReportingEnabled(false) .start(this); } registerReceiver(new NetworkConnectivityReceiver(), new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); registerReceiver(new NetworkConnectivityReceiver(), new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION)); boolean isOnZeroRatedNetwork = NetworkUtil.isOnZeroRatedNetwork(getApplicationContext(), config); if (!isOnZeroRatedNetwork && config.getFacebookConfig().isEnabled()) { com.facebook.Settings.setApplicationId(config.getFacebookConfig().getFacebookAppId()); } if (needVersionUpgrade(this)) { injector.getInstance(IStorage.class).repairDownloadCompletionData(); } Iconify.with(new FontAwesomeModule()); CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() .setDefaultFontPath("fonts/OpenSans-Regular.ttf") .setFontAttrId(R.attr.fontPath) .build() ); }
Source:
<code>private static SortedSet<ServiceName> findAllMissingServices(Set<ServiceController<?>> missingTransitive, Set<ServiceName> alreadyTracked) { Set<ServiceContainer> examined = new HashSet<ServiceContainer>(); SortedSet<ServiceName> allMissingServices = new TreeSet<ServiceName>(); for (ServiceController<?> controller : missingTransitive) { ServiceContainer container = controller.getServiceContainer(); if (examined.add(container)) { allMissingServices.addAll(findAllMissingServices(container)); } } Set<ServiceName> retain = new HashSet<>(allMissingServices); retain.removeAll(alreadyTracked); <START> if (retain.size() != 0) { <END> allMissingServices.clear(); } return allMissingServices; }</code><technical_language>this ==</technical_language>

Target:
private static SortedSet<ServiceName> findAllMissingServices(Set<ServiceController<?>> missingTransitive, Set<ServiceName> alreadyTracked) { Set<ServiceContainer> examined = new HashSet<ServiceContainer>(); SortedSet<ServiceName> allMissingServices = new TreeSet<ServiceName>(); for (ServiceController<?> controller : missingTransitive) { ServiceContainer container = controller.getServiceContainer(); if (examined.add(container)) { allMissingServices.addAll(findAllMissingServices(container)); } } Set<ServiceName> retain = new HashSet<>(allMissingServices); retain.removeAll(alreadyTracked); if (retain.size() == 0) { allMissingServices.clear(); } return allMissingServices; }
Source:
<code>public void onLiveStreamTranscoderCreate(ILiveStreamTranscoder liveStreamTranscoder, IMediaStream stream) { <START> ((LiveStreamTranscoder)liveStreamTranscoder).addActionListener( <END> new TranscoderActionNotifier(stream)); }</code><technical_language>do need removeActionListener</technical_language>

Target:
public void onLiveStreamTranscoderCreate(ILiveStreamTranscoder liveStreamTranscoder, IMediaStream stream) { logger.info("onLiveStreamTranscoderCreate: " + stream.getSrc()); TranscoderActionNotifier transcoderActionNotifier = new TranscoderActionNotifier(stream); ((LiveStreamTranscoder)liveStreamTranscoder).addActionListener( transcoderActionNotifier); WMSProperties props = stream.getProperties(); synchronized (props) { props.put("TranscoderActionNotifier", transcoderActionNotifier); } }
Source:
<code>private boolean isHTTPAuthErrorMessage(Exception e) { <START> if (e != null && e.getMessage() != null && e.getMessage().contains("401")) { <END> return true; } return false; }</code><technical_language>return this else in if statement anymore</technical_language>

Target:
private boolean isHTTPAuthErrorMessage(Exception e) { return e != null && e.getMessage() != null && e.getMessage().contains("401"); }
Source:
<code>public char getLabel() { final char returnValue; switch (getType()) { case INPUT_VAL: returnValue = buttonData.inputVal; break; case AUTO_CHAR: returnValue = buttonData.autoChar; break; case CUSTOM: returnValue = buttonData.customChar; break; <START> default: returnValue = '*'; END> } return returnValue; }</code><technical_language>This case avoided creating a getLabel(ButtonData buttonData) method in ValueType enum, is overridden enum value. kind of esoterically</technical_language>

Target:
public char getLabel() { return getType().getLabel(getData()); }
Source:
<code>public Optional<String> getVersion() { if (provider.contains("OracleJDK")) { <START> return version.ofNullable(System.getProperty("java.version")); <END> } else { return version.empty(); } }</code><technical_language>do Optional instance version if for is call static methods</technical_language>

Target:
public Optional<String> getVersion() { if (provider.contains("OracleJDK")) { return Optional.ofNullable(System.getProperty("java.version")); } else { return Optional.empty(); } }
Source:
<code>private void getToken() throws Exception { while (TOKEN_STRING == null) { handleResponse(); Thread.sleep(2000); } <START> logger.debug("Token has been acquired: " + TOKEN_STRING); <END> }</code><technical_language>Please change parameterized logging</technical_language>

Target:
private void getToken() throws Exception { while (TOKEN_STRING == null) { handleResponse(); Thread.sleep(2000); } logger.debug("Token has been acquired: '{}'", TOKEN_STRING); }
Source:
<code>private <T> void onRemoteOpMsg(final AvroElasticMemoryMessage msg) { LOG.log(Level.INFO, "onRemoteOpMsg: {0}", msg); final RemoteOpMsg remoteOpMsg = msg.getRemoteOpMsg(); final String origEvalId = remoteOpMsg.getOrigEvalId().toString(); final DataOpType operationType = remoteOpMsg.getOpType(); final String dataType = remoteOpMsg.getDataType().toString(); final List<AvroLongRange> avroLongRangeList = remoteOpMsg.getDataKeyRanges(); final List<UnitIdPair> dataKVPairList = remoteOpMsg.getDataKVPairList(); final String operationId = msg.getOperationId().toString(); final List<LongRange> dataKeyRanges = new ArrayList<>(avroLongRangeList.size()); for (final AvroLongRange avroRange : avroLongRangeList) { dataKeyRanges.add(AvroUtils.fromAvroLongRange(avroRange)); } final Optional<SortedMap<Long, T>> dataKeyValueMap; if (dataKVPairList.isEmpty()) { dataKeyValueMap = Optional.empty(); } else { <START> dataKeyValueMap = Optional.of((SortedMap<Long, T>) new TreeMap<Long, T>()); <END> final Codec codec = serializer.getCodec(dataType); for (final UnitIdPair dataKVPair : dataKVPairList) { final T dataValue = (T) codec.decode(dataKVPair.getUnit().array()); dataKeyValueMap.get().put(dataKVPair.getId(), dataValue); } } final DataOperation<T> operation = new DataOperation<>(Optional.of(origEvalId), operationId, operationType, dataType, dataKeyRanges, dataKeyValueMap); memoryStore.onNext(operation); }</code><technical_language>refactored final SortedMap<Long, T> x = new TreeMap<>(); // decode values put in x dataKeyValueMap = Optional.of(x); still, fully convinced want SortedMap</technical_language>

Target:
private <T> void onRemoteOpMsg(final AvroElasticMemoryMessage msg) { LOG.log(Level.INFO, "onRemoteOpMsg: {0}", msg); final RemoteOpMsg remoteOpMsg = msg.getRemoteOpMsg(); final String origEvalId = remoteOpMsg.getOrigEvalId().toString(); final DataOpType operationType = remoteOpMsg.getOpType(); final String dataType = remoteOpMsg.getDataType().toString(); final List<AvroLongRange> avroLongRangeList = remoteOpMsg.getDataKeyRanges(); final List<UnitIdPair> dataKVPairList = remoteOpMsg.getDataKVPairList(); final String operationId = msg.getOperationId().toString(); final List<LongRange> dataKeyRanges = new ArrayList<>(avroLongRangeList.size()); for (final AvroLongRange avroRange : avroLongRangeList) { dataKeyRanges.add(AvroUtils.fromAvroLongRange(avroRange)); } final Optional<SortedMap<Long, T>> dataKeyValueMap; if (operationType.equals(DataOpType.PUT)) { final SortedMap<Long, T> dataMap = new TreeMap<>(); dataKeyValueMap = Optional.of(dataMap); final Codec codec = serializer.getCodec(dataType); for (final UnitIdPair dataKVPair : dataKVPairList) { final T dataValue = (T) codec.decode(dataKVPair.getUnit().array()); dataMap.put(dataKVPair.getId(), dataValue); } } else { dataKeyValueMap = Optional.empty(); } final DataOperation<T> operation = new DataOperation<>(Optional.of(origEvalId), operationId, operationType, dataType, dataKeyRanges, dataKeyValueMap); memoryStore.onNext(operation); }
Source:
<code>private IParserSettings createParserSettings(IProject project) { ParserSettings parserSettings = new ParserSettings(); <START> ICProject cProject = CoreModel.getDefault().getCModel().getCProject(project.getName()); <END> if (CCorePreferenceConstants.getPreference(CCorePreferenceConstants.SCALABILITY_SKIP_TRIVIAL_EXPRESSIONS, cProject, CCorePreferenceConstants.DEFAULT_SCALABILITY_SKIP_TRIVIAL_EXPRESSIONS)) { int maximumNumberOfTrivialExpressionsInAggregateInitializers = CCorePreferenceConstants.getPreference( CCorePreferenceConstants.SCALABILITY_MAXIMUM_TRIVIAL_EXPRESSIONS, cProject, CCorePreferenceConstants.DEFAULT_SCALABILITY_MAXIMUM_TRIVIAL_EXPRESSIONS); parserSettings.setMaximumTrivialExpressionsInAggregateInitializers(maximumNumberOfTrivialExpressionsInAggregateInitializers); } return parserSettings; }</code><technical_language>"..getName()" is redundant</technical_language>

Target:
private IParserSettings createParserSettings(IProject project) { ParserSettings parserSettings = new ParserSettings(); ICProject cProject = CModelManager.getDefault().create(project); if (CCorePreferenceConstants.getPreference(CCorePreferenceConstants.SCALABILITY_SKIP_TRIVIAL_EXPRESSIONS, cProject, CCorePreferenceConstants.DEFAULT_SCALABILITY_SKIP_TRIVIAL_EXPRESSIONS)) { int maximumNumberOfTrivialExpressionsInAggregateInitializers = CCorePreferenceConstants.getPreference( CCorePreferenceConstants.SCALABILITY_MAXIMUM_TRIVIAL_EXPRESSIONS, cProject, CCorePreferenceConstants.DEFAULT_SCALABILITY_MAXIMUM_TRIVIAL_EXPRESSIONS); parserSettings.setMaximumTrivialExpressionsInAggregateInitializers(maximumNumberOfTrivialExpressionsInAggregateInitializers); } return parserSettings; }
Source:
<code>private T createExtension(String name) { Class<?> clazz = getExtensionClasses().get(name); if (clazz == null) { throw findException(name); } try { EXTENSION_INSTANCES.computeIfAbsent(clazz, c -> { try { return c.newInstance(); } catch (Throwable t) { throw new IllegalStateException("Extension instance(name: " + name + ", class: " + type + ") could not be instantiated: " + t.getMessage(), t); <START> } <END> }); T instance = (T) EXTENSION_INSTANCES.get(clazz); injectExtension(instance); Set<Class<?>> wrapperClasses = cachedWrapperClasses; if (wrapperClasses != null && !wrapperClasses.isEmpty()) { for (Class<?> wrapperClass : wrapperClasses) { instance = injectExtension((T) wrapperClass.getConstructor(type).newInstance(instance)); } } return instance; } catch (Throwable t) { throw new IllegalStateException("Extension instance(name: " + name + ", class: " + type + ") could not be instantiated: " + t.getMessage(), t); } }</code><technical_language>this instead of string concatination. throw new IllegalStateException(String.format("Extension instance(name: %s,class: %s instantiated: %s",name,type,t.getMessage),t);</technical_language>

Target:
private T createExtension(String name) { Class<?> clazz = getExtensionClasses().get(name); if (clazz == null) { throw findException(name); } try { T instance = (T) EXTENSION_INSTANCES.computeIfAbsent(clazz, c -> { try { return c.newInstance(); } catch (Throwable t) { throw new IllegalStateException("Extension instance(name: " + name + ", class: " + type + ") could not be instantiated: " + t.getMessage(), t); } }); injectExtension(instance); Set<Class<?>> wrapperClasses = cachedWrapperClasses; if (wrapperClasses != null && !wrapperClasses.isEmpty()) { for (Class<?> wrapperClass : wrapperClasses) { instance = injectExtension((T) wrapperClass.getConstructor(type).newInstance(instance)); } } return instance; } catch (Throwable t) { throw new IllegalStateException("Extension instance(name: " + name + ", class: " + type + ") could not be instantiated: " + t.getMessage(), t); } }
Source:
<code>protected void executeVmCommand() { AddCustomValue("InterfaceType", (VmInterfaceType.forValue(getParameters().getInterface().getType()).getDescription()).toString()); this.setVmName(getVmStaticDAO().get(getParameters().getVmId()).getVmName()); if (StringUtils.isEmpty(getMacAddress())) { getParameters().getInterface().setMacAddress(MacPoolManager.getInstance().allocateNewMac()); } boolean succeeded = false; try { getParameters().getInterface().setSpeed( VmInterfaceType.forValue( getParameters().getInterface().getType()).getSpeed()); getParameters().getInterface().setId(Guid.NewGuid()); getParameters().getInterface().setVmId(getParameters().getVmId()); TransactionSupport.executeInNewTransaction(new TransactionMethod<Void>() { @Override public Void runInTransaction() { addInterfaceToDb(getParameters().getInterface()); addInterfaceDeviceToDb(); getCompensationContext().stateChanged(); return null; } }); if (getParameters().getInterface().isPlugged()) { succeeded = activateOrDeactivateNic(getParameters().getInterface().getId(), PlugAction.PLUG); } else { succeeded = true; } } finally { setSucceeded(succeeded); if (!succeeded) { <START> MacPoolManager.getInstance().freeMac(getParameters().getInterface().getMacAddress()); <END> } } }</code><technical_language>this change</technical_language>

Target:
protected void executeVmCommand() { AddCustomValue("InterfaceType", (VmInterfaceType.forValue(getParameters().getInterface().getType()).getDescription()).toString()); this.setVmName(getVmStaticDAO().get(getParameters().getVmId()).getVmName()); boolean succeeded = false; boolean macAddedToPool = false; try { if (StringUtils.isEmpty(getMacAddress())) { getParameters().getInterface().setMacAddress(MacPoolManager.getInstance().allocateNewMac()); macAddedToPool = true; } else { macAddedToPool = addMacToPool(getMacAddress()); } getParameters().getInterface().setSpeed( VmInterfaceType.forValue( getParameters().getInterface().getType()).getSpeed()); getParameters().getInterface().setId(Guid.NewGuid()); getParameters().getInterface().setVmId(getParameters().getVmId()); TransactionSupport.executeInNewTransaction(new TransactionMethod<Void>() { @Override public Void runInTransaction() { addInterfaceToDb(getParameters().getInterface()); addInterfaceDeviceToDb(); getCompensationContext().stateChanged(); return null; } }); if (getParameters().getInterface().isPlugged()) { succeeded = activateOrDeactivateNic(getParameters().getInterface().getId(), PlugAction.PLUG); } else { succeeded = true; } } finally { setSucceeded(succeeded); if (macAddedToPool && !succeeded) { MacPoolManager.getInstance().freeMac(getMacAddress()); } } }
Source:
<code><START> private static void removeUserSystemProperties(BackendlessUser user) <END> { user.removeProperty( HeadersManager.HeadersEnum.USER_TOKEN_KEY.getHeader() ); user.removeProperty( USER_REGISTERED_KEY ); }</code><technical_language>is reason duplicate method in places. create a static method in BackendlessUser everywhere</technical_language>

Target:
static void removeUserSystemProperties(BackendlessUser user) { user.removeProperty( HeadersManager.HeadersEnum.USER_TOKEN_KEY.getHeader() ); user.removeProperty( USER_REGISTERED_KEY ); }
Source:
<code>private boolean sample(Span object) { <START> if (sampler != null && sampler.sample(object.getName(), <END> UUID.fromString(object.getTraceId()).getLeastSignificantBits(), object.getDuration())) { return true; } discardedSpansBySampler.inc(); return false; }</code><technical_language>if marked Nullable, dont do null check if do null check default true false</technical_language>

Target:
private boolean sample(Span object) { if (sampler.sample(object.getName(), UUID.fromString(object.getTraceId()).getLeastSignificantBits(), object.getDuration())) { return true; } discardedSpansBySampler.inc(); return false; }
Source:
<code>private Map<String, AnalyzerDef> createDefaultAnalyzerDefinitions() { LuceneAnalyzerDefinitionRegistryBuilderImpl builder = new LuceneAnalyzerDefinitionRegistryBuilderImpl(); String providerClassName = cfg.getProperty( Environment.ANALYZER_DEFINITION_PROVIDER ); if ( providerClassName != null ) { LuceneAnalyzerDefinitionProvider provider; try { <START> Class<?> providerClazz = ClassLoaderHelper.classForName( providerClassName, serviceManager ); <END> provider = (LuceneAnalyzerDefinitionProvider) ReflectionHelper.createInstance( providerClazz, true ); } catch (RuntimeException e) { throw LOG.invalidLuceneAnalyzerDefinitionProvider( providerClassName, e ); } try { provider.register( builder ); } catch (SearchException e) { throw e; } catch (RuntimeException e) { throw LOG.invalidLuceneAnalyzerDefinitionProvider( providerClassName, e ); } } return builder.build(); }</code><technical_language>here. ClassLoaderHelper.instanceFromName instead</technical_language>

Target:
private Map<String, AnalyzerDef> createDefaultAnalyzerDefinitions() { LuceneAnalyzerDefinitionRegistryBuilderImpl builder = new LuceneAnalyzerDefinitionRegistryBuilderImpl(); String providerClassName = cfg.getProperty( Environment.ANALYZER_DEFINITION_PROVIDER ); if ( providerClassName != null ) { LuceneAnalyzerDefinitionProvider provider; try { Class<?> providerClazz = ClassLoaderHelper.classForName( providerClassName, serviceManager ); provider = (LuceneAnalyzerDefinitionProvider) ReflectionHelper.createInstance( providerClazz, true ); } catch (RuntimeException e) { throw log.invalidLuceneAnalyzerDefinitionProvider( providerClassName, e ); } try { provider.register( builder ); } catch (SearchException e) { throw e; } catch (RuntimeException e) { throw log.invalidLuceneAnalyzerDefinitionProvider( providerClassName, e ); } } return builder.build(); }
Source:
<code>public Collection<ExternalVnicProfileMapping> mapFromModel(VnicProfileMappings vnicProfileMappings) { return vnicProfileMappings != null && vnicProfileMappings.isSetVnicProfileMappings() ? vnicProfileMappings.getVnicProfileMappings() .stream() .map(this::mapSingleMappingEntry) <START> .collect(Collectors.toList()) <END> : Collections.emptyList(); }</code><technical_language>static import</technical_language>

Target:
public Collection<ExternalVnicProfileMapping> mapFromModel(VnicProfileMappings vnicProfileMappings) { return isVnicProfileMappingSupplied(vnicProfileMappings) ? mapMultipleMappings(vnicProfileMappings) : Collections.emptyList(); }
Source:
<code>public List<T> getPossible(MediaType accept) { accept = new MediaType(accept.getType().toLowerCase(), accept.getSubtype().toLowerCase(), accept.getParameters()); List<Entry<T>> matches = new ArrayList<Entry<T>>(); if (accept.isWildcardType()) { ArrayList<T> copy = new ArrayList<T>(); <START> copy.addAll(convert(all)); <END> return copy; } else { matches.addAll(wildcards); SubtypeMap<T> indexed = index.get(accept.getType()); if (indexed != null) { matches.addAll(indexed.getPossible(accept)); } } Collections.sort(matches); return convert(matches); }</code><technical_language>If this correctly, idea is avoid List<T> = new ArrayList<T>() a member of MediaTypeMap computed *if* needed. get rid of convert(List<Entry<T>> list) method create return (ArrayList<T> copy) double ArrayList creation</technical_language>

Target:
public List<T> getPossible(MediaType accept) { accept = new MediaType(accept.getType().toLowerCase(), accept.getSubtype().toLowerCase(), accept.getParameters()); List<Entry<T>> matches = new ArrayList<Entry<T>>(); if (accept.isWildcardType()) { return convert(all); } else { matches.addAll(wildcards); SubtypeMap<T> indexed = index.get(accept.getType()); if (indexed != null) { matches.addAll(indexed.getPossible(accept)); } } Collections.sort(matches); return convert(matches); }
Source:
<code>HostLocation getHostLocation() { String dataCenter = "Unknown"; String rack = "Unknown"; String physicalHost = "Unknown"; try { Config config = ConfigFactory.parseFile(file); if (config.hasPath("dataCenter")) { dataCenter = config.getString("dataCenter"); } if (config.hasPath("rack")) { rack = config.getString("rack"); } if (config.hasPath("physicalHost")) { physicalHost = config.getString("physicalHost"); } } catch (Exception e) { <START> log.warn("error getting host location from {}: {}", file.getName(), e); <END> } return new HostLocation(dataCenter, rack, physicalHost); }</code><technical_language>this error</technical_language>

Target:
public HostLocation getHostLocation() { String dataCenter = "Unknown"; String rack = "Unknown"; String physicalHost = "Unknown"; try { Config config = ConfigFactory.parseFile(file); if (config.hasPath("dataCenter")) { dataCenter = config.getString("dataCenter"); } if (config.hasPath("rack")) { rack = config.getString("rack"); } if (config.hasPath("physicalHost")) { physicalHost = config.getString("physicalHost"); } } catch (Exception e) { log.warn("error getting host location from {}: ", file.getName(), e); } return new HostLocation(dataCenter, rack, physicalHost); }
Source:
<code><START> void cancelAdditional() { <END> transaction.setLoanId(loans.get(position).getLoan().getLoanId()); transaction.setTransactionAmount((!etCharges.getText().toString().isEmpty() ? Double.parseDouble(etCharges.getText().toString()) : 0) + (!etTotalDues.getText().toString().isEmpty() ? Double.parseDouble(etTotalDues.getText().toString()) : 0)); tableAdditional.setVisibility(View.GONE); transaction.setPaymentTypeId(null); transaction.setAccountNumber(null); transaction.setCheckNumber(null); transaction.setRoutingCode(null); transaction.setReceiptNumber(null); transaction.setBankNumber(null); sheetItemClickListener.onSaveAdditionalItem(transaction, position); }</code><technical_language>methods local this class, private, methods too</technical_language>

Target:
private void cancelAdditional() { transaction.setLoanId(loans.get(position).getLoan().getLoanId()); transaction.setTransactionAmount((!etCharges.getText().toString().isEmpty() ? Double.parseDouble(etCharges.getText().toString()) : 0) + (!etTotalDues.getText().toString().isEmpty() ? Double.parseDouble(etTotalDues.getText().toString()) : 0)); tableAdditional.setVisibility(View.GONE); transaction.setPaymentTypeId(null); transaction.setAccountNumber(null); transaction.setCheckNumber(null); transaction.setRoutingCode(null); transaction.setReceiptNumber(null); transaction.setBankNumber(null); sheetItemClickListener.onSaveAdditionalItem(transaction, position); }
Source:
<code>public PagedIterable<GHStargazer> listStargazers() { return new PagedIterable<GHStargazer>() { @Override public PagedIterator<GHStargazer> _iterator(int pageSize) { Requester requester = root.retrieve(); <START> requester.setHeader("Accept", "application/vnd.github.v3.star+json"); <END> return new PagedIterator<GHStargazer>(requester.asIterator(getApiTailUrl("stargazers"), GHStargazer[].class, pageSize)) { @Override protected void wrapUp(GHStargazer[] page) { for (GHStargazer c : page) { c.wrapUp(GHRepository.this); } } }; } }; }</code><technical_language>continue working previous APIs? E.g. GitHub Enterprise instances</technical_language>

Target:
public PagedIterable<GHUser> listStargazers() { return listUsers("stargazers"); }
Source:
<code>public TimezoneCachingTest(String name) { super(name); try { <START> Class.forName("org.postgresql.Driver"); <END> } catch (Exception ex) { } }</code><technical_language>Why's that</technical_language>

Target:
public TimezoneCachingTest(String name) { super(name); }
Source:
<code>public Response getCharge(@Auth String accountId, @PathParam(PAYMENT_KEY) String chargeId, @Context UriInfo uriInfo) { logger.info("received get payment request: [ ]", chargeId); <START> Response connectorResponse = client.target(connectorUrl + "/v1/api/charges" + "/" + chargeId) <END> .request() .get(); return responseFrom(uriInfo, connectorResponse, HttpStatus.SC_OK, (locationUrl, data) -> Response.ok(data), data -> notFoundResponse(logger, data)); }</code><technical_language>extracted "/v1/api/charges"</technical_language>

Target:
public Response getCharge(@Auth String accountId, @PathParam(PAYMENT_KEY) String chargeId, @Context UriInfo uriInfo) { logger.info("received get payment request: [ ]", chargeId); Response connectorResponse = client.target(connectorUrl + CONNECTOR_CHARGES_RESOURCE + "/" + chargeId) .request() .get(); return responseFrom(uriInfo, connectorResponse, HttpStatus.SC_OK, (locationUrl, data) -> Response.ok(data), data -> notFoundResponse(logger, data)); }
Source:
<code>public IClient build() { try { TrustManagerFactory trustManagerFactory = initTrustManagerFactory(certificateAlias, certificate); X509TrustManager trustManager = getCurrentTrustManager(trustManagerFactory); SSLContext sslContext = SSLUtils.getSSLContext(trustManager); ResponseCodeInterceptor responseCodeInterceptor = new ResponseCodeInterceptor(); OpenShiftAuthenticator authenticator = new OpenShiftAuthenticator(); OkHttpClient.Builder builder = new OkHttpClient.Builder() .addInterceptor(responseCodeInterceptor) .authenticator(authenticator) .readTimeout(readTimeout, readTimeoutUnit) .writeTimeout(writeTimeout, writeTimeoutUnit) .connectTimeout(connectTimeout, connectTimeoutUnit) .hostnameVerifier(this.sslCertificateCallback) <START> .followRedirects(false) <END> .followSslRedirects(false) .sslSocketFactory(sslContext.getSocketFactory(), trustManager); OkHttpClient okClient = builder.build(); IResourceFactory factory = defaultIfNull(resourceFactory, new ResourceFactory(null)); AuthorizationContext authContext = new AuthorizationContext(token, userName, password); DefaultClient client = new DefaultClient(new URL(this.baseUrl), okClient, factory, null, authContext); authContext.setClient(client); responseCodeInterceptor.setClient(client); authenticator.setClient(client); authenticator.setOkClient(okClient); return client; } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException | CertificateException | IOException e) { throw new OpenShiftException(e, "Unable to initialize client"); } }</code><technical_language>redirects? frequently allow endpoints evolve while staying compatible (and other useful usecases)</technical_language>

Target:
public IClient build() { try { TrustManagerFactory trustManagerFactory = initTrustManagerFactory(certificateAlias, certificate); X509TrustManager trustManager = getCurrentTrustManager(trustManagerFactory); SSLContext sslContext = SSLUtils.getSSLContext(trustManager); ResponseCodeInterceptor responseCodeInterceptor = new ResponseCodeInterceptor(); OpenShiftAuthenticator authenticator = new OpenShiftAuthenticator(); OkHttpClient.Builder builder = new OkHttpClient.Builder() .addInterceptor(responseCodeInterceptor) .authenticator(authenticator) .readTimeout(readTimeout, readTimeoutUnit) .writeTimeout(writeTimeout, writeTimeoutUnit) .connectTimeout(connectTimeout, connectTimeoutUnit) .hostnameVerifier(this.sslCertificateCallback) .sslSocketFactory(sslContext.getSocketFactory(), trustManager); OkHttpClient okClient = builder.build(); IResourceFactory factory = defaultIfNull(resourceFactory, new ResourceFactory(null)); AuthorizationContext authContext = new AuthorizationContext(token, userName, password); DefaultClient client = new DefaultClient(new URL(this.baseUrl), okClient, factory, null, authContext); authContext.setClient(client); responseCodeInterceptor.setClient(client); authenticator.setClient(client); authenticator.setOkClient(okClient); return client; } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException | CertificateException | IOException e) { throw new OpenShiftException(e, "Unable to initialize client"); } }
Source:
<code>static AssertionError counterexampleFound( String propertyName, <START> Object[] args, <END> long[] seeds, AssertionError e) { final String message = "Property named '%s' failed%s%n" + "With arguments: %s%n" + "Seeds for reproduction: %s"; return new AssertionError( String.format( message, propertyName, e.getMessage() == null ? ":" : " (" + e.getMessage() + "):", Arrays.deepToString(args), Arrays.toString(seeds)), e); }</code><technical_language>prefer declare locals final</technical_language>

Target:
static AssertionError counterexampleFound( String propertyName, Object[] args, long[] seeds, AssertionError e) { String message = "Property named '%s' failed%s%n" + "With arguments: %s%n" + "Seeds for reproduction: %s"; return new AssertionError( String.format( message, propertyName, e.getMessage() == null ? ":" : " (" + e.getMessage() + "):", Arrays.deepToString(args), Arrays.toString(seeds)), e); }
Source:
<code>public void onMapReady(@NonNull final MapboxMap mapboxMap) { BathymetryActivity.this.mapboxMap = mapboxMap; mapboxMap.setStyle(Style.OUTDOORS, new Style.OnStyleLoaded() { @Override public void onStyleLoaded(@NonNull Style style) { mapboxMap.setLatLngBoundsForCameraTarget(LAKE_BOUNDS); mapboxMap.getStyle().removeLayer("water-label"); featureCollection = FeatureCollection.fromJson(loadGeoJsonFromAsset("bathymetry-data.geojson")); GeoJsonSource geoJsonSource = new GeoJsonSource(geojsonSourceId, featureCollection); mapboxMap.getStyle().addSource(geoJsonSource); <START> setUpDepthFillLayers(); <END> setUpDepthNumberSymbolLayer(); } }); }</code><technical_language>Fixed. Passing style argument for setUpDepthFillLayers() setUpDepthNumberSymbolLayer()</technical_language>

Target:
public void onMapReady(@NonNull final MapboxMap mapboxMap) { mapboxMap.setStyle(Style.OUTDOORS, new Style.OnStyleLoaded() { @Override public void onStyleLoaded(@NonNull Style style) { mapboxMap.setLatLngBoundsForCameraTarget(LAKE_BOUNDS); style.removeLayer("water-label"); featureCollection = FeatureCollection.fromJson(loadGeoJsonFromAsset( "bathymetry-data.geojson")); style.addSource(new GeoJsonSource(GEOJSON_SOURCE_ID, featureCollection)); setUpDepthFillLayers(style); setUpDepthNumberSymbolLayer(style); } }); }
Source:
<code>private Set<String> getMemberRoles(GatewayConfig gatewayConfig, SaltConnector sc) { Map<String, JsonNode> roles = SaltStates.getGrains(sc, new HostList(List.of(gatewayConfig.getHostname())), "roles"); return roles.entrySet().stream().findFirst() <START> .map(Entry::getValue) <END> .map(JsonNode::elements) .map(IteratorUtils::toList) .map(l -> (Set<String>) l.stream() .map(i -> ((JsonNode) i).asText()) .collect(Collectors.toSet()) ).orElse(Collections.emptySet()); }</code><technical_language>do stream entryset if need values</technical_language>

Target:
private Set<String> getMemberRoles(GatewayConfig gatewayConfig, SaltConnector sc) { Map<String, JsonNode> roles = SaltStates.getGrains(sc, new HostList(List.of(gatewayConfig.getHostname())), "roles"); return roles.values().stream().findFirst() .map(GrainsJsonPropertyUtil::getPropertySet) .orElse(Collections.emptySet()); }
Source:
<code><START> private boolean containsPolyNullNotAtTopLevel(AnnotatedTypeMirror t) { <END> switch (t.getKind()) { case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FLOAT: case INT: case LONG: case SHORT: return false; case ARRAY: AnnotatedArrayType at = (AnnotatedArrayType) t; AnnotatedTypeMirror component = at.getComponentType(); return component.hasAnnotation(POLYNULL) || containsPolyNullNotAtTopLevel(component); case DECLARED: AnnotatedDeclaredType dt = (AnnotatedDeclaredType) t; for (AnnotatedTypeMirror typeArg : dt.getTypeArguments()) { if (typeArg.hasAnnotation(POLYNULL) || containsPolyNullNotAtTopLevel(typeArg)) { return true; } } return false; case WILDCARD: case TYPEVAR: return true; default: throw new BugInCF("Unexpected TypeKind %s for %s", t.getKind(), t); } }</code><technical_language>do this a SimpleAnnotatedTypeScanner: new SimpleAnnotatedTypeScanner<>( (type, p) -> type.hasAnnotation(POLYNULL), Boolean::logicalOr, false);</technical_language>

Target:
private boolean containsPolyNullNotAtTopLevel(AnnotatedTypeMirror t) { return new ContainsPolyNullNotAtTopLevelScanner().visit(t); }
Source:
<code>protected InputStream doGetInputStream() throws Exception { if (this.stat == null) { throw new FileSystemException("vfs.provider/read-not-file.error", getName()); } <START> final byte[] data = (this.stat.getDataLength() == 0) ? new byte[0] <END> : framework.getData().forPath(this.path); return new ByteArrayInputStream(data); }</code><technical_language>Extra ()'s superfluous</technical_language>

Target:
protected InputStream doGetInputStream() throws Exception { if (this.stat == null) { throw new FileSystemException("vfs.provider/read-not-file.error", getName()); } final byte[] data = this.stat.getDataLength() == 0 ? new byte[0] : framework.getData().forPath(this.path); return new ByteArrayInputStream(data); }
Source:
<code>protected void doHealthCheck(final Health.Builder builder) { <START> val systemUsage = metrics.metric("system.cpu.usage", null).getMeasurements().get(0).getValue(); <END> val systemLoad = metrics.metric("system.load.average.1m", null).getMeasurements().get(0).getValue(); val processUsage = metrics.metric("process.cpu.usage", null).getMeasurements().get(0).getValue(); val jvmUsed = metrics.metric("jvm.memory.used", null).getMeasurements().get(0).getValue(); val jvmCommitted = metrics.metric("jvm.memory.committed", null).getMeasurements().get(0).getValue(); val heapUsed = metrics.metric("jvm.memory.used", List.of("area:heap")).getMeasurements().get(0).getValue(); val heapCommitted = metrics.metric("jvm.memory.committed", List.of("area:heap")).getMeasurements().get(0).getValue(); val uptime = metrics.metric("process.uptime", null).getMeasurements().get(0).getValue(); val reqs = metrics.metric("http.server.requests", null); builder .withDetail("systemUsage", systemUsage) .withDetail("systemLoad", systemLoad) .withDetail("processUsage", processUsage) .withDetail("jvmUsed", jvmUsed) .withDetail("jvmCommitted", jvmCommitted) .withDetail("heapUsed", heapUsed) .withDetail("heapCommitted", heapCommitted) .withDetail("uptime", uptime) .withDetail("requests", reqs != null ? reqs.getMeasurements().get(0).getValue() : 0) .withDetail("maxRequest", reqs != null ? reqs.getMeasurements().get(2).getValue() : 0); if (systemLoad > threshold) { builder.status("WARN"); } else { builder.status(Status.UP); } }</code><technical_language>Refactor a smaller method getMeMetricsFor(metrics, "system.cpu.usage"), etc</technical_language>

Target:
protected void doHealthCheck(final Health.Builder builder) { val systemLoad = getMetricsFor("system.load.average.1m"); builder .withDetail("systemUsage", getMetricsFor("system.cpu.usage")) .withDetail("systemLoad", getMetricsFor("system.load.average.1m")) .withDetail("processUsage", getMetricsFor("process.cpu.usage")) .withDetail("jvmUsed", getMetricsFor("jvm.memory.used")) .withDetail("jvmCommitted", getMetricsFor("jvm.memory.committed")) .withDetail("heapUsed", getMetricsFor("jvm.memory.used", List.of("area:heap"))) .withDetail("heapCommitted", getMetricsFor("jvm.memory.committed", List.of("area:heap"))) .withDetail("uptime", getMetricsFor("process.uptime")) .withDetail("requests", getMetricsFor("http.server.requests")) .withDetail("maxRequest", getMetricsFor("http.server.requests", 2)); if (systemLoad > threshold) { builder.status("WARN"); } else { builder.status(Status.UP); } }