auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void started() { AdministrationService administrationService= org.openmrs.api.context.Context.getAdministrationService(); AijarService aijarService= org.openmrs.api.context.Context.getService(AijarService.class); <START> if (administrationService.getGlobalProperty(GP_NHPI).equalsIgnoreCase(GP_NHPI_VALUE)) { <END> aijarService.setAlertForAllUsers(GP_NHPI_DEFAULT_ALERT_MESSAGE); log.info("Creating alert "+GP_NHPI_DEFAULT_ALERT_MESSAGE); } if (administrationService.getGlobalProperty(GP_HEALTH_CENTER_NAME).equalsIgnoreCase(GP_HEALTH_CENTER_NAME_VALUE)) { aijarService.setAlertForAllUsers(GP_HEALTH_CENTER_NAME_DEFAULT_ALERT_MESSAGE); log.info("Creating alert "+GP_HEALTH_CENTER_NAME_DEFAULT_ALERT_MESSAGE); } if (administrationService.getGlobalProperty(GP_DHIS2).equalsIgnoreCase(GP_DHIS2_VALUE)) { aijarService.setAlertForAllUsers(GP_DHIS2_DEFAULT_ALERT_MESSAGE); log.info("Creating alert "+GP_DHIS2_DEFAULT_ALERT_MESSAGE); } }</code><technical_language>@slubwama Instead of 3 If statements create a private method sends alerts call instead</technical_language>

Target:
public void started() { createAlertWhenDefaultIsNotSet(GP_NHPI, GP_NHPI_VALUE, GP_NHPI_DEFAULT_ALERT_MESSAGE); createAlertWhenDefaultIsNotSet(GP_HEALTH_CENTER_NAME, GP_HEALTH_CENTER_NAME_VALUE, GP_HEALTH_CENTER_NAME_DEFAULT_ALERT_MESSAGE); createAlertWhenDefaultIsNotSet(GP_DHIS2, GP_DHIS2_VALUE, GP_DHIS2_DEFAULT_ALERT_MESSAGE); }
Source:
<code>public void decapitalizeShouldReturnDecapizalizedWordOnTurkishLocale() { Locale.setDefault(new Locale("tr", "TR")); <START> assertEquals( StringHelper.decapitalize( "IsIsolationLevelGuaranteed" ), "isIsolationLevelGuaranteed" ); <END> }</code><technical_language>get default locale changing restore test? cleaner state consistent test</technical_language>

Target:
public void decapitalizeShouldReturnDecapizalizedWordOnTurkishLocale() { Locale defaultLocale = Locale.getDefault(); Locale.setDefault( new Locale( "tr" , "TR" ) ); assertEquals( StringHelper.decapitalize( "IsIsolationLevelGuaranteed" ), "isIsolationLevelGuaranteed" ); Locale.setDefault( defaultLocale ); }
Source:
<code>private void addProfile(MultipartHttpServletRequest request, ModelMap model) { List<String> lines = new ArrayList<>(); MultipartFile mpf = request.getFile("file"); if (mpf != null) { String message = ""; String filename = mpf.getOriginalFilename(); try { File tempFile = File.createTempFile("profile", null); mpf.transferTo(tempFile); <START> boolean exResult = execute(VALIDATE_CMD, tempFile, lines); <END> if (exResult) { filename = getNextVersionedFilename(mpf.getOriginalFilename()); File newFile = new File(profileDir, filename); FileUtils.moveFile(tempFile, newFile); model.addAttribute("success", true); message = "Success adding profile: "; } else { model.addAttribute("success", false); message = "Error adding profile: "; } } catch (Exception e) { model.addAttribute("success", false); message = "Problem saving uploaded profile: "; lines.add(e.getMessage()); log.error("Problem saving uploaded profile", e); } finally { model.addAttribute("operation", "add"); model.addAttribute("message", message + filename); model.addAttribute("filename", filename); model.addAttribute("output", StringUtils.join(lines, "\n")); } } }</code><technical_language>exResult is else, is write if (execute(...)) { ... }</technical_language>

Target:
private void addProfile(MultipartHttpServletRequest request, ModelMap model) { List<String> lines = new ArrayList<>(); MultipartFile mpf = request.getFile("file"); if (mpf != null) { String message = ""; String filename = mpf.getOriginalFilename(); try { File tempFile = File.createTempFile("profile", null); mpf.transferTo(tempFile); boolean exResult = execute(VALIDATE_CMD, tempFile, lines); if (exResult) { filename = getNextVersionedFilename(filename); File newFile = new File(profileDir, filename); FileUtils.moveFile(tempFile, newFile); model.addAttribute("success", true); message = "Success adding profile: "; } else { model.addAttribute("success", false); message = "Error adding profile: "; } } catch (Exception e) { model.addAttribute("success", false); message = "Problem saving uploaded profile: "; lines.add(e.getMessage()); log.error("Problem saving uploaded profile", e); } finally { model.addAttribute("operation", "add"); model.addAttribute("message", message + filename); model.addAttribute("filename", filename); model.addAttribute("output", StringUtils.join(lines, "\n")); } } }
Source:
<code>protected Object cleanSimplePropertyValue( Class<? extends PersistableBusinessObject> businessObjectClass, RassPropertyDefinition propertyMapping, Object propertyValue) { if (propertyValue instanceof String) { <START> propertyValue = cleanStringValue(businessObjectClass, propertyMapping, (String) propertyValue); <END> } else if (propertyValue instanceof Date) { propertyValue = cleanDateValue(businessObjectClass, propertyMapping.getBoPropertyName(), (Date) propertyValue); } else if (propertyValue instanceof Boolean) { return cleanBooleanValue(businessObjectClass, propertyMapping.getBoPropertyName(), (Boolean) propertyValue); } else if (LOG.isDebugEnabled()) { String propertyNameForLogging = StringUtils.defaultIfBlank(propertyMapping.getBoPropertyName(), "[Blank]"); if (ObjectUtils.isNull(propertyValue)) { LOG.debug("cleanSimplePropertyValue, property " + propertyNameForLogging + " is null on business object " + businessObjectClass.getName()); } else { LOG.debug("cleanSimplePropertyValue, no cleaning for property " + propertyNameForLogging + " on business object " + businessObjectClass.getName() + " (value: " + propertyValue.toString() + ")"); } } return propertyValue; }</code><technical_language>If feasible, want avoid reassigning method argument</technical_language>

