auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void dispatchHomeScreen() { <START> CommCareApp currentApp = CommCareApplication._().getCurrentApp(); <END> if (currentApp != null) { boolean appResourcesCorrupted = currentApp.getAppResourceState() == CommCareApplication.STATE_CORRUPTED; boolean dbCorrupted = CommCareApplication._().getDatabaseState() == CommCareApplication.STATE_CORRUPTED; ApplicationRecord currentRecord = currentApp.getAppRecord(); try { if (appResourcesCorrupted || dbCorrupted) { handleDamagedApp(); } else if (!currentRecord.isUsable()) { boolean unseated = handleUnusableApp(currentRecord); if (unseated) { dispatchHomeScreen(); } } else if (!CommCareApplication._().getSession().isActive()) { returnToLogin(); } else if (this.getIntent().hasExtra(SESSION_REQUEST)) { handleExternalLaunch(); } else if (this.getIntent().hasExtra(AndroidShortcuts.EXTRA_KEY_SHORTCUT)) { handleShortcutLaunch(); } else if (CommCareApplication._().isUpdatePending()) { handlePendingUpdate(); } else if (CommCareApplication._().isSyncPending(false)) { handlePendingSync(); } else { refreshView(); } } catch (SessionUnavailableException sue) { returnToLogin(); } } else { if (CommCareApplication._().usableAppsPresent()) { Logger.log(AndroidLogger.TYPE_ERROR_WORKFLOW, "In CommCareHomeActivity with no" + "seated app, but there are other usable apps available on the device."); } Intent i = new Intent(getApplicationContext(), CommCareSetupActivity.class); this.startActivityForResult(i, INIT_APP); } }</code><technical_language>This section great! thanks for refactor here</technical_language>

Target:
private void dispatchHomeScreen() { CommCareApp currentApp = CommCareApplication._().getCurrentApp(); if (currentApp != null) { boolean appResourcesCorrupted = currentApp.getAppResourceState() == CommCareApplication.STATE_CORRUPTED; boolean dbCorrupted = CommCareApplication._().getDatabaseState() == CommCareApplication.STATE_CORRUPTED; ApplicationRecord currentRecord = currentApp.getAppRecord(); try { if (appResourcesCorrupted || dbCorrupted) { handleDamagedApp(); } else if (!currentRecord.isUsable()) { boolean unseated = handleUnusableApp(currentRecord); if (unseated) { dispatchHomeScreen(); } } else if (!CommCareApplication._().getSession().isActive()) { SessionActivityRegistration.returnToLogin(this); } else if (this.getIntent().hasExtra(SESSION_REQUEST)) { handleExternalLaunch(); } else if (this.getIntent().hasExtra(AndroidShortcuts.EXTRA_KEY_SHORTCUT)) { handleShortcutLaunch(); } else if (CommCareApplication._().isUpdatePending()) { handlePendingUpdate(); } else if (CommCareApplication._().isSyncPending(false)) { handlePendingSync(); } else { refreshView(); } } catch (SessionUnavailableException sue) { SessionActivityRegistration.returnToLogin(this); } } else { if (CommCareApplication._().usableAppsPresent()) { Logger.log(AndroidLogger.TYPE_ERROR_WORKFLOW, "In CommCareHomeActivity with no" + "seated app, but there are other usable apps available on the device."); } Intent i = new Intent(getApplicationContext(), CommCareSetupActivity.class); this.startActivityForResult(i, INIT_APP); } }
Source:
<code>public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod) throws IOException { AsyncClientHttpRequest request = this.delegate.createAsyncRequest(uri, httpMethod); Span span = getCurrentSpan(); if (span == null) { setHeader(request, Span.NOT_SAMPLED_NAME, "true"); return request; } enrichWithTraceHeaders(request, span); <START> publish(new ClientSentEvent(this, span)); <END> return request; }</code><technical_language>kill enrichWithTraceHeaders instead publishStartEvent. This more obvious hoping people do</technical_language>

Target:
public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod) throws IOException { AsyncClientHttpRequest request = this.delegate.createAsyncRequest(uri, httpMethod); if (!isTracing()) { doNotSampleThisSpan(request); return request; } publishStartEvent(request); return request; }
Source:
<code>private boolean setSealedReplicas(List<String> sealedReplicas) { <START> synchronized (participateLock) { <END> InstanceConfig instanceConfig = helixAdmin.getInstanceConfig(clusterName, instanceName); if (instanceConfig == null) { throw new IllegalStateException( "No instance config found for cluster: \"" + clusterName + "\", instance: \"" + instanceName + "\""); } logger.trace("Setting InstanceConfig with list of sealed replicas: {}", Arrays.toString(sealedReplicas.toArray())); instanceConfig.getRecord().setListField(ClusterMapUtils.SEALED_STR, sealedReplicas); return helixAdmin.setInstanceConfig(clusterName, instanceName, instanceConfig); } }</code><technical_language>Actually, do this differently. Notice method calls this, setReplicaSealedState(), is synchronized. is method get set, synchronization happen it. need method synchronizes object participate() call</technical_language>

Target:
private boolean setSealedReplicas(List<String> sealedReplicas) { InstanceConfig instanceConfig = helixAdmin.getInstanceConfig(clusterName, instanceName); if (instanceConfig == null) { throw new IllegalStateException( "No instance config found for cluster: \"" + clusterName + "\", instance: \"" + instanceName + "\""); } logger.trace("Setting InstanceConfig with list of sealed replicas: {}", Arrays.toString(sealedReplicas.toArray())); instanceConfig.getRecord().setListField(ClusterMapUtils.SEALED_STR, sealedReplicas); return helixAdmin.setInstanceConfig(clusterName, instanceName, instanceConfig); }
Source:
<code>public static String join(String delimiter, List<String> strings) { <START> StringJoiner joiner = new StringJoiner(delimiter); <END> for (CharSequence cs : strings) { joiner.add(cs); } return joiner.toString(); }</code><technical_language>problem Android compatibility, [StringJoiner](<LINK_0> a Java 8 class, added in API level 24 (Android 7 Nougat)</technical_language>

Target:
public static String join(String delimiter, List<String> strings) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < strings.size(); i++) { if (i > 0) { sb.append(delimiter); } sb.append(strings.get(i)); } return sb.toString(); }
Source:
<code>private boolean checkForAvailabilityIn(String applicationIdentifier, int times) throws InterruptedException { while (times > 0) { for (WebkitApplication application : registeredApplications) { if (application.getBundleId().equals(applicationIdentifier)) { if (log.isLoggable(Level.FINE)) { <START> log.log(Level.FINE, "application available in registeredApplications"); <END> } return true; } } if (--times == 0) break; if (log.isLoggable(Level.FINE)) { log.log(Level.FINE, "Sleeping for 10 ms in checking availability..."); } Thread.sleep(10); } return false; }</code><technical_language>"registered applications" consistent message line 180 ? :)</technical_language>