Target:
protected Object cleanSimplePropertyValue( Class<? extends PersistableBusinessObject> businessObjectClass, RassPropertyDefinition propertyMapping, Object propertyValue) { Object cleanedValue = propertyValue; if (propertyValue instanceof String) { cleanedValue = cleanStringValue(businessObjectClass, propertyMapping, (String) propertyValue); } else if (propertyValue instanceof Date) { cleanedValue = cleanDateValue(businessObjectClass, propertyMapping.getBoPropertyName(), (Date) propertyValue); } else if (propertyValue instanceof Boolean) { cleanedValue = cleanBooleanValue(businessObjectClass, propertyMapping.getBoPropertyName(), (Boolean) propertyValue); } else if (LOG.isDebugEnabled()) { String propertyNameForLogging = StringUtils.defaultIfBlank(propertyMapping.getBoPropertyName(), "[Blank]"); if (ObjectUtils.isNull(propertyValue)) { LOG.debug("cleanSimplePropertyValue, property " + propertyNameForLogging + " is null on business object " + businessObjectClass.getName()); } else { LOG.debug("cleanSimplePropertyValue, no cleaning for property " + propertyNameForLogging + " on business object " + businessObjectClass.getName() + " (value: " + propertyValue.toString() + ")"); } } return cleanedValue; }
Source:
<code>public void testElideGetInvalidKey() throws Exception { DataStore store = mock(DataStore.class); Elide elide = getElide(store, dictionary, MOCK_AUDIT_LOGGER); <START> MultivaluedMap<String, String> headers = new MultivaluedHashMap<>(); <END> headers.putSingle("fields[testModel]", "field"); headers.putSingle("?filter", "field"); ElideResponse response = elide.get(baseUrl, "/testModel/1", headers, null, NO_VERSION); assertEquals(HttpStatus.SC_BAD_REQUEST, response.getResponseCode()); assertEquals("{\"errors\":[{\"detail\":\"Found undefined keys in request: ?filter\"}]}", response.getBody()); }</code><technical_language>query params instead of headers</technical_language>

Target:
public void testElideGetInvalidKey() throws Exception { DataStore store = mock(DataStore.class); Elide elide = getElide(store, dictionary, MOCK_AUDIT_LOGGER); MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<>(); queryParams.putSingle("fields[testModel]", "field"); queryParams.putSingle("?filter", "field"); queryParams.putSingle("Sort", "field"); queryParams.putSingle("INCLUDE", "field"); queryParams.putSingle("fields.testModel", "field"); queryParams.putSingle("page.size", "10"); ElideResponse response = elide.get(baseUrl, "/testModel/1", queryParams, null, NO_VERSION); assertEquals(HttpStatus.SC_BAD_REQUEST, response.getResponseCode()); assertEquals("{\"errors\":[{\"detail\":\"Found undefined keys in request: fields.testModel, ?filter, Sort, page.size, INCLUDE\"}]}", response.getBody()); }
Source:
<code>private static void registerGeoShapeBoundsAggregator(ValuesSourceRegistry.Builder builder) { builder.register(GeoBoundsAggregationBuilder.NAME, GeoShapeValuesSourceType.instance(), (GeoBoundsAggregatorSupplier) (name, aggregationContext, parent, valuesSourceConfig, wrapLongitude, metadata) <START> -> new GeoShapeBoundsAggregator(name, aggregationContext, parent, valuesSourceConfig, wrapLongitude, metadata)); <END> }</code><technical_language>this a ctor reference others? *looks* here</technical_language>

Target:
private static void registerGeoShapeBoundsAggregator(ValuesSourceRegistry.Builder builder) { builder.register(GeoBoundsAggregationBuilder.NAME, GeoShapeValuesSourceType.instance(), (GeoBoundsAggregatorSupplier) GeoShapeBoundsAggregator::new); }
Source:
<code>void recover() { if (isStartRefused.get()) { LOG.warn("Recovery of the workspaces is rejected."); return; } Set<RuntimeIdentity> identities; try { identities = infrastructure.getIdentities(); } catch (UnsupportedOperationException e) { LOG.warn("Not recoverable infrastructure: '{}'", infrastructure.getName()); return; } catch (InfrastructureException e) { LOG.error( <START> "An error occurred while attempted to recover runtimes using infrastructure '{}'. Reason: '{}'", <END> infrastructure.getName(), e.getMessage()); return; } for (RuntimeIdentity identity : identities) { try { recoverOne(infrastructure, identity); } catch (ServerException | ConflictException e) { LOG.error( "An error occurred while attempted to recover runtimes using infrastructure '{}'. Reason: '{}'", infrastructure.getName(), e.getMessage()); } } }</code><technical_language>Le'ts rephrase this message clear error occurred identities fetching</technical_language>

Target:
void recover() { if (isStartRefused.get()) { LOG.warn("Recovery of the workspaces is rejected."); return; } Set<RuntimeIdentity> identities; try { identities = infrastructure.getIdentities(); } catch (UnsupportedOperationException e) { LOG.warn("Not recoverable infrastructure: '{}'", infrastructure.getName()); return; } catch (InfrastructureException e) { LOG.error( "An error occurred while attempting to get runtime identities for infrastructure '{}'. Reason: '{}'", infrastructure.getName(), e.getMessage()); return; } for (RuntimeIdentity identity : identities) { try { recoverOne(infrastructure, identity); } catch (ServerException | ConflictException e) { LOG.error( "An error occurred while attempting to recover runtimes using infrastructure '{}'. Reason: '{}'", infrastructure.getName(), e.getMessage()); } } }
Source:
<code>Set<Integer> extractGidsFromObservations(final String gidLabel, final List<MeasurementRow> observations) { Set<Integer> gids = new HashSet<>(); for (MeasurementRow observationRow : observations) { String gidString = observationRow.getMeasurementDataValue(gidLabel); <START> if (StringUtils.isNotBlank(gidString)) { <END> gids.add(Integer.valueOf(gidString)); } } return gids; }</code><technical_language>This **StringUtil** is import com.hazelcast.util.StringUtil; commons lang 3 string utils</technical_language>

Target:
Set<Integer> extractGidsFromObservations(final String gidLabel, final List<MeasurementRow> observations) { final Set<Integer> gids = new HashSet<>(); for (final MeasurementRow observationRow : observations) { final String gidString = observationRow.getMeasurementDataValue(gidLabel); if (StringUtils.isNotBlank(gidString) && StringUtils.isNumeric(gidString)) { gids.add(Integer.valueOf(gidString)); } } return gids; }
Source:
<code>public NotAnInputTypeError(TypeDefinition typeDefinition) { <START> super(typeDefinition, format("The %s type is used as an InputType, but is not declared as one", typeDefinition.getName())); <END> }</code><technical_language>phrase a bit diffrent: "expected InputType, %s type"</technical_language>