Target:
private boolean checkForAvailabilityIn(String applicationIdentifier, int times) throws InterruptedException { while (times > 0) { for (WebkitApplication application : registeredApplications) { if (application.getBundleId().equals(applicationIdentifier)) { if (log.isLoggable(Level.FINE)) { log.log(Level.FINE, "Application available in the list of registered applications"); } return true; } } if (--times == 0) { break; } if (log.isLoggable(Level.FINE)) { log.log(Level.FINE, "Sleeping for 10 ms in checking availability..."); } Thread.sleep(10); } return false; }
Source:
<code>public Set<String> getStageNames() { <START> return stages.keySet(); <END> }</code><technical_language>this method create a copy of set getStages()</technical_language>

Target:
public Set<String> getStageNames() { return Collections.unmodifiableSet(new HashSet<String>(stages.keySet())); }
Source:
<code>private void validateMetrics(final List<CollectWgsMetricsFromQuerySorted.QuerySortedSeqMetrics> metrics, final long genomeSize) { for (final CollectWgsMetricsFromQuerySorted.QuerySortedSeqMetrics row : metrics) { <START> final boolean isRaw = row.TYPE == CollectWgsMetricsFromQuerySorted.FILTERING_STRINGENCY.RAW; <END> Assert.assertEquals(row.GENOME_TERRITORY, genomeSize); Assert.assertEquals(row.TOTAL_BASES, 606); Assert.assertEquals(row.TOTAL_PASSING_BASES, isRaw ? 238 : 200); Assert.assertEquals(row.PCT_EXC_OVERLAP, isRaw ? 0.085809 : 0.013201); Assert.assertEquals(row.PCT_EXC_BASEQ, isRaw ? 0.188119 : 0.156766); Assert.assertEquals(row.PCT_EXC_MAPQ, isRaw ? 0.0 : 0.166667); Assert.assertEquals(row.PCT_EXC_DUPE, 0.333333); Assert.assertEquals(row.TOTAL_READ_PAIRS, 3); Assert.assertEquals(row.TOTAL_DUPE_PAIRS, 1); Assert.assertEquals(row.TOTAL_ORIENTED_PAIRS, 2); Assert.assertEquals(row.MEAN_INSERT_SIZE, 118.0); } }</code><technical_language>check for actual modify - MEAN_COVERAGE</technical_language>

Target:
private void validateMetrics(final List<CollectWgsMetricsFromQuerySorted.QuerySortedSeqMetrics> metrics, final long genomeSize) { for (final CollectWgsMetricsFromQuerySorted.QuerySortedSeqMetrics row : metrics) { final boolean isRaw = row.TYPE == CollectWgsMetricsFromQuerySorted.FILTERING_STRINGENCY.RAW; Assert.assertEquals(row.GENOME_TERRITORY, genomeSize); Assert.assertEquals(row.TOTAL_BASES, 606); Assert.assertEquals(row.TOTAL_PASSING_BASES, isRaw ? 238 : 200); Assert.assertEquals(row.PCT_EXC_OVERLAP, isRaw ? 0.085809 : 0.013201); Assert.assertEquals(row.PCT_EXC_BASEQ, isRaw ? 0.188119 : 0.156766); Assert.assertEquals(row.PCT_EXC_MAPQ, isRaw ? 0.0 : 0.166667); Assert.assertEquals(row.PCT_EXC_DUPE, 0.333333); Assert.assertEquals(row.TOTAL_READ_PAIRS, 3); Assert.assertEquals(row.TOTAL_DUPE_PAIRS, 1); Assert.assertEquals(row.TOTAL_ORIENTED_PAIRS, 2); Assert.assertEquals(row.MEAN_INSERT_SIZE, 118.0); final BigDecimal meanCov = new BigDecimal((double)row.TOTAL_PASSING_BASES / genomeSize).setScale(6, RoundingMode.HALF_UP); Assert.assertEquals(Double.compare(row.MEAN_COVERAGE, meanCov.doubleValue()), 0); } }
Source:
<code>public List<RebaseTodoLine> readRebaseTodo(String path, boolean includeComments) throws IOException { byte[] buf = IO.readFully(new File(repo.getDirectory(), path)); int ptr = 0; int tokenBegin = 0; List<RebaseTodoLine> r = new LinkedList<RebaseTodoLine>(); while (ptr < buf.length) { tokenBegin = ptr; ptr = RawParseUtils.nextLF(buf, ptr); int lineStart = tokenBegin; int lineEnd = ptr - 2; if (lineEnd >= 0 && buf[lineEnd] == '\r') lineEnd--; if (buf[tokenBegin] == '#') { <START> if (includeComments) { <END> parseComments(buf, tokenBegin, r, lineEnd); } } else { tokenBegin = nextParsableToken(buf, tokenBegin, lineEnd); if (tokenBegin == -1) { if (includeComments) r.add(new RebaseTodoLine(RawParseUtils.decode(buf, lineStart, 1 + lineEnd))); continue; } RebaseTodoLine line = parseLine(buf, tokenBegin, lineEnd); if (line == null) continue; r.add(line); } } return r; }</code><technical_language>style nit: braces</technical_language>

Target:
public List<RebaseTodoLine> readRebaseTodo(String path, boolean includeComments) throws IOException { byte[] buf = IO.readFully(new File(repo.getDirectory(), path)); int ptr = 0; int tokenBegin = 0; List<RebaseTodoLine> r = new LinkedList<RebaseTodoLine>(); while (ptr < buf.length) { tokenBegin = ptr; ptr = RawParseUtils.nextLF(buf, ptr); int lineStart = tokenBegin; int lineEnd = ptr - 2; if (lineEnd >= 0 && buf[lineEnd] == '\r') lineEnd--; if (buf[tokenBegin] == '#') { if (includeComments) parseComments(buf, tokenBegin, r, lineEnd); } else { tokenBegin = nextParsableToken(buf, tokenBegin, lineEnd); if (tokenBegin == -1) { if (includeComments) r.add(new RebaseTodoLine(RawParseUtils.decode(buf, lineStart, 1 + lineEnd))); continue; } RebaseTodoLine line = parseLine(buf, tokenBegin, lineEnd); if (line == null) continue; r.add(line); } } return r; }
Source:
<code>public static void setupLogging() { final Logger rootLogger = LogManager.getRootLogger(); rootLogger.setLevel(Level.OFF); <START> final ConsoleAppender ca = (ConsoleAppender) rootLogger.getAppender("stdout"); <END> ca.setLayout(new PatternLayout("%d{MMM dd yyyy HH:mm:ss} %5p [%t] (%F:%L) - %m%n")); rootLogger.setLevel(Level.INFO); Logger.getLogger(ClientCnxn.class).setLevel(Level.OFF); Logger.getLogger(MockMongoFactory.class).setLevel(Level.OFF); }</code><technical_language>Do need this if created config file</technical_language>