Target:
public NotAnInputTypeError(TypeDefinition typeDefinition) { super(typeDefinition, format("expected InputType, but found %s type", typeDefinition.getName())); }
Source:
<code>public Map<String,String> validateLiterals(Map<String, List<Literal>> varNamesToValues){ HashMap<String,String> errors = new HashMap<String,String>(); for( String name : editConfig.getLiteralsOnForm() ){ List<Literal> literals = varNamesToValues.get(name); List<String>validations = varsToValidations.get(name); if( validations != null ){ boolean isRequiredField = validations.contains("nonempty"); for( String validationType : validations){ String value = null; StringBuilder validateMsg = null; if((literals == null || literals.size() == 0) && isRequiredField) { errors.put(name, i18n.text("required_field_empty_msg")); break; } if(literals != null) { for(Literal literal: literals) { try{ if( literal != null ){ value = literal.getString(); } }catch(Throwable th){ log.debug("could not convert literal to string" , th); } if (isEmpty(value)) { if (isRequiredField) { <START> errors.put(name, i18n.text("required_field_empty_msg")); <END> } break; } String thisValidateMsg = validate(validationType,value); if (thisValidateMsg != null) { if (validateMsg != null) { validateMsg.append(", ").append(thisValidateMsg); } else { validateMsg = new StringBuilder(thisValidateMsg); } } } } if( validateMsg != null) { errors.put(name, validateMsg.toString()); } } } } return errors; }</code><technical_language>constant inplace of this String. <LINK_0></technical_language>

Target:
public Map<String,String> validateLiterals(Map<String, List<Literal>> varNamesToValues){ HashMap<String,String> errors = new HashMap<String,String>(); for( String name : editConfig.getLiteralsOnForm() ){ List<Literal> literals = varNamesToValues.get(name); List<String>validations = varsToValidations.get(name); if( validations != null ){ boolean isRequiredField = validations.contains("nonempty"); for( String validationType : validations){ String value = null; StringBuilder validateMsg = null; if((literals == null || literals.size() == 0) && isRequiredField) { errors.put(name, i18n.text(REQUIRED_FIELD_EMPTY_MSG)); break; } if(literals != null) { for(Literal literal: literals) { try{ if( literal != null ){ value = literal.getString(); } }catch(Throwable th){ log.debug("could not convert literal to string" , th); } if (isEmpty(value)) { if (isRequiredField) { errors.put(name, i18n.text(REQUIRED_FIELD_EMPTY_MSG)); } break; } String thisValidateMsg = validate(validationType,value); if (thisValidateMsg != null) { if (validateMsg != null) { validateMsg.append(", ").append(thisValidateMsg); } else { validateMsg = new StringBuilder(thisValidateMsg); } } } } if( validateMsg != null) { errors.put(name, validateMsg.toString()); } } } } return errors; }
Source:
<code>private List<GerritQueryResult> executeQueryRest(String query) { List<GerritQueryResult> results = null; try { results = client.executeQueryRest(new NullProgressMonitor(), query); <START> } catch (GerritException e) { <END> results = null; } return results; }</code><technical_language>Tests suppress exception propagate ExpectedException rule</technical_language>

Target:
private List<GerritQueryResult> executeQueryRest(String query) throws GerritException { List<GerritQueryResult> results = null; results = client.executeQueryRest(new NullProgressMonitor(), query); return results; }
Source:
<code>public void run() { String smsg = null; try { m_consumer.subscribe(Arrays.asList(m_config.topic)); while (!m_closed.get()) { <START> ConsumerRecords<byte[], byte[]> records = m_consumer.poll(1000); END> for (ConsumerRecord<byte[], byte[]> record : records) { byte[] msg = record.value(); long offset = record.offset(); smsg = new String(msg); Object params[]; if (m_formatter != null) { try { params = m_formatter.transform(ByteBuffer.wrap(msg)); } catch (FormatException badMsg) { m_log.warn("Failed to transform message " + smsg + " at offset " + offset + ", error message: " + badMsg.getMessage()); continue; } } else { params = m_csvParser.parseLine(smsg); } if (params == null) continue; m_loader.insertRow(new RowWithMetaData(smsg, offset), params); } } } catch (IllegalArgumentException invalidTopic) { m_closed.set(true); m_log.error("Failed subscribing to the topic " + m_config.topic, invalidTopic); } catch (WakeupException wakeup) { m_closed.set(true); m_log.debug("Consumer signalled to terminate ", wakeup); } catch (IOException ioExcp) { m_closed.set(true); if (m_formatter == null) { m_log.error("Failed to parse message" + smsg); } else { m_log.error("Error seen when processing message ", ioExcp); } } catch (Throwable terminate) { m_closed.set(true); m_log.error("Error seen during poll", terminate); } finally { try { m_consumer.close(); } catch (Exception ignore) notifyShutdown(); } }</code><technical_language>1 pretty arbitrary. This a named constant top of file - do need a hidden property for it</technical_language>

Target:
public void run() { String smsg = null; try { m_consumer.subscribe(Arrays.asList(m_config.topic)); while (!m_closed.get()) { ConsumerRecords<byte[], byte[]> records = m_consumer.poll(pollTimedWaitInMilliSec); for (ConsumerRecord<byte[], byte[]> record : records) { byte[] msg = record.value(); long offset = record.offset(); smsg = new String(msg); Object params[]; if (m_formatter != null) { try { params = m_formatter.transform(ByteBuffer.wrap(msg)); } catch (FormatException badMsg) { m_log.warn("Failed to transform message " + smsg + " at offset " + offset + ", error message: " + badMsg.getMessage()); continue; } } else { params = m_csvParser.parseLine(smsg); } if (params == null) continue; m_loader.insertRow(new RowWithMetaData(smsg, offset), params); } } } catch (IllegalArgumentException invalidTopic) { m_closed.set(true); m_log.error("Failed subscribing to the topic " + m_config.topic, invalidTopic); } catch (WakeupException wakeup) { m_closed.set(true); m_log.debug("Consumer signalled to terminate ", wakeup); } catch (IOException ioExcp) { m_closed.set(true); if (m_formatter == null) { m_log.error("Failed to parse message" + smsg); } else { m_log.error("Error seen when processing message ", ioExcp); } } catch (Throwable terminate) { m_closed.set(true); m_log.error("Error seen during poll", terminate); } finally { try { m_consumer.close(); } catch (Exception ignore) notifyShutdown(); } }
Source:
<code>protected void okPressed() { String sessionPath = fFileNameCombo.getText(); if (!"".equals(sessionPath)) { <START> saveWidgetValues(); <END> ImmutableList.Builder<String> builder = new ImmutableList.Builder<>(); try (BufferedRandomAccessFile rafile = new BufferedRandomAccessFile(sessionPath, "r")) { String line = rafile.getNextLine(); while (line != null) { builder.add(line); line = rafile.getNextLine(); } } catch (IOException e) { return; } fCommands = builder.build(); super.okPressed(); } }</code><technical_language>save method do try-catch in case is exception</technical_language>