Target:
public static void setupLogging() { final Logger rootLogger = LogManager.getRootLogger(); final ConsoleAppender ca = (ConsoleAppender) rootLogger.getAppender("stdout"); ca.setLayout(new PatternLayout("%d{MMM dd yyyy HH:mm:ss} %5p [%t] (%F:%L) - %m%n")); rootLogger.setLevel(Level.INFO); Logger.getLogger(ClientCnxn.class).setLevel(Level.OFF); Logger.getLogger(MockMongoFactory.class).setLevel(Level.OFF); }
Source:
<code>private boolean filterNode(StructuralNode node) { for (ScanFilter scanFilter : parentScanner.getScanFilters()) { try { FilterResult filterResult = scanFilter.isFiltered(node); if (filterResult.isFiltered()) { try { HttpMessage msg = node.getHistoryReference().getHttpMessage(); parentScanner.notifyFilteredMessage(msg, filterResult.getReason()); } catch (HttpMalformedHeaderException | DatabaseException e) { <START> log.error( <END> "Error while getting httpmessage from history reference: " + e.getMessage(), e); } if (log.isDebugEnabled()) { log.debug( "Ignoring filtered node: " + node.getName() + " Reason: " + filterResult.getReason()); } return true; } } catch (Exception ex) { log.error(ex.getMessage(), ex); } } return false; }</code><technical_language>This warning (also, for consistency log line 554)</technical_language>

Target:
private boolean filterNode(StructuralNode node) { for (ScanFilter scanFilter : parentScanner.getScanFilters()) { try { FilterResult filterResult = scanFilter.isFiltered(node); if (filterResult.isFiltered()) { try { HttpMessage msg = node.getHistoryReference().getHttpMessage(); parentScanner.notifyFilteredMessage(msg, filterResult.getReason()); } catch (HttpMalformedHeaderException | DatabaseException e) { log.warn( "Error while getting httpmessage from history reference: " + e.getMessage(), e); } if (log.isDebugEnabled()) { log.debug( "Ignoring filtered node: " + node.getName() + " Reason: " + filterResult.getReason()); } return true; } } catch (Exception ex) { log.error(ex.getMessage(), ex); } } return false; }
Source:
<code>private void checkRuleParams( boolean checkRuleID ) { <START> if( nodeId == null || nodeId.trim().length() == 0 ) <END> { throw new IllegalArgumentException( "nodeId must be specified" ); } if( checkRuleID ) { if( ruleID == null || ruleID.trim().length() == 0 ) { throw new IllegalArgumentException( "ruleID must be specified" ); } } }</code><technical_language>StringUtils.isBlank(nodeId)</technical_language>

Target:
private void checkRuleParams( boolean checkRuleID ) { if( StringUtils.isBlank( nodeId ) ) { throw new IllegalArgumentException( "nodeId must be specified" ); } if( checkRuleID ) { if( StringUtils.isBlank( ruleID ) ) { throw new IllegalArgumentException( "ruleID must be specified" ); } } }
Source:
<code>public static void setUp() { <START> setUp("rabbit"); <END> }</code><technical_language>Overdid - setUp("redis")</technical_language>

Target:
public static void setUp() { setUp("redis"); }
Source:
<code>public abstract void writeTo(OutputStream os, ContentFilter filter) throws IOException; @Override <START> public boolean shouldBeFiltered() { <END> return false; }</code><technical_language>this declared final</technical_language>

Target:
public abstract void writeTo(OutputStream os, ContentFilter filter) throws IOException; @Override public final boolean shouldBeFiltered() { return false; }
Source:
<code>public KetchSystem() { this(defaultExecutor(), <START> "refs/txn/"); <END> }</code><technical_language>this a constant in KetchConstants</technical_language>

Target:
public KetchSystem() { this(defaultExecutor(), DEFAULT_TXN_NAMESPACE); }
Source:
<code>public void onSessionExpired() { if (_shutdown) { return; } stopEventThread(); <START> _leaderDatastreamAddOrDeleteEventScheduled.set(false); <END> if (_leaderDatastreamAddOrDeleteEventScheduledFuture != null) { _leaderDatastreamAddOrDeleteEventScheduledFuture.cancel(true); _leaderDatastreamAddOrDeleteEventScheduledFuture = null; } _leaderDoAssignmentScheduled.set(false); if (_leaderDoAssignmentScheduledFuture != null) { _leaderDoAssignmentScheduledFuture.cancel(true); _leaderDoAssignmentScheduledFuture = null; } _eventQueue.clear(); List<Future<Boolean>> assignmentChangeFutures = _connectors.keySet().stream() .map(connectorType -> { _assignmentChangeThreadPool.get(connectorType).shutdownNow(); _assignmentChangeThreadPool.put(connectorType, Executors.newSingleThreadExecutor()); return dispatchAssignmentChangeIfNeeded(connectorType, new ArrayList<>(), false, false); }) .filter(Objects::nonNull) .collect(Collectors.toList()); ExecutorService threadPoolExecutor = Executors.newFixedThreadPool(1); threadPoolExecutor.submit(() -> { Instant start = Instant.now(); try { getAssignmentsFuture(assignmentChangeFutures, start); } catch (Exception e) { _log.warn("Hit exception while clearing the assignment list", e); } finally { assignmentChangeFutures.forEach(future -> future.cancel(true)); } }); onDatastreamChange(new ArrayList<>()); _assignedDatastreamTasks.clear(); }</code><technical_language>sure, setting this false vs. cancel future a difference</technical_language>

Target:
public void onSessionExpired() { _log.info("Coordinator::onSessionExpired is called"); _zkSessionExpired = true; if (_shutdown) { return; } stopEventThread(); _leaderDatastreamAddOrDeleteEventScheduled.set(false); if (_leaderDatastreamAddOrDeleteEventScheduledFuture != null) { _leaderDatastreamAddOrDeleteEventScheduledFuture.cancel(true); _leaderDatastreamAddOrDeleteEventScheduledFuture = null; } _leaderDoAssignmentScheduled.set(false); if (_leaderDoAssignmentScheduledFuture != null) { _leaderDoAssignmentScheduledFuture.cancel(true); _leaderDoAssignmentScheduledFuture = null; } _eventQueue.clear(); List<Future<Boolean>> assignmentChangeFutures = _connectors.keySet().stream() .map(connectorType -> { _assignmentChangeThreadPool.get(connectorType).shutdownNow(); _assignmentChangeThreadPool.put(connectorType, Executors.newSingleThreadExecutor()); return dispatchAssignmentChangeIfNeeded(connectorType, new ArrayList<>(), false, false); }) .filter(Objects::nonNull) .collect(Collectors.toList()); onDatastreamChange(new ArrayList<>()); for (DatastreamTask task : _assignedDatastreamTasks.values()) { ((EventProducer) task.getEventProducer()).shutdown(true); } ExecutorService threadPoolExecutor = Executors.newFixedThreadPool(1); threadPoolExecutor.submit(() -> { Instant start = Instant.now(); try { getAssignmentsFuture(assignmentChangeFutures, start); } catch (Exception e) { _log.warn("Hit exception while clearing the assignment list", e); } finally { assignmentChangeFutures.forEach(future -> future.cancel(true)); } }); _assignedDatastreamTasks.clear(); _log.info("Coordinator::onSessionExpired completed successfully."); }
Source:
<code>protected int doWork() { if (OUTPUT.exists()) { throw new PicardException(OUTPUT.getAbsolutePath() + " already exists. Delete this file and try again, or specify a different output file."); } final SortingCollection<String> sequenceNames = makeSortingCollection(); try (BufferedWriter writer = makeWriter()) { final ReferenceSequenceFile refSeqFile = ReferenceSequenceFileFactory. getReferenceSequenceFile(REFERENCE, TRUNCATE_NAMES_AT_WHITESPACE); SAMSequenceDictionaryCodec samDictCodec = new SAMSequenceDictionaryCodec(writer); samDictCodec.encodeHeaderLine(false); ReferenceSequence refSeq; while ((refSeq = refSeqFile.nextSequence()) != null) { final SAMSequenceRecord samSequenceRecord = makeSequenceRecord(refSeq); samDictCodec.encodeSequenceRecord(samSequenceRecord); sequenceNames.add(refSeq.getName()); } } catch (FileNotFoundException e) { throw new PicardException("File " + OUTPUT.getAbsolutePath() + " not found"); } catch (IOException e) { throw new PicardException("Can't write to or close output file " + OUTPUT.getAbsolutePath()); } final CloseableIterator<String> iterator = sequenceNames.iterator(); <START> String first = iterator.hasNext() ? iterator.next() : ""; <END> while (iterator.hasNext()) { final String next = iterator.next(); if (first.equals(next)) { OUTPUT.delete(); throw new PicardException("Sequence name " + first + " appears more than once in reference file"); } first = next; } return 0; }</code><technical_language>I more clear if(!iterator.hasNext()) return 0; String = iterator.next();</technical_language>

Target:
protected int doWork() { if (OUTPUT.exists()) { throw new PicardException(OUTPUT.getAbsolutePath() + " already exists. Delete this file and try again, or specify a different output file."); } final SortingCollection<String> sequenceNames = makeSortingCollection(); try (BufferedWriter writer = makeWriter()) { final ReferenceSequenceFile refSeqFile = ReferenceSequenceFileFactory. getReferenceSequenceFile(REFERENCE, TRUNCATE_NAMES_AT_WHITESPACE); SAMSequenceDictionaryCodec samDictCodec = new SAMSequenceDictionaryCodec(writer); samDictCodec.encodeHeaderLine(false); for (ReferenceSequence refSeq = refSeqFile.nextSequence(); refSeq != null; refSeq = refSeqFile.nextSequence()) { final SAMSequenceRecord samSequenceRecord = makeSequenceRecord(refSeq); samDictCodec.encodeSequenceRecord(samSequenceRecord); sequenceNames.add(refSeq.getName()); } } catch (FileNotFoundException e) { throw new PicardException("File " + OUTPUT.getAbsolutePath() + " not found"); } catch (IOException e) { throw new PicardException("Can't write to or close output file " + OUTPUT.getAbsolutePath()); } final CloseableIterator<String> iterator = sequenceNames.iterator(); if(!iterator.hasNext()) return 0; String current = iterator.next(); while (iterator.hasNext()) { final String next = iterator.next(); if (current.equals(next)) { OUTPUT.delete(); throw new PicardException("Sequence name " + current + " appears more than once in reference file"); } current = next; } return 0; }
Source:
<code>public void setUp() throws Exception { serializedCommandFilterData = new XStreamSerializer().serialize(COMMAND_NAME_FILTER, String.class).getData(); serializedCommandFilterClassName = COMMAND_NAME_FILTER.getClass().getName(); String atomicConsistentHashFieldName = "atomicConsistentHash"; atomicConsistentHashField = SpringCloudCommandRouter.class.getDeclaredField(atomicConsistentHashFieldName); String blackListedServiceInstancesFieldName = "blackListedServiceInstances"; blackListedServiceInstancesField = SpringCloudCommandRouter.class.getDeclaredField( blackListedServiceInstancesFieldName); serviceInstanceMetadata = new HashMap<>(); when(localServiceInstance.getServiceId()).thenReturn(SERVICE_INSTANCE_ID); when(localServiceInstance.getUri()).thenReturn(SERVICE_INSTANCE_URI); when(localServiceInstance.getMetadata()).thenReturn(serviceInstanceMetadata); when(discoveryClient.getServices()).thenReturn(singletonList(SERVICE_INSTANCE_ID)); when(discoveryClient.getInstances(SERVICE_INSTANCE_ID)) .thenReturn(singletonList(localServiceInstance)); when(routingStrategy.getRoutingKey(any())).thenReturn(ROUTING_KEY); testSubject = SpringCloudCommandRouter.builder() .discoveryClient(discoveryClient) .localServiceInstance(localServiceInstance) .routingStrategy(routingStrategy) <START> .serviceInstanceFilter(s -> true) <END> .consistentHashChangeListener(consistentHashChangeListener) .build(); }</code><technical_language>nit: change this s serviceInstance well? in line 337/378</technical_language>