Target:
protected void okPressed() { String sessionPath = fFileNameCombo.getText(); if (!"".equals(sessionPath)) { ImmutableList.Builder<String> builder = new ImmutableList.Builder<>(); try (BufferedRandomAccessFile rafile = new BufferedRandomAccessFile(sessionPath, "r")) { String line = rafile.getNextLine(); while (line != null) { builder.add(line); line = rafile.getNextLine(); } } catch (IOException e) { ErrorDialog.openError(getShell(), null, null, new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e.getLocalizedMessage(), e)); return; } saveWidgetValues(); fCommands = builder.build(); super.okPressed(); } }
Source:
<code>public void beginTraining() { String trainingFilesUrl = "{SAS-URL-of-your-container-in-blob-storage}"; boolean useTrainingLabels = true; formTrainingAsyncClient.beginTraining(trainingFilesUrl, useTrainingLabels) <START> .subscribe(trainingPollingOperation -> { <END> trainingPollingOperation.getFinalResult().subscribe(customFormModel -> { System.out.printf("Model Id: %s%n", customFormModel.getModelId()); System.out.printf("Model Status: %s%n", customFormModel.getModelStatus()); customFormModel.getSubmodels() .forEach(customFormSubmodel -> customFormSubmodel.getFields() .forEach((key, customFormModelField) -> System.out.printf("Form type: %s Field Text: %s Field Accuracy: %f%n", key, customFormModelField.getName(), customFormModelField.getAccuracy()))); }); }); END: com.azure.ai.formrecognizer.training.FormTrainingAsyncClient.beginTraining#string-boolean }</code><technical_language>other change, change flatMap()</technical_language>

Target:
public void beginTraining() { String trainingFilesUrl = "{SAS-URL-of-your-container-in-blob-storage}"; boolean useTrainingLabels = true; formTrainingAsyncClient.beginTraining(trainingFilesUrl, useTrainingLabels) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(customFormModel -> { System.out.printf("Model Id: %s%n", customFormModel.getModelId()); System.out.printf("Model Status: %s%n", customFormModel.getModelStatus()); customFormModel.getSubmodels() .forEach(customFormSubmodel -> customFormSubmodel.getFields() .forEach((key, customFormModelField) -> System.out.printf("Form type: %s Field Text: %s Field Accuracy: %f%n", key, customFormModelField.getName(), customFormModelField.getAccuracy()))); }); END: com.azure.ai.formrecognizer.training.FormTrainingAsyncClient.beginTraining#string-boolean }
Source:
<code>protected void updateAttributesInfo(Collection<DynamicMetric<?, ?>> dynamicMetrics, String description) { <START> if (dynamicMetrics == null || dynamicMetrics.isEmpty()) { <END> _logger.warn("Cannot update attributes info because dynamicMetrics is null or empty."); } List<MBeanAttributeInfo> attributeInfoList = new ArrayList<>(); Map<String, DynamicMetric> newAttributeMap = new HashMap<>(); for (DynamicMetric dynamicMetric : dynamicMetrics) { Iterator<MBeanAttributeInfo> iter = dynamicMetric.getAttributeInfos().iterator(); while (iter.hasNext()) { MBeanAttributeInfo attributeInfo = iter.next(); attributeInfoList.add(attributeInfo); newAttributeMap.put(attributeInfo.getName(), dynamicMetric); } } attributeInfoList.add(new MBeanAttributeInfo(SENSOR_NAME_TAG, String.class.getName(), "The name of the metric sensor", true, false, false)); MBeanConstructorInfo constructorInfo = new MBeanConstructorInfo( String.format("Default %s Constructor", getClass().getSimpleName()), getClass().getConstructors()[0]); MBeanAttributeInfo[] attributesInfo = new MBeanAttributeInfo[attributeInfoList.size()]; attributesInfo = attributeInfoList.toArray(attributesInfo); if (description == null) { description = DEFAULT_DESCRIPTION; } _mBeanInfo = new MBeanInfo(getClass().getName(), description, attributesInfo, new MBeanConstructorInfo[]{constructorInfo}, new MBeanOperationInfo[0], new MBeanNotificationInfo[0]); _attributeMap = newAttributeMap; }</code><technical_language>I empty fine</technical_language>

Target:
protected void updateAttributesInfo(Collection<DynamicMetric<?, ?>> dynamicMetrics, String description) { if (dynamicMetrics == null) { _logger.warn("Cannot update attributes info because dynamicMetrics is null."); return; } List<MBeanAttributeInfo> attributeInfoList = new ArrayList<>(); Map<String, DynamicMetric> newAttributeMap = new HashMap<>(); for (DynamicMetric<?, ?> dynamicMetric : dynamicMetrics) { for (MBeanAttributeInfo attributeInfo : dynamicMetric.getAttributeInfos()) { attributeInfoList.add(attributeInfo); newAttributeMap.put(attributeInfo.getName(), dynamicMetric); } } attributeInfoList.add(new MBeanAttributeInfo(SENSOR_NAME_TAG, String.class.getName(), "The name of the metric sensor", true, false, false)); MBeanConstructorInfo constructorInfo = new MBeanConstructorInfo( String.format("Default %s Constructor", getClass().getSimpleName()), getClass().getConstructors()[0]); MBeanAttributeInfo[] attributesInfo = new MBeanAttributeInfo[attributeInfoList.size()]; attributesInfo = attributeInfoList.toArray(attributesInfo); if (description == null) { description = DEFAULT_DESCRIPTION; } _mBeanInfo = new MBeanInfo(getClass().getName(), description, attributesInfo, new MBeanConstructorInfo[]{constructorInfo}, new MBeanOperationInfo[0], new MBeanNotificationInfo[0]); _attributeMap = newAttributeMap; }
Source:
<code>public List<Credential> fromRequest(final HttpServletRequest request, final MultiValueMap<String, String> requestBody) { val credentials = super.fromRequest(request, requestBody); if (credentials.isEmpty()) { return credentials; } val credential = extractCredential(request, credentials); if (credential == null) { <START> LOGGER.debug("Not a surrogate authentication attempt, returning parent class credentials"); <END> return credentials; } val surrogateAccounts = surrogateAuthenticationService.getEligibleAccountsForSurrogateToProxy(credential.getId()); if (!surrogateAccounts.contains(credential.getSurrogateUsername())) { throw new SurrogateAuthenticationException("Unable to authorize surrogate authentication request for " + credential.getSurrogateUsername()); } return CollectionUtils.wrapList(credential); }</code><technical_language>suggestion LOGGER.trace("Not a surrogate authentication attempt, returning parent class credentials");</technical_language>

Target:
public List<Credential> fromRequest(final HttpServletRequest request, final MultiValueMap<String, String> requestBody) { val credentials = super.fromRequest(request, requestBody); if (credentials.isEmpty()) { return credentials; } val credential = extractCredential(request, credentials); if (credential == null) { LOGGER.trace("Not a surrogate authentication attempt, returning parent class credentials"); return credentials; } val surrogateAccounts = surrogateAuthenticationService.getEligibleAccountsForSurrogateToProxy(credential.getId()); if (!surrogateAccounts.contains(credential.getSurrogateUsername())) { throw new SurrogateAuthenticationException("Unable to authorize surrogate authentication request for " + credential.getSurrogateUsername()); } return CollectionUtils.wrapList(credential); }
Source:
<code>private void verifyBodyOpenBraceStyle(ParserRuleContext ctx, String constructName) { ParserRuleContext leftSibling = (ParserRuleContext) ParseTreeUtil.getLeftSibling(ctx); Location constructLocation = ListenerUtil.getContextStopLocation(leftSibling); <START> verifySingleSpaceBeforeOpenBrace(ctx, leftSibling.getStop()); <END> verifyCodeBlockOpenBraceIsInline(ctx, constructLocation, constructName); }</code><technical_language>please swap order of L436 L437 consistent verifyCodeBlockOpenBraceStyle()</technical_language>

Target:
private void verifyBodyOpenBraceStyle(ParserRuleContext ctx, String constructName) { ParserRuleContext leftSibling = (ParserRuleContext) ParseTreeUtil.getLeftSibling(ctx); Location constructLocation = ListenerUtil.getContextStopLocation(leftSibling); verifyCodeBlockOpenBraceIsInline(ctx, constructLocation, constructName); verifySingleSpaceBeforeOpenBrace(ctx, leftSibling.getStop()); }
Source:
<code>private void handleResult(final String id, Map<String, List<QualifiedOafJsonRecord>> mappedRecords) throws InterruptedException, IOException { Oaf oafObj = buildOafObject(mappedRecords.get(Type.result.name())); if (oafObj == null) { log.error("missing 'body' qualifier value for record " + id); return; } if (resultApprover.approve(oafObj)) { DocumentMetadata docMeta = docMetaConverter.convert(oafObj.getEntity()); if (docMeta!=null) { outputs.write(outputNameDocumentMeta, new AvroKey<DocumentMetadata>(docMeta)); } if (acceptAsDataset(oafObj)) { DataSetReference datasetMeta = datasetMetaConverter.convert(oafObj.getEntity()); if (datasetMeta != null) { <START> outputs.write(outputNameDatasetMeta, new AvroKey<DataSetReference>(datasetMeta)); <END> } } handleRelation(mappedRecords.get(resProjColumnFamily), docProjectConverter, outputNameDocumentProject); handleRelation(mappedRecords.get(dedupMappingColumnFamily), deduplicationMappingConverter, outputNameDedupMapping); } }</code><technical_language>IDE new AvroKey<DataSetReference>(datasetMeta) replaced new AvroKey<>(datasetMeta))</technical_language>

Target:
private void handleResult(final String id, Map<String, List<QualifiedOafJsonRecord>> mappedRecords) throws InterruptedException, IOException { Oaf oafObj = buildOafObject(mappedRecords.get(Type.result.name())); if (oafObj == null) { log.error("missing 'body' qualifier value for record " + id); return; } if (resultApprover.approve(oafObj)) { DocumentMetadata docMeta = docMetaConverter.convert(oafObj.getEntity()); if (docMeta!=null) { outputs.write(outputNameDocumentMeta, new AvroKey<>(docMeta)); } if (acceptAsDataset(oafObj)) { DataSetReference datasetMeta = datasetMetaConverter.convert(oafObj.getEntity()); if (datasetMeta != null) { outputs.write(outputNameDatasetMeta, new AvroKey<>(datasetMeta)); } } handleRelation(mappedRecords.get(resProjColumnFamily), docProjectConverter, outputNameDocumentProject); handleRelation(mappedRecords.get(dedupMappingColumnFamily), deduplicationMappingConverter, outputNameDedupMapping); } }
Source:
<code>private static LinkedFile convert(List<String> entry) { while (entry.size() < 3) { entry.add(""); } LinkedFile field; if (LinkedFile.isOnlineLink(entry.get(1))) { try { field = new LinkedFile(new URL(entry.get(1)), entry.get(2)); } catch (MalformedURLException e) { field = new LinkedFile(entry.get(0), Path.of(entry.get(1)), entry.get(2)); } } else { <START> field = new LinkedFile(entry.get(0), Path.of(entry.get(1)), entry.get(2)); <END> } if (field.getDescription().isEmpty() && field.getLink().isEmpty() && !field.getFileType().isEmpty()) { field = new LinkedFile("", Path.of(field.getFileType()), ""); } else if (!field.getDescription().isEmpty() && field.getLink().isEmpty() && field.getFileType().isEmpty()) { field = new LinkedFile("", Path.of(field.getDescription()), ""); } entry.clear(); return field; }</code><technical_language>Please a try catch block a normal control structure in code. <LINK_0></technical_language>

Target:
private static LinkedFile convert(List<String> entry) { while (entry.size() < 3) { entry.add(""); } LinkedFile field = null; if (LinkedFile.isOnlineLink(entry.get(1))) { try { field = new LinkedFile(new URL(entry.get(1)), entry.get(2)); } catch (MalformedURLException ignored) { } } if (field == null) { field = new LinkedFile(entry.get(0), Path.of(entry.get(1)), entry.get(2)); } if (field.getDescription().isEmpty() && field.getLink().isEmpty() && !field.getFileType().isEmpty()) { field = new LinkedFile("", Path.of(field.getFileType()), ""); } else if (!field.getDescription().isEmpty() && field.getLink().isEmpty() && field.getFileType().isEmpty()) { field = new LinkedFile("", Path.of(field.getDescription()), ""); } entry.clear(); return field; }
Source:
<code>protected boolean canDoAction() { boolean retValue = true; if (!VM.isStatusUpOrPaused(getVm().getstatus())) { setSucceeded(false); retValue = false; addCanDoActionMessage(VdcBllMessages.VAR__TYPE__VM); if (!StringUtils.isEmpty(mCdImagePath)) { addCanDoActionMessage(VdcBllMessages.VAR__ACTION__CHANGE_CD); } else { addCanDoActionMessage(VdcBllMessages.VAR__ACTION__EJECT_CD); } addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_VM_STATUS_ILLEGAL); } else if ((VmRunHandler.getInstance().findActiveISODomain(getVm().getstorage_pool_id()) == null) && !StringUtils.isEmpty(mCdImagePath)) { <START> } else if ((VmRunHandler.getInstance().findActiveISODomain(getVm().getstorage_pool_id()) == null) && !StringHelper.isNullOrEmpty(mCdImagePath)) { <END> addCanDoActionMessage(VdcBllMessages.VAR__ACTION__CHANGE_CD); addCanDoActionMessage(VdcBllMessages.VM_CANNOT_WITHOUT_ACTIVE_STORAGE_DOMAIN_ISO); setSucceeded(false); retValue = false; } return retValue; }</code><technical_language>StringHelper is deprecated. Please StringUtils.isEmpty(mCdImagePath) instead</technical_language>