Target:
public void setUp() throws Exception { serializedCommandFilterData = new XStreamSerializer().serialize(COMMAND_NAME_FILTER, String.class).getData(); serializedCommandFilterClassName = COMMAND_NAME_FILTER.getClass().getName(); String atomicConsistentHashFieldName = "atomicConsistentHash"; atomicConsistentHashField = SpringCloudCommandRouter.class.getDeclaredField(atomicConsistentHashFieldName); String blackListedServiceInstancesFieldName = "blackListedServiceInstances"; blackListedServiceInstancesField = SpringCloudCommandRouter.class.getDeclaredField( blackListedServiceInstancesFieldName); serviceInstanceMetadata = new HashMap<>(); when(localServiceInstance.getServiceId()).thenReturn(SERVICE_INSTANCE_ID); when(localServiceInstance.getUri()).thenReturn(SERVICE_INSTANCE_URI); when(localServiceInstance.getMetadata()).thenReturn(serviceInstanceMetadata); when(discoveryClient.getServices()).thenReturn(singletonList(SERVICE_INSTANCE_ID)); when(discoveryClient.getInstances(SERVICE_INSTANCE_ID)) .thenReturn(singletonList(localServiceInstance)); when(routingStrategy.getRoutingKey(any())).thenReturn(ROUTING_KEY); testSubject = SpringCloudCommandRouter.builder() .discoveryClient(discoveryClient) .localServiceInstance(localServiceInstance) .routingStrategy(routingStrategy) .serviceInstanceFilter(serviceInstance -> true) .consistentHashChangeListener(consistentHashChangeListener) .build(); }
Source:
<code>public SiteRequestCondition(SiteResolver siteResolver, Set<String> validSites){ this.siteResolver = Preconditions.checkNotNull(siteResolver); <START> this.validSites = ImmutableSet.copyOf(Preconditions.checkNotNull(validSites)); <END> }</code><technical_language>need checkNotNull here. ImmutableSet.copyOf checks for null arguments own</technical_language>

Target:
public SiteRequestCondition(SiteResolver siteResolver, Set<String> validSites){ this.siteResolver = Preconditions.checkNotNull(siteResolver); this.validSites = ImmutableSet.copyOf(validSites); }
Source:
<code>public static Slice toSphericalGeography(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { Envelope envelope = deserializeEnvelope(input); if (envelope != null && !envelope.isEmpty()) { <START> validateSphericalPoint(envelope.getUpperLeft()); <END> validateSphericalPoint(envelope.getUpperRight()); validateSphericalPoint(envelope.getLowerLeft()); validateSphericalPoint(envelope.getLowerRight()); } return input; }</code><technical_language>sufficient check lower-left upper-right corners. checkLatitude(envelope.getYMin()); checkLatitude(envelope.getYMax()); checkLongitude(envelope.getXMin()); checkLongitude(envelope.getXMax());</technical_language>

Target:
public static Slice toSphericalGeography(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { Envelope envelope = deserializeEnvelope(input); if (envelope != null) { checkLatitude(envelope.getYMin()); checkLatitude(envelope.getYMax()); checkLongitude(envelope.getXMin()); checkLongitude(envelope.getXMax()); } OGCGeometry geometry = deserialize(input); if (geometry.is3D()) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Cannot convert 3D geometry to a spherical geography"); } GeometryCursor cursor = geometry.getEsriGeometryCursor(); while (true) { com.esri.core.geometry.Geometry subGeometry = cursor.next(); if (subGeometry == null) { break; } if (!GEOMETRY_TYPES_FOR_SPHERICAL_GEOGRAPHY.contains(subGeometry.getType())) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Cannot convert geometry of this type to spherical geography: " + subGeometry.getType()); } } return input; }
Source:
<code>public @Nullable String resolve(ITmfStateSystem ss, long value, int quark) throws StateSystemDisposedException { <START> Map<Long, String> stringPool = fStringPools.computeIfAbsent(quark, unused -> HashBiMap.<String, Long> create()).inverse(); <END> if (quark != ITmfStateSystem.INVALID_ATTRIBUTE) { String string = stringPool.get(value); if (string != null) { return string; } Object resolved = ss.querySingleState(value, quark).getValue(); if (resolved instanceof String) { return (String) resolved; } } return null; }</code><technical_language>this if statement</technical_language>

Target:
public @Nullable String resolve(ITmfStateSystem ss, long value, int quark) throws StateSystemDisposedException { if (quark != ITmfStateSystem.INVALID_ATTRIBUTE) { Map<Long, String> stringPool = fStringPools.computeIfAbsent(quark, unused -> HashBiMap.<String, Long> create()).inverse(); String string = stringPool.get(value); if (string != null) { return string; } Object resolved = ss.querySingleState(value, quark).getValue(); if (resolved instanceof String) { return (String) resolved; } } return null; }
Source:
<code>public void getMeasurementJsonSuccess() { final CountDownLatch signal = new CountDownLatch(1); <START> new OkHttpClient().newCall(new Request.Builder().url(JSON_URL).build()).enqueue(new GetMeasurementCallback() { <END> @Override public void onSuccess(String json) { Assert.assertNotNull(json); signal.countDown(); } @Override public void onError(String msg) { Assert.fail(); signal.countDown(); } }); try { signal.await(1, TimeUnit.MINUTES); } catch (InterruptedException e) { e.printStackTrace(); Assert.fail(); } }</code><technical_language>singleton client</technical_language>