Target:
protected boolean canDoAction() { boolean retValue = true; if (!VM.isStatusUpOrPaused(getVm().getstatus())) { setSucceeded(false); retValue = false; addCanDoActionMessage(VdcBllMessages.VAR__TYPE__VM); if (!StringUtils.isEmpty(mCdImagePath)) { addCanDoActionMessage(VdcBllMessages.VAR__ACTION__CHANGE_CD); } else { addCanDoActionMessage(VdcBllMessages.VAR__ACTION__EJECT_CD); } addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_VM_STATUS_ILLEGAL); } else if ((VmRunHandler.getInstance().findActiveISODomain(getVm().getstorage_pool_id()) == null) && !StringUtils.isEmpty(mCdImagePath)) { } else if ((VmRunHandler.getInstance().findActiveISODomain(getVm().getstorage_pool_id()) == null) && !StringUtils.isEmpty(mCdImagePath)) { addCanDoActionMessage(VdcBllMessages.VAR__ACTION__CHANGE_CD); addCanDoActionMessage(VdcBllMessages.VM_CANNOT_WITHOUT_ACTIVE_STORAGE_DOMAIN_ISO); setSucceeded(false); retValue = false; } return retValue; }
Source:
<code>public void testGetAllPropertiesByTags() throws Exception { try{ out = new BufferedWriter(new FileWriter(CONFIG)); startConfig(); appendProperty("hadoop.tags.system", "YARN,HDFS,NAMENODE"); appendProperty("hadoop.tags.custom", "MYCUSTOMTAG"); appendPropertyByTag("dfs.cblock.trace.io", "false", "YARN"); appendPropertyByTag("dfs.replication", "1", "HDFS"); appendPropertyByTag("dfs.namenode.logging.level", "INFO", "NAMENODE"); appendPropertyByTag("dfs.random.key", "XYZ", "MYCUSTOMTAG"); endConfig(); Path fileResource = new Path(CONFIG); conf.addResource(fileResource); assertEq(conf.getAllPropertiesByTag("MYCUSTOMTAG").getProperty("dfs.random.key"), "XYZ"); } finally { out.close(); } <START> try { <END> out = new BufferedWriter(new FileWriter(CONFIG_CORE)); startConfig(); appendProperty("dfs.random.key", "ABC"); appendProperty("dfs.replication", "3"); appendProperty("dfs.cblock.trace.io", "true"); endConfig(); Path fileResource = new Path(CONFIG_CORE); conf.addResource(fileResource); } finally { out.close(); } assertEq("3", conf.getAllPropertiesByTag("HDFS").getProperty("dfs.replication")); assertEq("ABC", conf.getAllPropertiesByTag("MYCUSTOMTAG").getProperty("dfs.random.key")); assertEq("true", conf.getAllPropertiesByTag("YARN").getProperty("dfs.cblock.trace.io")); }</code><technical_language>try construct closes Closeable explicit close. syntactic sugar</technical_language>