Target:
public void getMeasurementJsonSuccess() { final CountDownLatch signal = new CountDownLatch(1); a.getOkHttpClient().newCall(new Request.Builder().url(JSON_URL).build()).enqueue(new GetMeasurementJsonCallback() { @Override public void onSuccess(String json) { Assert.assertNotNull(json); signal.countDown(); } @Override public void onError(String msg) { Assert.fail(); signal.countDown(); } }); try { signal.await(1, TimeUnit.MINUTES); } catch (InterruptedException e) { e.printStackTrace(); Assert.fail(); } }
Source:
<code><START> public boolean handleSelectedContextItem(AdapterView.AdapterContextMenuInfo info, MenuItem item) { <END> try { if (item.getGroupId() == 2) { ProfileData data = (ProfileData) info.targetView.getTag(); if (item.getItemId() == 0) { startActivity( new Intent(mContext, ProfileActivity.class).putExtra( "profile", data ) ); } else if (item.getItemId() == 1) { if (data.isAdmin()) { Toast.makeText(mContext, R.string.info_platoon_member_demoting, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(mContext, R.string.info_platoon_member_promoting, Toast.LENGTH_SHORT).show(); } new AsyncPlatoonMemberManagement(mContext, data.getId(), mPlatoonData).execute(!data.isAdmin()); } else if (item.getItemId() == 2) { Toast.makeText(mContext, R.string.info_platoon_member_kicking, Toast.LENGTH_SHORT).show(); new AsyncPlatoonMemberManagement(mContext, data.getId(), mPlatoonData).execute(); } else if (item.getItemId() == 3) { Toast.makeText(mContext, R.string.info_platoon_member_new_ok, Toast.LENGTH_SHORT).show(); new AsyncPlatoonRespond( mContext, mPlatoonData, data.getId(), true ).execute( mSharedPreferences.getString(Constants.SP_BL_PROFILE_CHECKSUM, "") ); } else if (item.getItemId() == 4) { Toast.makeText(mContext, R.string.info_platoon_member_new_false, Toast.LENGTH_SHORT).show(); new AsyncPlatoonRespond( mContext, mPlatoonData, data.getId(), false ).execute(mSharedPreferences.getString(Constants.SP_BL_PROFILE_CHECKSUM, "")); } } } catch (Exception ex) { ex.printStackTrace(); return false; } return true; }</code><technical_language>complexity. switch statement simple call specific method calls this complex if/else statement more readable simpler</technical_language>

Target:
public boolean handleSelectedContextItem(AdapterView.AdapterContextMenuInfo info, MenuItem item) { if (item.getGroupId() == 2) { ProfileData user = (ProfileData) info.targetView.getTag(); switch(item.getItemId()) { case 0: startActivity(new Intent(mContext, ProfileActivity.class).putExtra("profile", user)); break; case 1: modifyMembership(user); break; case 2: kickUser(user); break; case 3: answerUserApplication(user, true); break; case 4: answerUserApplication(user, false); break; default: return false; } } return true; }
Source:
<code>public void testCompleteVerificationScan() { Buffer buffer = (Buffer) store; buffer.start(); <START> addRandomElementsToBufferAndList(buffer, TestData.getScaleCount()); <END> Iterator<Write> iterator = buffer.iterator(); while(iterator.hasNext()) { buffer.verify(iterator.next(), true); } float percent = Reflection.call(buffer, "getPercentVerifyScans"); Assert.assertTrue(percent == 1.0f); }</code><technical_language>save list a variable</technical_language>

Target:
public void testCompleteVerificationScan() { Buffer buffer = (Buffer) store; List<Write> stored = addRandomElementsToBufferAndList(buffer, TestData.getScaleCount()); Iterator<Write> iterator = stored.iterator(); while(iterator.hasNext()) { Write write = iterator.next(); buffer.verify(write.getKey().toString(), write.getValue().getTObject(), write.getRecord().longValue()); } float percent = Reflection.call(buffer, "getPercentVerifyScans"); Assert.assertEquals(1.0f, percent, 0f); }
Source:
<code>public void testReplace() { <START> final String value1 = "A" ; <END> final String value2 = "B" ; final Cache<Integer, Object> testCache = new CacheSimple<>(5); testCache.put(1, value1); testCache.put(1, value2); assertEquals("Wrong size", 1, testCache.size()) ; assertEquals("Wrong slot contents", value2, testCache.getIfPresent(1)) ; }</code><technical_language>key constant</technical_language>

Target:
public void testReplace() { final Integer key = 1 ; final String value1 = "A" ; final String value2 = "B" ; final Cache<Integer, Object> testCache = new CacheSimple<>(5); testCache.put(key, value1); testCache.put(key, value2); assertEquals("Wrong size", 1, testCache.size()) ; assertEquals("Wrong slot contents", value2, testCache.getIfPresent(key)) ; }
Source:
<code>public static String parseRoot(String zookeepers) { int slashIndex = zookeepers.indexOf("/"); if (slashIndex != -1) { <START> return zookeepers.substring(slashIndex); <END> } return "/"; }</code><technical_language>return zookeepers.substring(slashIndex).trim() remove trailing whitespace..</technical_language>

Target:
public static String parseRoot(String zookeepers) { int slashIndex = zookeepers.indexOf("/"); if (slashIndex != -1) { return zookeepers.substring(slashIndex).trim(); } return "/"; }
Source:
<code>public HttpSecurity addFilterAt(Filter filter, Class<? extends Filter> atFilter) { this.comparitor.registerAt(filter.getClass(), atFilter); <START> this.filters.add(filter); <END> return this; }</code><technical_language>addFilterBefore() addFilterAfter() call addFilter() method add filter a pre-check adding. However, new addFilterAt() method puts filter in filters member variable avoiding extra check in addFilter(). call comparitor.registerAt() (if succeeds) ensure addFilter check succeed too. current implementation work way. consistent other 2 methods of adding. Is a reasoning this seeing</technical_language>

Target:
public HttpSecurity addFilterAt(Filter filter, Class<? extends Filter> atFilter) { this.comparitor.registerAt(filter.getClass(), atFilter); return addFilter(filter); }
Source:
<code>protected boolean isImageRemovedFromStorage() { VDSReturnValue retValue = getBackend().getResourceManager().RunVdsCommand(VDSCommandType.GetImagesList, new GetImagesListVDSCommandParameters(getStorageDomainId(), getDiskImage().getStoragePoolId())); if (retValue.getSucceeded()) { List<Guid> ids = (List<Guid>) retValue.getReturnValue(); for (Guid id : ids) { if (id.equals(getDiskImage().getId())) { return false; } } return true; } else { log.warnFormat("Failed to retrieve list of images from storage domain '" + getStorageDomainId() + "', " + <START> "therefore there is no proof that image was deleted!"); <END> return false; } }</code><technical_language>s/.*/Could retrieve image list storage domain {0}, disk deleted/ Please add storage domain name</technical_language>

Target:
protected boolean isImageRemovedFromStorage() { VDSReturnValue retValue = getBackend().getResourceManager().RunVdsCommand(VDSCommandType.GetImagesList, new GetImagesListVDSCommandParameters(getStorageDomainId(), getDiskImage().getStoragePoolId())); if (retValue.getSucceeded()) { List<Guid> ids = (List<Guid>) retValue.getReturnValue(); for (Guid id : ids) { if (id.equals(getDiskImage().getId())) { return false; } } return true; } else { log.warnFormat("Could not retrieve image list from storage domain '{0}' '{1}', disk '{2}' might " + "not have been deleted", getStorageDomainId(), getStorageDomain().getName(), getDiskImage().getId()); return false; } }
Source:
<code>public void transform(StructuredRecord in, Emitter<StructuredRecord> emitter) throws Exception { StructuredRecord.Builder builder = StructuredRecord.builder(outSchema); Schema inSchema = in.getSchema(); List<Field> inFields = inSchema.getFields(); for(Field field : inFields) { <START> LOG.info("Looking at field '" + field.getName() + "'"); <END> String name = field.getName(); if(!outSchemaMap.containsKey(name)) { continue; } Schema.Type outFieldType = outSchemaMap.get(name); if(!compMap.containsKey(name) || compMap.get(name) == CompressorType.NONE) { builder.set(name, in.get(name)); } else { byte[] obj = new byte[0]; if (field.getSchema().getType() == Schema.Type.BYTES){ obj = in.get(name); } else if (field.getSchema().getType() == Schema.Type.STRING) { obj = ((String)in.get(name)).getBytes(); } byte[] outValue = new byte[0]; CompressorType type = compMap.get(name); if(type == CompressorType.SNAPPY) { outValue = Snappy.compress(obj); } else if (type == CompressorType.ZIP) { outValue = compressZIP(obj); } else if (type == CompressorType.GZIP) { outValue = compressGZIP(obj); } if(outFieldType == Schema.Type.BYTES) { builder.set(name, outValue); } } } emitter.emit(builder.build()); }</code><technical_language>Log level trace remove log line</technical_language>

Target:
public void transform(StructuredRecord in, Emitter<StructuredRecord> emitter) throws Exception { StructuredRecord.Builder builder = StructuredRecord.builder(outSchema); Schema inSchema = in.getSchema(); List<Field> inFields = inSchema.getFields(); for(Field field : inFields) { String name = field.getName(); if(!outSchemaMap.containsKey(name)) { continue; } Schema.Type outFieldType = outSchemaMap. get(name); if(!compMap.containsKey(name) || compMap.get(name) == CompressorType.NONE) { builder.set(name, in.get(name)); } else { byte[] obj = new byte[0]; if (field.getSchema().getType() == Schema.Type.BYTES){ obj = in.get(name); } else if (field.getSchema().getType() == Schema.Type.STRING) { obj = ((String)in.get(name)).getBytes(); } byte[] outValue = new byte[0]; CompressorType type = compMap.get(name); if(type == CompressorType.SNAPPY) { outValue = Snappy.compress(obj); } else if (type == CompressorType.ZIP) { outValue = compressZIP(obj); } else if (type == CompressorType.GZIP) { outValue = compressGZIP(obj); } if(outFieldType == Schema.Type.BYTES) { if(outValue != null) { builder.set(name, outValue); } } else { LOG.warn("Output field '" + name + "' is not of BYTES. In order to emit compressed data, you should set " + "it to type BYTES."); } } } emitter.emit(builder.build()); }
Source:
<code>public void shutdown() { long startTime = SystemTime.getInstance().milliseconds(); try { logger.info("shutdown started"); if (scheduler != null) { scheduler.shutdown(); if (!scheduler.awaitTermination(5, TimeUnit.MINUTES)) { logger.error("Could not terminate all tasks after scheduler shutdown"); } } if (networkServer != null) { networkServer.shutdown(); } if (requestHandlerPool != null) { requestHandlerPool.shutdown(); } if (replicationManager != null) { replicationManager.shutdown(); } if (storageManager != null) { storageManager.shutdown(); } if (connectionPool != null) { connectionPool.shutdown(); } if (reporter != null) { reporter.stop(); } if (notificationSystem != null) { try { notificationSystem.close(); } catch (IOException e) { logger.error("Error while closing notification system.", e); } } <START> if (statsManager != null) { <END> statsManager.shutdown(); } logger.info("shutdown completed"); } catch (Exception e) { logger.error("Error while shutting down server", e); } finally { shutdownLatch.countDown(); long processingTime = SystemTime.getInstance().milliseconds() - startTime; metrics.serverShutdownTimeInMs.update(processingTime); logger.info("Server shutdown time in Ms " + processingTime); } }</code><technical_language>shut this first. General rule of thumb follow - starts shuts first. Otherwise, stores shutdown stats manager calling getStatsSnapshot()</technical_language>

Target:
public void shutdown() { long startTime = SystemTime.getInstance().milliseconds(); try { logger.info("shutdown started"); if (scheduler != null) { scheduler.shutdown(); if (!scheduler.awaitTermination(5, TimeUnit.MINUTES)) { logger.error("Could not terminate all tasks after scheduler shutdown"); } } if (statsManager != null) { statsManager.shutdown(); } if (networkServer != null) { networkServer.shutdown(); } if (requestHandlerPool != null) { requestHandlerPool.shutdown(); } if (replicationManager != null) { replicationManager.shutdown(); } if (storageManager != null) { storageManager.shutdown(); } if (connectionPool != null) { connectionPool.shutdown(); } if (reporter != null) { reporter.stop(); } if (notificationSystem != null) { try { notificationSystem.close(); } catch (IOException e) { logger.error("Error while closing notification system.", e); } } logger.info("shutdown completed"); } catch (Exception e) { logger.error("Error while shutting down server", e); } finally { shutdownLatch.countDown(); long processingTime = SystemTime.getInstance().milliseconds() - startTime; metrics.serverShutdownTimeInMs.update(processingTime); logger.info("Server shutdown time in Ms " + processingTime); } }
Source:
<code>public ColumnType getExpectedColumnType(ColumnType type) { <START> return null; <END> }</code><technical_language>I return ColumnType.STRING a String</technical_language>

Target:
public ColumnType getExpectedColumnType(ColumnType type) { return ColumnType.STRING; }
Source:
<code>private AuditerMessage resolveBanSetForResource(PerunSessionImpl perunSession, BanSetForResource banSetForResource) throws InternalErrorException, AttributeNotExistsException, WrongAttributeAssignmentException { try { Member member = perunSession.getPerunBl().getMembersManagerBl().getMemberById(perunSession, banSetForResource.getMemberId()); Resource resource = perunSession.getPerunBl().getResourcesManagerBl().getResourceById(perunSession, banSetForResource.getResourceId()); <START> Attribute attribute = perunSession.getPerunBl().getAttributesManagerBl().getAttribute(perunSession, member, resource, AttributesManager.NS_MEMBER_RESOURCE_ATTR_VIRT + ":isBanned"); <END> return new AuditerMessage(perunSession, new AttributeSetForResourceAndMember(attribute, resource, member)); } catch (MemberNotExistsException | ResourceNotExistsException | MemberResourceMismatchException e) { log.error("Can't resolve virtual attribute value change for " + this.getClass().getSimpleName() + " module because of exception.", e); return null; } }</code><technical_language>This attribute name set constant. chance typo</technical_language>

Target:
private List<AuditEvent> resolveBanSetForResource(PerunSessionImpl perunSession, BanSetForResource banSetForResource) throws InternalErrorException, AttributeNotExistsException, WrongAttributeAssignmentException { List<AuditEvent> resolvingMessages = new ArrayList<>(); try { Member member = perunSession.getPerunBl().getMembersManagerBl().getMemberById(perunSession, banSetForResource.getMemberId()); Resource resource = perunSession.getPerunBl().getResourcesManagerBl().getResourceById(perunSession, banSetForResource.getResourceId()); Attribute attribute = perunSession.getPerunBl().getAttributesManagerBl().getAttribute(perunSession, member, resource, A_MR_V_isBanned); resolvingMessages.add(new AttributeSetForResourceAndMember(attribute, resource, member)); } catch (MemberNotExistsException | ResourceNotExistsException | MemberResourceMismatchException e) { log.error("Can't resolve virtual attribute value change for " + this.getClass().getSimpleName() + " module because of exception.", e); } return resolvingMessages; }
Source:
<code>public Event(String outcome, String[] context, float[] values) { <START> Objects.requireNonNull(context, "context must not be null"); <END> this.outcome = outcome; this.context = context; this.values = values; }</code><technical_language>nicer write that: this.context = Objects.requireNonNull(context, "context null"); outcome non-null</technical_language>

Target:
public Event(String outcome, String[] context, float[] values) { this.outcome = Objects.requireNonNull(outcome, "outcome must not be null"); this.context = Objects.requireNonNull(context, "context must not be null"); this.values = values; }
Source:
<code>public TableSnapshotResultIterator(Configuration configuration, Scan scan, ScanMetricsHolder scanMetricsHolder) throws IOException { this.configuration = configuration; this.currentRegion = -1; this.scan = scan; this.scanMetricsHolder = scanMetricsHolder; this.scanIterator = UNINITIALIZED_SCANNER; <START> this.restoreDir = new Path(new Path(configuration.get(PhoenixConfigurationUtil.RESTORE_DIR_KEY)), <END> UUID.randomUUID().toString()); this.snapshotName = configuration.get( PhoenixConfigurationUtil.SNAPSHOT_NAME_KEY); this.rootDir = FSUtils.getRootDir(configuration); this.fs = rootDir.getFileSystem(configuration); init(); }</code><technical_language>Path offers other API <LINK_0> of params String</technical_language>

Target:
public TableSnapshotResultIterator(Configuration configuration, Scan scan, ScanMetricsHolder scanMetricsHolder) throws IOException { this.configuration = configuration; this.currentRegion = -1; this.scan = scan; this.scanMetricsHolder = scanMetricsHolder; this.scanIterator = UNINITIALIZED_SCANNER; this.restoreDir = new Path(configuration.get(PhoenixConfigurationUtil.RESTORE_DIR_KEY), UUID.randomUUID().toString()); this.snapshotName = configuration.get( PhoenixConfigurationUtil.SNAPSHOT_NAME_KEY); this.rootDir = FSUtils.getRootDir(configuration); this.fs = rootDir.getFileSystem(configuration); init(); }
Source:
<code>public BasicClusterDataCache(String clusterName) { _propertyDataChangedMap = new ConcurrentHashMap<>(); _externalViewCache = new ExternalViewCache(clusterName); _clusterName = clusterName; <START> DEFAULT_CONTEXT_PROVIDER = AbstractDataCache.createDefaultControlContextProvider(clusterName); <END> _liveInstancePropertyCache = new PropertyCache<>(DEFAULT_CONTEXT_PROVIDER, LIVE_INSTANCE, new PropertyCache.PropertyCacheKeyFuncs<LiveInstance>() { @Override public PropertyKey getRootKey(HelixDataAccessor accessor) { return accessor.keyBuilder().liveInstances(); } @Override public PropertyKey getObjPropertyKey(HelixDataAccessor accessor, String objName) { return accessor.keyBuilder().liveInstance(objName); } @Override public String getObjName(LiveInstance obj) { return obj.getInstanceName(); } }, true); _instanceConfigPropertyCache = new PropertyCache<>(DEFAULT_CONTEXT_PROVIDER, INSTANCE_CONFIG, new PropertyCache.PropertyCacheKeyFuncs<InstanceConfig>() { @Override public PropertyKey getRootKey(HelixDataAccessor accessor) { return accessor.keyBuilder().instanceConfigs(); } @Override public PropertyKey getObjPropertyKey(HelixDataAccessor accessor, String objName) { return accessor.keyBuilder().instanceConfig(objName); } @Override public String getObjName(InstanceConfig obj) { return obj.getInstanceName(); } }, true); }</code><technical_language>Please refer this class</technical_language>

Target:
public BasicClusterDataCache(String clusterName) { _propertyDataChangedMap = new ConcurrentHashMap<>(); _externalViewCache = new ExternalViewCache(clusterName); _clusterName = clusterName; _clusterEventId = AbstractDataCache.UNKNOWN_EVENT_ID; _liveInstancePropertyCache = new PropertyCache<>(this, LIVE_INSTANCE, new PropertyCache.PropertyCacheKeyFuncs<LiveInstance>() { @Override public PropertyKey getRootKey(HelixDataAccessor accessor) { return accessor.keyBuilder().liveInstances(); } @Override public PropertyKey getObjPropertyKey(HelixDataAccessor accessor, String objName) { return accessor.keyBuilder().liveInstance(objName); } @Override public String getObjName(LiveInstance obj) { return obj.getInstanceName(); } }, true); _instanceConfigPropertyCache = new PropertyCache<>(this, INSTANCE_CONFIG, new PropertyCache.PropertyCacheKeyFuncs<InstanceConfig>() { @Override public PropertyKey getRootKey(HelixDataAccessor accessor) { return accessor.keyBuilder().instanceConfigs(); } @Override public PropertyKey getObjPropertyKey(HelixDataAccessor accessor, String objName) { return accessor.keyBuilder().instanceConfig(objName); } @Override public String getObjName(InstanceConfig obj) { return obj.getInstanceName(); } }, true); }