Target:
public void testGetAllPropertiesByTags() throws Exception { File coreDefault = tempConfigs.newFile("core-default-test.xml"); File coreSite = tempConfigs.newFile("core-site-test.xml"); try (BufferedWriter out = new BufferedWriter(new FileWriter(coreDefault))) { startConfig(out); appendProperty(out, "hadoop.tags.system", "YARN,HDFS,NAMENODE"); appendProperty(out, "hadoop.tags.custom", "MYCUSTOMTAG"); appendPropertyByTag(out, "dfs.cblock.trace.io", "false", "YARN"); appendPropertyByTag(out, "dfs.replication", "1", "HDFS"); appendPropertyByTag(out, "dfs.namenode.logging.level", "INFO", "NAMENODE"); appendPropertyByTag(out, "dfs.random.key", "XYZ", "MYCUSTOMTAG"); endConfig(out); Path fileResource = new Path(coreDefault.getAbsolutePath()); conf.addResource(fileResource); Assert.assertEquals(conf.getAllPropertiesByTag("MYCUSTOMTAG") .getProperty("dfs.random.key"), "XYZ"); } try (BufferedWriter out = new BufferedWriter(new FileWriter(coreSite))) { startConfig(out); appendProperty(out, "dfs.random.key", "ABC"); appendProperty(out, "dfs.replication", "3"); appendProperty(out, "dfs.cblock.trace.io", "true"); endConfig(out); Path fileResource = new Path(coreSite.getAbsolutePath()); conf.addResource(fileResource); } Assert.assertEquals("3", conf.getAllPropertiesByTag("HDFS") .getProperty("dfs.replication")); Assert.assertEquals("ABC", conf.getAllPropertiesByTag("MYCUSTOMTAG") .getProperty("dfs.random.key")); Assert.assertEquals("true", conf.getAllPropertiesByTag("YARN") .getProperty("dfs.cblock.trace.io")); }
Source:
<code>public Builder crossoverRate(double rate) { if(rate < 0 || rate > 1.0) { throw new IllegalArgumentException("Rate must be between 0.0 and 1.0"); <START> } <END> this.crossoverRate = rate; return this; }</code><technical_language>more a stylistic (I'll leave change this sort of input validation if want), I tend (which is shorter more informative for user): Preconditions.checkState(rate >= 0.0 && rate <= 1.0, "Rate 0.0 1.0, %s", rate); ND4J Preconditions class: <LINK_0> <LINK_1> ND4J preconditions class formats arrays properly in error string, results in object creation exception is thrown</technical_language>

Target:
public Builder crossoverRate(double rate) { Preconditions.checkState(rate >= 0.0 && rate <= 1.0, "Rate must be between 0.0 and 1.0, got %s", rate); this.crossoverRate = rate; return this; }
Source:
<code><START> public void test() { <END> String title = getViewTitle(); SWTBotView viewBot = fBot.viewByTitle(title); viewBot.show(); viewBot.setFocus(); TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, START_TIME)); ConditionHelpers.timeGraphIsReadyCondition((AbstractTimeGraphView) viewBot.getViewReference().getPart(false), new TmfTimeRange(START_TIME, START_TIME), START_TIME); openDialog(viewBot); SWTBotShell shell = fBot.shell("Find"); SWTBot bot = shell.bot(); SWTBotButton findButton = bot.button("Fi&nd"); String text = getFindText(); testDirectionSearch(true, text, bot, findButton, viewBot); testCaseSensitive(text, bot, findButton); final @NonNull String ttext = text.split(SPACE)[0]; testWholeWord(ttext, bot, findButton); testRegEx(REGEX_PREFIX + ttext, bot, findButton); testDirectionSearch(false, text, bot, findButton, viewBot); }</code><technical_language>clear methods tests helper methods. need @Test annotations? (Hmm other methods private)</technical_language>

Target:
public void test() { String title = getViewTitle(); SWTBotView viewBot = fBot.viewByTitle(title); viewBot.show(); viewBot.setFocus(); TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, START_TIME)); ConditionHelpers.timeGraphIsReadyCondition((AbstractTimeGraphView) viewBot.getViewReference().getPart(false), new TmfTimeRange(START_TIME, START_TIME), START_TIME); openDialog(viewBot); SWTBotShell shell = fBot.shell("Find"); SWTBot bot = shell.bot(); SWTBotButton findButton = bot.button("Fi&nd"); String text = getFindText(); testWrapSearch(text, bot, findButton, viewBot); testDirectionSearch(true, text, bot, findButton, viewBot); testCaseSensitive(text, bot, findButton); final @NonNull String ttext = text.split(SPACE)[0]; testWholeWord(ttext, bot, findButton); testRegEx(REGEX_PREFIX + ttext, bot, findButton); testDirectionSearch(false, text, bot, findButton, viewBot); }
Source:
<code>public void updateS3Credentials() { <START> s3Credentials = service.updateS3Credentials(s3Credentials) <END> .get(1, TimeUnit.MINUTES); assertThat(s3Credentials, notNullValue()); }</code><technical_language>this update</technical_language>

Target:
public void updateS3Credentials() { final DateTime lastUpdated = s3Credentials.getUpdated(); s3Credentials = service.updateS3Credentials(s3Credentials.withSecretKey("newSecretKey")) .get(1, TimeUnit.MINUTES); assertThat(s3Credentials, notNullValue()); assertThat(s3Credentials.getUpdated(), is(not(lastUpdated))); }
Source:
<code>private static void updateAttributeValue( ApplicationConfiguration configuration, Element element, String attribute, Object value) { if (value == null || value instanceof String) { WidgetUtil.updateAttribute(element, attribute, (String) value); } else { <START> JsonObject object = WidgetUtil.crazyJsCast(value); <END> assert object.hasKey( NodeProperties.URI_ATTRIBUTE) : "Implementation error: JsonObject is recieved as an attribute value for '" + attribute + "' but it has no " + NodeProperties.URI_ATTRIBUTE + " key"; String uri = object.getString(NodeProperties.URI_ATTRIBUTE); if (configuration.isWebComponentMode()) { String baseUri = configuration.getServiceUrl(); baseUri = baseUri.endsWith("/") ? baseUri : baseUri + "/"; WidgetUtil.updateAttribute(element, attribute, baseUri + uri); } else { WidgetUtil.updateAttribute(element, attribute, uri); } } }</code><technical_language>Please put a explanations this wrapper is put intentionally doSetResource method? java cast here, a JS cast</technical_language>

Target:
private static void updateAttributeValue( ApplicationConfiguration configuration, Element element, String attribute, Object value) { if (value == null || value instanceof String) { WidgetUtil.updateAttribute(element, attribute, (String) value); } else { JsonValue jsonValue = WidgetUtil.crazyJsoCast(value); if (JsonType.OBJECT.equals(jsonValue.getType())) { JsonObject object = (JsonObject) jsonValue; assert object.hasKey( NodeProperties.URI_ATTRIBUTE) : "Implementation error: JsonObject is recieved as an attribute value for '" + attribute + "' but it has no " + NodeProperties.URI_ATTRIBUTE + " key"; String uri = object.getString(NodeProperties.URI_ATTRIBUTE); if (configuration.isWebComponentMode()) { String baseUri = configuration.getServiceUrl(); baseUri = baseUri.endsWith("/") ? baseUri : baseUri + "/"; WidgetUtil.updateAttribute(element, attribute, baseUri + uri); } else { WidgetUtil.updateAttribute(element, attribute, uri); } } else { WidgetUtil.updateAttribute(element, attribute, value.toString()); } } }
Source:
<code>public void onAllRequiredCapabilitiesAvailable() { FrameworkUtil.getBundle(MSF4JDeployerSC.class).getBundleContext() .registerService(Deployer.class, new MicroservicesDeployer(), null); <START> if (log.isDebugEnabled()) { <END> log.debug("MicroservicesDeployer service is available"); } }</code><technical_language>Do need check if debug is enabled? AFAIK this is handled internally. Please refer [1] for more information this. [1] <LINK_0></technical_language>

Target:
public void onAllRequiredCapabilitiesAvailable() { FrameworkUtil.getBundle(MSF4JDeployerSC.class).getBundleContext() .registerService(Deployer.class, new MicroservicesDeployer(), null); log.debug("MicroservicesDeployer service is available"); }
Source:
<code>public void createCache(String name, String template, EnumSet<AdminFlag> flags) { Map<String, String> params = new HashMap<>(2); params.put(CACHE_NAME, name); if (template != null) params.put(CACHE_TEMPLATE, template); if (flags != null && !flags.isEmpty()) params.put(FLAGS, flagsToString(flags)); <START> operationsFactory.newAdminOperation("CACHE_CREATE", params).execute(); <END> }</code><technical_language>Hmmm, wondering... do need admin operation this? Wondering if do this a deployable server task? IOW, ship admin deployable tasks of need</technical_language>

Target:
public void createCache(String name, String template, EnumSet<AdminFlag> flags) { Map<String, byte[]> params = new HashMap<>(2); params.put(CACHE_NAME, string(name)); if (template != null) params.put(CACHE_TEMPLATE, string(template)); if (flags != null && !flags.isEmpty()) params.put(FLAGS, flags(flags)); operationsFactory.newExecuteOperation("@@cache@create", params).execute(); }
Source:
<code>ConcurrentMap<String, StatisticQuery.Builder> getSelectedStatsPerCapability() { <START> return selectedStatsPerCapability; <END> }</code><technical_language>for tests, I this is modifiable. Map interface is needed</technical_language>

Target:
Map<String, StatisticQuery.Builder> getSelectedStatsPerCapability() { return Collections.unmodifiableMap(selectedStatsPerCapability); }
Source:
<code>public void testAddRawRow() { <START> DoorsTableRowCollector dtc = setupTestRowCollector(); <END> Assert.assertEquals(dtc.getTableRows().size(), 2); }</code><technical_language>pass dtc instance setup method name more discriptive add elements something</technical_language>

Target:
public void testAddRawRow() { loadElementsInCollector(); Assert.assertEquals(dtc.getTableRows().size(), 2); }
Source:
<code>public void testDoGet_NotFound_MissingFile() throws IOException, ServletException { final IConfigUtilsInterface configUtils = Mockito.mock(IConfigUtilsInterface.class); <START> Config.setConfigUtils(configUtils); <END> testServlet.doGet(mockRequest, mockResponse); verify(mockResponse).sendError(HttpServletResponse.SC_NOT_FOUND); }</code><technical_language>this is required</technical_language>

Target:
public void testDoGet_NotFound_MissingFile() throws IOException, ServletException { testServlet.doGet(mockRequest, mockResponse); verify(mockResponse).sendError(HttpServletResponse.SC_NOT_FOUND); }
Source:
<code>public static KeyVaultKeyIdentifier parse(String keyId) throws IllegalArgumentException, MalformedURLException { if (keyId == null) { throw new IllegalArgumentException("keyId cannot be null"); } <START> URL url = new URL(keyId); <END> String[] pathSegments = url.getPath().split("/"); if ((pathSegments.length != 3 && pathSegments.length != 4) || !"https".equals(url.getProtocol()) || (!"keys".equals(pathSegments[1]) && !"deletedkeys".equals(pathSegments[1])) || ("deletedkeys".equals(pathSegments[1]) && pathSegments.length == 4)) { throw new IllegalArgumentException("keyId is not a valid Key Vault Key identifier"); } return new KeyVaultKeyIdentifier(keyId, url.getProtocol() + "://" + url.getHost(), pathSegments[2], pathSegments.length == 4 ? pathSegments[3] : null); }</code><technical_language>feedback certs</technical_language>

Target:
public static KeyVaultKeyIdentifier parse(String keyId) throws IllegalArgumentException { if (keyId == null) { throw new IllegalArgumentException("keyId cannot be null"); } try { final URL url = new URL(keyId); final String[] pathSegments = url.getPath().split("/"); if ((pathSegments.length != 3 && pathSegments.length != 4) || !"https".equals(url.getProtocol()) || (!"keys".equals(pathSegments[1]) && !"deletedkeys".equals(pathSegments[1])) || ("deletedkeys".equals(pathSegments[1]) && pathSegments.length == 4)) { throw new IllegalArgumentException("keyId is not a valid Key Vault Key identifier"); } final String vaultUrl = String.format("%s://%s", url.getProtocol(), url.getHost()); final String keyName = pathSegments[2]; final String keyVersion = pathSegments.length == 4 ? pathSegments[3] : null; return new KeyVaultKeyIdentifier(keyId, vaultUrl, keyName, keyVersion); } catch (MalformedURLException e) { throw new IllegalArgumentException("Could not parse keyId", e); } }
Source:
<code><START> private static StrictMode.VmPolicy.Builder newVmPolicyBuilderWithDefaultViolations() { <END> return new StrictMode.VmPolicy.Builder() .detectLeakedSqlLiteObjects() .detectLeakedRegistrationObjects(); }</code><technical_language>want enable violations default. change focus giving opportunity override policies IMHO</technical_language>

Target:
private static StrictMode.VmPolicy.Builder newVmPolicyBuilderWithDefaultViolations() { StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { builder.detectLeakedRegistrationObjects(); } return builder; }
Source:
<code>public V putIfAbsent(final K key, final V value) { putIfAbsentObserver.begin(); statusTransitioner.checkAvailable(); checkNonNull(key, value); <START> AtomicBoolean put = new AtomicBoolean(false); <END> try { ValueHolder<V> inCache = doPutIfAbsent(key, value, b -> put.set(b)); if(put.get()) { putIfAbsentObserver.end(PutIfAbsentOutcome.PUT); return null; } else if (inCache == null) { putIfAbsentObserver.end(PutIfAbsentOutcome.HIT); return null; } else { putIfAbsentObserver.end(PutIfAbsentOutcome.HIT); return inCache.get(); } } catch (StoreAccessException e) { try { return resilienceStrategy.putIfAbsentFailure(key, value, e); } finally { putIfAbsentObserver.end(PutIfAbsentOutcome.FAILURE); } } }</code><technical_language>Do need memory semantics of AtomicBoolean get a boolean[] here</technical_language>

Target:
public V putIfAbsent(final K key, final V value) { putIfAbsentObserver.begin(); try { statusTransitioner.checkAvailable(); checkNonNull(key, value); boolean[] put = { false }; try { ValueHolder<V> inCache = doPutIfAbsent(key, value, b -> put[0] = b); if (put[0]) { putIfAbsentObserver.end(PutIfAbsentOutcome.PUT); return null; } else if (inCache == null) { putIfAbsentObserver.end(PutIfAbsentOutcome.HIT); return null; } else { putIfAbsentObserver.end(PutIfAbsentOutcome.HIT); return inCache.get(); } } catch (StoreAccessException e) { V newValue = resilienceStrategy.putIfAbsentFailure(key, value, e); putIfAbsentObserver.end(PutIfAbsentOutcome.FAILURE); return newValue; } } catch (Throwable e) { putIfAbsentObserver.end(PutIfAbsentOutcome.FAILURE); throw e; } }