auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public synchronized JSONObject getDebugState() { JSONObject debugState = new JSONObject(); debugState.put( "class", VP8AdaptiveTrackProjectionContext.class.getSimpleName()); JSONArray mapSizes = new JSONArray(); int i = 0; <START> for (long ssrc: vp8FrameMaps.keySet()) <END> { JSONObject sizeInfo = new JSONObject(); sizeInfo.put("ssrc", ssrc); sizeInfo.put("size", vp8FrameMaps.get(ssrc).size()); mapSizes.add(sizeInfo); } debugState.put( "vp8FrameMaps", mapSizes); debugState.put("vp8QualityFilter", vp8QualityFilter.getDebugState()); debugState.put("payloadType", payloadType.toString()); return debugState; }</code><technical_language>end retrieving value, iterate of entries of map (instead of keySet)</technical_language>

Target:
public synchronized JSONObject getDebugState() { JSONObject debugState = new JSONObject(); debugState.put( "class", VP8AdaptiveTrackProjectionContext.class.getSimpleName()); JSONArray mapSizes = new JSONArray(); int i = 0; for (Map.Entry<Long, VP8FrameMap> entry: vp8FrameMaps.entrySet()) { JSONObject sizeInfo = new JSONObject(); sizeInfo.put("ssrc", entry.getKey()); sizeInfo.put("size", entry.getValue().size()); mapSizes.add(sizeInfo); } debugState.put( "vp8FrameMaps", mapSizes); debugState.put("vp8QualityFilter", vp8QualityFilter.getDebugState()); debugState.put("payloadType", payloadType.toString()); return debugState; }
Source:
<code>public void transferFailed(TransferEvent event) { transferCompleted(event); <START> logger.warn(event.getException().getMessage()); <END> }</code><technical_language>a good update</technical_language>

Target:
public void transferFailed(TransferEvent event) { transferCompleted(event); logger.warn("Unsuccessful transfer", event.getException()); }
Source:
<code>private String makePattern(String template) { String compilerPatternExtended = getCompilerPatternExtended(); <START> Map<String, String> map = new HashMap<>(); <END> map.put("${COMPILER_PATTERN}", compilerPatternExtended); map.put("${EXTENSIONS_PATTERN}", getPatternFileExtensions()); map.put("${COMPILER_GROUPS+1}", Integer.toString(countGroups(compilerPatternExtended) + 1)); String pattern = replaceFromMap(template, map); return pattern; }</code><technical_language>depends : getCompilerPatternExtended() getPatternFileExtensions() return</technical_language>

Target:
private String makePattern(String template) { String compilerPatternExtended = getCompilerPatternExtended(); if (replaceMap == null) { replaceMap = new HashMap<>(); replaceMap.put("${COMPILER_PATTERN}", compilerPatternExtended); replaceMap.put("${EXTENSIONS_PATTERN}", getPatternFileExtensions()); replaceMap.put("${COMPILER_GROUPS+1}", Integer.toString(countGroups(compilerPatternExtended) + 1)); } String pattern = replace(template, replaceMap); return pattern; }
Source:
<code>TableMetadata parseVirtualTable( AdminRow tableRow, CqlIdentifier keyspaceId, Map<CqlIdentifier, UserDefinedType> userTypes) { CqlIdentifier tableId = CqlIdentifier.fromInternal( <START> tableRow.getString(rows.isCassandraV3 ? "table_name" : "columnfamily_name")); <END> List<RawColumn> rawColumns = RawColumn.toRawColumns( rows.virtualColumns.getOrDefault(keyspaceId, ImmutableMultimap.of()).get(tableId), keyspaceId, userTypes); if (rawColumns.isEmpty()) { LOG.warn( "[{}] Processing TABLE refresh for {}.{} but found no matching rows, skipping", logPrefix, keyspaceId, tableId); return null; } Collections.sort(rawColumns); ImmutableMap.Builder<CqlIdentifier, ColumnMetadata> allColumnsBuilder = ImmutableMap.builder(); for (RawColumn raw : rawColumns) { DataType dataType = dataTypeParser.parse(keyspaceId, raw.dataType, userTypes, context); ColumnMetadata column = new DefaultColumnMetadata( keyspaceId, tableId, raw.name, dataType, raw.kind == RawColumn.Kind.STATIC); allColumnsBuilder.put(column.getName(), column); } return new DefaultTableMetadata( keyspaceId, tableId, new UUID(0L, 0L), false, Collections.emptyList(), Collections.emptyMap(), allColumnsBuilder.build(), Collections.emptyMap(), Collections.emptyMap()); }</code><technical_language>Nit: virtual tables 4.0+ column table_name</technical_language>

Target:
TableMetadata parseVirtualTable( AdminRow tableRow, CqlIdentifier keyspaceId, Map<CqlIdentifier, UserDefinedType> userTypes) { CqlIdentifier tableId = CqlIdentifier.fromInternal(tableRow.getString("table_name")); List<RawColumn> rawColumns = RawColumn.toRawColumns( rows.virtualColumns().getOrDefault(keyspaceId, ImmutableMultimap.of()).get(tableId), keyspaceId, userTypes); if (rawColumns.isEmpty()) { LOG.warn( "[{}] Processing TABLE refresh for {}.{} but found no matching rows, skipping", logPrefix, keyspaceId, tableId); return null; } Collections.sort(rawColumns); ImmutableMap.Builder<CqlIdentifier, ColumnMetadata> allColumnsBuilder = ImmutableMap.builder(); ImmutableList.Builder<ColumnMetadata> partitionKeyBuilder = ImmutableList.builder(); ImmutableMap.Builder<ColumnMetadata, ClusteringOrder> clusteringColumnsBuilder = ImmutableMap.builder(); for (RawColumn raw : rawColumns) { DataType dataType = rows.dataTypeParser().parse(keyspaceId, raw.dataType, userTypes, context); ColumnMetadata column = new DefaultColumnMetadata( keyspaceId, tableId, raw.name, dataType, raw.kind.equals(RawColumn.KIND_STATIC)); switch (raw.kind) { case RawColumn.KIND_PARTITION_KEY: partitionKeyBuilder.add(column); break; case RawColumn.KIND_CLUSTERING_COLUMN: clusteringColumnsBuilder.put( column, raw.reversed ? ClusteringOrder.DESC : ClusteringOrder.ASC); break; default: } allColumnsBuilder.put(column.getName(), column); } return new DefaultTableMetadata( keyspaceId, tableId, null, false, true, partitionKeyBuilder.build(), clusteringColumnsBuilder.build(), allColumnsBuilder.build(), Collections.emptyMap(), Collections.emptyMap()); }
Source:
<code><START> public static List<Event> getUpcomingEvents(Context context) { <END> ContentResolver cr = context.getContentResolver(); Calendar now = Calendar.getInstance(); now.setTime(new Date()); Cursor evtCur = cr.query( CalendarContract.Events.CONTENT_URI, EVENT_PROJECTION, CalendarContract.Events.DTSTART + ">" + now.getTimeInMillis() , null, CalendarContract.Events.DTSTART + " ASC LIMIT 50"); List<Event> events = new ArrayList<Event>(); evtCur.moveToFirst(); for (int i = 0; i < evtCur.getCount(); i++) { events.add(eventFromCusrsor(context, evtCur)); evtCur.moveToNext(); } evtCur.close(); return events; }</code><technical_language>limit (50) a parameter, this useful for</technical_language>

Target:
public static List<Event> getUpcomingEvents(Context context) { return getUpcomingEvents(context, 50); }
Source:
<code>private void printIndented(int indent, String format, String... arguments) { if (indent == 0) { stdout.format(format + "%n", (Object[]) arguments); } else { String f = "%" + indent + "s" + format + "%n"; String[] newArgs = new String[arguments.length + 1]; <START> newArgs[0] = " "; int i = 1; <END> for (String arg: arguments ) { newArgs[i] = arg; i++; } stdout.format(f, newArgs); } }</code><technical_language>Please avoir multiple statements line, writing JavaScript ;)</technical_language>

Target:
private void printIndented(int indent, String format, String... arguments) { if (indent == 0) { stdout.format(format + "%n", (Object[]) arguments); } else { String[] newArgs = new String[arguments.length + 1]; newArgs[0] = " "; System.arraycopy(arguments, 0, newArgs, 1, arguments.length); String f = "%" + indent + "s" + format + "%n"; stdout.format(f, newArgs); } }
Source:
<code>public static boolean evaluateNoexceptSpecifier(ICPPEvaluation noexceptSpecifier) { if (noexceptSpecifier == null) return false; else { IntegralValue v = (IntegralValue) noexceptSpecifier.getValue(); <START> return v.numberValue().longValue() == 1; <END> } }</code><technical_language>numberValue() needs a null check</technical_language>

Target:
public static boolean evaluateNoexceptSpecifier(ICPPEvaluation noexceptSpecifier) { if (noexceptSpecifier != null) { IntegralValue v = (IntegralValue) noexceptSpecifier.getValue(); if (v.numberValue() != null) return v.numberValue().longValue() == 1; } return false; }
Source:
<code>private <R> R accessInner(ICorfuSMRAccess<R, T> accessMethod, Object[] conflictObject, boolean isMetricsEnabled) { if (TransactionalContext.isInTransaction()) { try { return TransactionalContext.getCurrentContext() .access(this, accessMethod, conflictObject); } catch (Exception e) { log.error("Access[{}]", this, e); this.abortTransaction(e); } } for (int x = 0; x < rt.getParameters().getTrimRetry(); x++) { final long timestamp = rt.getSequencerView() <START> .query(getStreamID()).getStreamTails().get(0); <END> log.debug("Access[{}] conflictObj={} version={}", this, conflictObject, timestamp); try { return underlyingObject.access(o -> o.getVersionUnsafe() >= timestamp && !o.isOptimisticallyModifiedUnsafe(), o -> o.syncObjectUnsafe(timestamp), o -> accessMethod.access(o)); } catch (TrimmedException te) { log.warn("accessInner: Encountered a trim exception while accessing version on attempt {}", timestamp, x); underlyingObject.update(o -> { o.resetUnsafe(); return null; }); } } throw new TrimmedException(); }</code><technical_language>hide this implementation in SequencerView -- leaking list "de-referencing logic" clean</technical_language>

Target:
private <R> R accessInner(ICorfuSMRAccess<R, T> accessMethod, Object[] conflictObject, boolean isMetricsEnabled) { if (TransactionalContext.isInTransaction()) { try { return TransactionalContext.getCurrentContext() .access(this, accessMethod, conflictObject); } catch (Exception e) { log.error("Access[{}]", this, e); this.abortTransaction(e); } } for (int x = 0; x < rt.getParameters().getTrimRetry(); x++) { final long timestamp = rt.getSequencerView() .query(getStreamID()); log.debug("Access[{}] conflictObj={} version={}", this, conflictObject, timestamp); try { return underlyingObject.access(o -> o.getVersionUnsafe() >= timestamp && !o.isOptimisticallyModifiedUnsafe(), o -> o.syncObjectUnsafe(timestamp), o -> accessMethod.access(o)); } catch (TrimmedException te) { log.warn("accessInner: Encountered a trim exception while accessing version on attempt {}", timestamp, x); underlyingObject.update(o -> { o.resetUnsafe(); return null; }); } } throw new TrimmedException(); }
Source:
<code>void testInsertEntry() throws SQLException { <START> dbmsProcessor.setupSharedDatabase(); <END> BibEntry expectedEntry = getBibEntryExample(); dbmsProcessor.insertEntry(expectedEntry); BibEntry emptyEntry = new BibEntry(); emptyEntry.getSharedBibEntryData().setSharedID(1); dbmsProcessor.insertEntry(emptyEntry); Map<String, String> actualFieldMap = new HashMap<>(); try (ResultSet entryResultSet = selectFrom("ENTRY", dbmsConnection, dbmsProcessor)) { assertTrue(entryResultSet.next()); assertEquals(1, entryResultSet.getInt("SHARED_ID")); assertEquals("inproceedings", entryResultSet.getString("TYPE")); assertEquals(1, entryResultSet.getInt("VERSION")); assertFalse(entryResultSet.next()); try (ResultSet fieldResultSet = selectFrom("FIELD", dbmsConnection, dbmsProcessor)) { while (fieldResultSet.next()) { actualFieldMap.put(fieldResultSet.getString("NAME"), fieldResultSet.getString("VALUE")); } } } Map<String, String> expectedFieldMap = expectedEntry.getFieldMap().entrySet().stream().collect(Collectors.toMap((entry) -> entry.getKey().getName(), Map.Entry::getValue)); assertEquals(expectedFieldMap, actualFieldMap); }</code><technical_language>appears test calls setupSharedDatabase this method moved setup method</technical_language>

Target:
void testInsertEntry() throws SQLException { BibEntry expectedEntry = getBibEntryExample(); dbmsProcessor.insertEntry(expectedEntry); BibEntry emptyEntry = new BibEntry(); emptyEntry.getSharedBibEntryData().setSharedID(1); dbmsProcessor.insertEntry(emptyEntry); Map<String, String> actualFieldMap = new HashMap<>(); try (ResultSet entryResultSet = selectFrom("ENTRY", dbmsConnection, dbmsProcessor)) { assertTrue(entryResultSet.next()); assertEquals(1, entryResultSet.getInt("SHARED_ID")); assertEquals("inproceedings", entryResultSet.getString("TYPE")); assertEquals(1, entryResultSet.getInt("VERSION")); assertFalse(entryResultSet.next()); try (ResultSet fieldResultSet = selectFrom("FIELD", dbmsConnection, dbmsProcessor)) { while (fieldResultSet.next()) { actualFieldMap.put(fieldResultSet.getString("NAME"), fieldResultSet.getString("VALUE")); } } } Map<String, String> expectedFieldMap = expectedEntry.getFieldMap().entrySet().stream().collect(Collectors.toMap((entry) -> entry.getKey().getName(), Map.Entry::getValue)); assertEquals(expectedFieldMap, actualFieldMap); }
Source:
<code>Set<SubscriptionName> decode(byte[] data) { MessageHeaderDecoder header = new MessageHeaderDecoder(); AssignmentsDecoder body = new AssignmentsDecoder(); UnsafeBuffer buffer = new UnsafeBuffer(data); header.wrap(buffer, 0); if (header.templateId() != AssignmentsDecoder.TEMPLATE_ID) { <START> throw new IllegalStateException(String.format("AssignmentsDecoder TEMPLATE_ID=%d does not match encoded TEMPLATE_ID=%d", <END> AssignmentsDecoder.TEMPLATE_ID, header.templateId())); } body.wrap(buffer, header.encodedLength(), header.blockLength(), header.version()); Set<SubscriptionName> subscriptions = new HashSet<>(); for (AssignmentsDecoder.SubscriptionsDecoder subscriptionDecoder : body.subscriptions()) { long id = subscriptionDecoder.id(); subscriptionIds.getSubscriptionId(id) .map(SubscriptionId::getSubscriptionName) .ifPresent(subscriptions::add); } return subscriptions; }</code><technical_language>Do handle/log this exception</technical_language>

Target:
Set<SubscriptionName> decode(byte[] data) { MessageHeaderDecoder header = new MessageHeaderDecoder(); AssignmentsDecoder body = new AssignmentsDecoder(); UnsafeBuffer buffer = new UnsafeBuffer(data); header.wrap(buffer, 0); if (header.schemaId() != AssignmentsDecoder.SCHEMA_ID || header.templateId() != AssignmentsDecoder.TEMPLATE_ID) { logger.warn("Unable to decode assignments, schema or template id mismatch. " + "Required by decoder: [schema id={}, template id={}], " + "encoded in payload: [schema id={}, template id={}]", AssignmentsDecoder.SCHEMA_ID, AssignmentsDecoder.TEMPLATE_ID, header.schemaId(), header.templateId()); return Collections.emptySet(); } body.wrap(buffer, header.encodedLength(), header.blockLength(), header.version()); Set<SubscriptionName> subscriptions = new HashSet<>(); for (AssignmentsDecoder.SubscriptionsDecoder subscriptionDecoder : body.subscriptions()) { long id = subscriptionDecoder.id(); subscriptionIds.getSubscriptionId(id) .map(SubscriptionId::getSubscriptionName) .ifPresent(subscriptions::add); } return subscriptions; }
Source:
<code>private void setKernelEnablements(KernelGroupEnum group) { fAllActivateButton.setSelection(group == KernelGroupEnum.ALL); fTracepointsActivateButton.setSelection(group == KernelGroupEnum.TRACEPOINTS); fTracepointsViewer.getTree().setEnabled(group == KernelGroupEnum.TRACEPOINTS); fSpecificEventActivateButton.setSelection(group == KernelGroupEnum.SPECIFICEVENT); fSpecificEventText.setEnabled(group == <START> KernelGroupEnum.SPECIFICEVENT); <END> fSysCallsActivateButton.setSelection(group == KernelGroupEnum.SYSCALLS); fProbeActivateButton.setSelection(group == KernelGroupEnum.PROBE); fProbeEventNameText.setEnabled(group == KernelGroupEnum.PROBE); fProbeText.setEnabled(group == KernelGroupEnum.PROBE); fFunctionActivateButton.setSelection(group == KernelGroupEnum.FUNCTION); fFunctionEventNameText.setEnabled(group == KernelGroupEnum.FUNCTION); fFunctionText.setEnabled(group == KernelGroupEnum.FUNCTION); }</code><technical_language>TRACEPOINTS</technical_language>

Target:
private void setKernelEnablements(KernelGroupEnum group) { fAllActivateButton.setSelection(group == KernelGroupEnum.ALL); fTracepointsActivateButton.setSelection(group == KernelGroupEnum.TRACEPOINTS); fTracepointsViewer.getTree().setEnabled(group == KernelGroupEnum.TRACEPOINTS); fSpecificEventText.setEnabled(group == KernelGroupEnum.TRACEPOINTS); fSysCallsActivateButton.setSelection(group == KernelGroupEnum.SYSCALLS); fProbeActivateButton.setSelection(group == KernelGroupEnum.PROBE); fProbeEventNameText.setEnabled(group == KernelGroupEnum.PROBE); fProbeText.setEnabled(group == KernelGroupEnum.PROBE); fFunctionActivateButton.setSelection(group == KernelGroupEnum.FUNCTION); fFunctionEventNameText.setEnabled(group == KernelGroupEnum.FUNCTION); fFunctionText.setEnabled(group == KernelGroupEnum.FUNCTION); }
Source:
<code>public void onDeleteSelectedColumns() { assertNotReadOnly(); final Set<Integer> selectedColumnIndexes = getSelectedColumnIndexes(); final Set<BaseColumn> columnsToDelete = new HashSet<>(); for ( int selectedColumnIndex : selectedColumnIndexes ) { final int columnIndex = findUiColumnIndex( selectedColumnIndex ); final BaseColumn column = model.getExpandedColumns().get( columnIndex ); if ( column instanceof AttributeCol52 ) { columnsToDelete.add( column ); } else if ( column instanceof MetadataCol52 ) { columnsToDelete.add( column ); } else if ( column instanceof ConditionCol52 ) { columnsToDelete.add( column ); } else if ( column instanceof ActionCol52 ) { columnsToDelete.add( column ); <START> } <END> } for ( BaseColumn columnToDelete : columnsToDelete ) { if ( columnToDelete instanceof AttributeCol52 ) { deleteColumn( (AttributeCol52) columnToDelete ); } else if ( columnToDelete instanceof MetadataCol52 ) { deleteColumn( (MetadataCol52) columnToDelete ); } else if ( columnToDelete instanceof ConditionCol52 ) { deleteColumn( (ConditionCol52) columnToDelete ); } else if ( columnToDelete instanceof ActionCol52 ) { deleteColumn( (ActionCol52) columnToDelete ); } } }</code><technical_language>This block of else ifs nicer if (with conditions), code for branch is same</technical_language>

Target:
public void onDeleteSelectedColumns() { assertNotReadOnly(); final Set<Integer> selectedColumnIndexes = getSelectedColumnIndexes(); final Set<BaseColumn> columnsToDelete = new HashSet<>(); for ( int selectedColumnIndex : selectedColumnIndexes ) { final int columnIndex = findUiColumnIndex( selectedColumnIndex ); final BaseColumn column = model.getExpandedColumns().get( columnIndex ); if ( !( column instanceof RowNumberCol52 || column instanceof DescriptionCol52 ) ) { columnsToDelete.add( column ); } } for ( BaseColumn columnToDelete : columnsToDelete ) { if ( columnToDelete instanceof AttributeCol52 ) { deleteColumn( (AttributeCol52) columnToDelete ); } else if ( columnToDelete instanceof MetadataCol52 ) { deleteColumn( (MetadataCol52) columnToDelete ); } else if ( columnToDelete instanceof ConditionCol52 ) { deleteColumn( (ConditionCol52) columnToDelete ); } else if ( columnToDelete instanceof ActionCol52 ) { deleteColumn( (ActionCol52) columnToDelete ); } } }
Source:
<code>public void close() { <START> Config.getInstance().soundManager.stopAllPlaylists(); <END> primaryStage.close(); }</code><technical_language>change this Platform.exit(); System.exit(0); if possible, if dosent work, merge this</technical_language>

Target:
public void close() { Platform.exit(); System.exit(0); }
Source:
<code>private String countHashSum(VirtualFile virtualFile, HashFunction hashFunction) throws ServerException { final PathLockFactory.PathLock lock = pathLockFactory.getLock(virtualFile.getVirtualFilePath(), false).acquire(LOCK_FILE_TIMEOUT); try { <START> return ByteSource.concat().hash(hashFunction).toString(); <END> } catch (IOException e) { throw new ServerException(e); } finally { lock.release(); } }</code><technical_language>I understand calculate a checksum if content of virtual file</technical_language>

Target:
private String countHashSum(VirtualFile virtualFile, HashFunction hashFunction) throws ServerException { final PathLockFactory.PathLock lock = pathLockFactory.getLock(virtualFile.getVirtualFilePath(), false).acquire(LOCK_FILE_TIMEOUT); try (InputStream contentStream = virtualFile.getContent().getStream()) { return ByteSource.wrap(ByteStreams.toByteArray(contentStream)).hash(hashFunction).toString(); } catch (ForbiddenException e) { throw new ServerException(e.getServiceError()); } catch (IOException e) { throw new ServerException(e); } finally { lock.release(); } }
Source:
<code>public void test_none_duplicate_responses() throws InterruptedException{ Microservices gateway = Microservices.builder() .build(); Microservices node = Microservices.builder() .seeds(gateway.cluster().address()) .services(new SimpleGenerator()) .build(); GeneratorService service = gateway.proxy().api(GeneratorService.class).create(); <START> List<String> results = new ArrayList<String>(); <END> service.generate().subscribe(r ->results.add("s1: " + r.data)); service.generate().subscribe(r ->results.add("s2: " + r.data)); TimeUnit.SECONDS.sleep(5); assertEquals(results.get(0),"s1: 1 => 1"); assertEquals(results.get(1),"s2: 2 => 1"); assertEquals(results.get(2),"s1: 1 => 2"); assertEquals(results.get(3),"s2: 2 => 2"); assertEquals(results.get(4),"s1: 1 => 3"); assertEquals(results.get(5),"s2: 2 => 3"); }</code><technical_language>This a concurrent write list. please Collections.synchronizedList(new ArrayList<String>());</technical_language>

Target:
public void test_none_duplicate_responses() throws InterruptedException { Microservices gateway = Microservices.builder() .build(); Microservices node = Microservices.builder() .seeds(gateway.cluster().address()) .services(new SimpleGenerator()) .build(); GeneratorService service = gateway.proxy().api(GeneratorService.class).create(); Map<String, String> results = new ConcurrentHashMap<>(); CountDownLatch latch = new CountDownLatch(7); Subscription subscription1 = service.generate().serialize().subscribe(r -> { results.put(r.data, "s1"); latch.countDown(); }); Subscription subscription2 = service.generate().serialize().subscribe(r -> { latch.countDown(); results.put(r.data, "s2"); }); latch.await(2, TimeUnit.SECONDS); assertEquals("s1", results.get("1 => 1")); assertEquals("s2", results.get("2 => 1")); assertEquals("s1", results.get("1 => 2")); assertEquals("s2", results.get("2 => 2")); assertEquals("s1", results.get("1 => 3")); assertEquals("s2", results.get("2 => 3")); subscription1.unsubscribe(); subscription2.unsubscribe(); node.shutdown(); gateway.shutdown(); }
Source:
<code><START> public TraceContext(NodeBuilder rootNode, long startTime, TraceReporter reporter) { <END> this.rootNode = rootNode; trace = new Trace(); trace.setId(UUID.randomUUID().toString()); trace.setStartTime(startTime); rootNode.setNodePath(String.format("%s:0", trace.getId())); this.reporter = reporter; }</code><technical_language>units</technical_language>

Target:
public TraceContext(NodeBuilder rootNode, long startTime, TraceReporter reporter) { this.rootNode = rootNode; this.reporter = reporter; trace = new Trace(); trace.setId(UUID.randomUUID().toString()); trace.setStartTime(startTime); rootNode.setNodePath(String.format("%s:0", trace.getId())); }
Source:
<code>public Reporter<Span> reporter(ReporterMetrics reporterMetrics, ZipkinProperties zipkin, @Qualifier(SENDER_BEAN_NAME) Sender sender) { AsyncReporter<Span> asyncReporter = AsyncReporter.builder(sender) .queuedMaxSpans(1000) .messageTimeout(zipkin.getMessageTimeout(), TimeUnit.SECONDS) .metrics(reporterMetrics).build(zipkin.getEncoder()); CheckResult checkResult = checkResult(asyncReporter); if (log.isDebugEnabled()) { <START> log.debug("Check result of the async reporter is [" + checkResult + "]"); <END> } return asyncReporter; }</code><technical_language>consider adding toString of reporter instead of "async reporter"</technical_language>

Target:
public Reporter<Span> reporter(ReporterMetrics reporterMetrics, ZipkinProperties zipkin, @Qualifier(SENDER_BEAN_NAME) Sender sender) { AsyncReporter<Span> asyncReporter = AsyncReporter.builder(sender) .queuedMaxSpans(1000) .messageTimeout(zipkin.getMessageTimeout(), TimeUnit.SECONDS) .metrics(reporterMetrics).build(zipkin.getEncoder()); CheckResult checkResult = checkResult(asyncReporter); logCheckResult(asyncReporter, checkResult); return asyncReporter; }
Source:
<code>public HiveOrcLocalMemoryContext(LocalMemoryContext delegate) { <START> this.delegate = delegate; <END> }</code><technical_language>requireNonNull</technical_language>

Target:
HiveOrcLocalMemoryContext(LocalMemoryContext delegate) { this.delegate = requireNonNull(delegate, "delegate is null"); }
Source:
<code>public void testTemplateOverridingStoreByValue() throws Exception { cacheManager = cachingProvider.getCacheManager( getClass().getResource("/org/ehcache/docs/ehcache-jsr107-template-override.xml").toURI(), getClass().getClassLoader()); MutableConfiguration<Long, String> mutableConfiguration = new MutableConfiguration<Long, String>(); mutableConfiguration.setTypes(Long.class, String.class); Cache<Long, String> myCache = null; myCache = cacheManager.createCache("anyCache", mutableConfiguration); myCache.put(1L, "foo"); assertNotSame("foo", myCache.get(1L)); myCache = cacheManager.createCache("byRefCache", mutableConfiguration); myCache.put(1L, "foo"); <START> assertSame("foo", myCache.get(1L)); <END> myCache = cacheManager.createCache("weirdCache", mutableConfiguration); myCache.put(1L, "foo"); assertNotSame("foo", myCache.get(1L)); }</code><technical_language>assertion pass not: assertThat(myCache.getConfiguration(Configuration.class).isStoreByValue(), is(false));</technical_language>

Target:
public void testTemplateOverridingStoreByValue() throws Exception { cacheManager = cachingProvider.getCacheManager( getClass().getResource("/org/ehcache/docs/ehcache-jsr107-template-override.xml").toURI(), getClass().getClassLoader()); MutableConfiguration<Long, String> mutableConfiguration = new MutableConfiguration<Long, String>(); mutableConfiguration.setTypes(Long.class, String.class); Cache<Long, String> myCache = null; myCache = cacheManager.createCache("anyCache", mutableConfiguration); myCache.put(1L, "foo"); assertNotSame("foo", myCache.get(1L)); assertTrue(myCache.getConfiguration(Configuration.class).isStoreByValue()); myCache = cacheManager.createCache("byRefCache", mutableConfiguration); myCache.put(1L, "foo"); assertSame("foo", myCache.get(1L)); assertFalse(myCache.getConfiguration(Configuration.class).isStoreByValue()); myCache = cacheManager.createCache("weirdCache1", mutableConfiguration); myCache.put(1L, "foo"); assertNotSame("foo", myCache.get(1L)); assertTrue(myCache.getConfiguration(Configuration.class).isStoreByValue()); myCache = cacheManager.createCache("weirdCache2", mutableConfiguration); myCache.put(1L, "foo"); assertSame("foo", myCache.get(1L)); assertFalse(myCache.getConfiguration(Configuration.class).isStoreByValue()); }
Source:
<code>public GitUser getUser() { String name = null; String email = null; try { Map<String, String> preferences = requestFactory.fromUrl(preferencessUrl) .useGetMethod() .addQueryParam("filter", "git.committer.\\w+") .request() .asProperties(); name = preferences.get("git.committer.name"); email = preferences.get("git.committer.email"); <START> } catch (ServerException | IOException | <END> ForbiddenException | BadRequestException | ConflictException | NotFoundException | UnauthorizedException e) { LOG.error(e.getLocalizedMessage(), e); } GitUser gitUser = newDto(GitUser.class); if (!isNullOrEmpty(name)) { gitUser.setName(name); } if (!isNullOrEmpty(email)) { gitUser.setEmail(email); } return gitUser; }</code><technical_language>catch ApiException | IOException</technical_language>

Target:
public GitUser getUser() { String name = null; String email = null; try { Map<String, String> preferences = requestFactory.fromUrl(apiUrl + "/preferences") .useGetMethod() .addQueryParam("filter", "git.committer.\\w+") .request() .asProperties(); name = preferences.get("git.committer.name"); email = preferences.get("git.committer.email"); } catch (ApiException | IOException e) { LOG.error(e.getLocalizedMessage(), e); } GitUser gitUser = newDto(GitUser.class); if (!isNullOrEmpty(name)) { gitUser.setName(name); } if (!isNullOrEmpty(email)) { gitUser.setEmail(email); } return gitUser; }
Source:
<code>public void resultsAreReadable() throws IOException { List<ReadRowsResponse> responses = generateReadRowsResponses("rowKey-%s", 3); <START> List<Row> rows = TO_ROWS_LIST_FUNCTION.apply(responses); <END> checkKeysAreEqual(responses, rows); }</code><technical_language>is fine. testing Function<List<ReadRowsResponse>, List<Row>></technical_language>

Target:
public void resultsAreReadable() throws IOException { List<ReadRowsResponse> responses = generateReadRowsResponses("rowKey-%s", 3); List<Row> rows = new ArrayList<>(); Iterator<ReadRowsResponse> iterator = responses.iterator(); while (iterator.hasNext()) { rows.add(RowMerger.readNextRow(iterator)); } Assert.assertEquals(responses.size(), rows.size()); for (int i = 0; i < responses.size(); i++) { Assert.assertEquals(responses.get(i).getRowKey(), rows.get(i).getKey()); } }
Source:
<code>public void testEmpty2DQuery() throws IndexOutOfBoundsException, TimeRangeException, StateSystemDisposedException { ITmfStateSystem ss = fStateSystem; assertNotNull(ss); Collection<Long> times = Collections.singleton(Long.valueOf(77)); Iterable<ITmfStateInterval> iterable = ss.query2D(Collections.emptyList(), times); assertNotNull(iterable); <START> <END> }</code><technical_language>newline for assertTrue(Iterables.isEmpty)</technical_language>

Target:
public void testEmpty2DQuery() throws IndexOutOfBoundsException, TimeRangeException, StateSystemDisposedException { ITmfStateSystem ss = fStateSystem; assertNotNull(ss); Iterable<ITmfStateInterval> iterable = ss.query2D(Collections.emptyList(), Collections.singleton(77L)); assertNotNull(iterable); assertTrue(Iterables.isEmpty(iterable)); iterable = ss.query2D(Collections.singleton(0), Collections.emptyList()); assertNotNull(iterable); assertTrue(Iterables.isEmpty(iterable)); iterable = ss.query2D(Collections.emptyList(), 77L, 78L); assertNotNull(iterable); assertTrue(Iterables.isEmpty(iterable)); }
Source:
<code>public void shouldNotifyEventWhenCreateAnnotation() { captureAndVerifyAnnotationEventNotification(() -> { Annotation createdAnnotation = createAnnotationAndAddSubscription("CommentAdded", "Creation"); return session.getDocument(new IdRef(createdAnnotation.getId())); <START> <END> }, COMMENT_ADDED, DOCUMENT_CREATED, 2); }</code><technical_language>Useless blank line</technical_language>

Target:
public void shouldNotifyEventWhenCreateAnnotation() { captureAndVerifyAnnotationEventNotification(() -> { Annotation createdAnnotation = createAnnotationAndAddSubscription("CommentAdded", "Creation"); return session.getDocument(new IdRef(createdAnnotation.getId())); }, COMMENT_ADDED, DOCUMENT_CREATED); }
Source:
<code>public CacheGroupMetricsImpl(CacheGroupContext ctx) { this.ctx = ctx; MetricRegistry mreg = ctx.shared().kernalContext().metric().registry(metricGroupName()); mreg.register("Caches", this::getCaches, List.class, null); storageSize = mreg.register("StorageSize", <START> () -> database().forGroupPageStores(ctx, PageStore::size), <END> "Storage space allocated for group, in bytes."); sparseStorageSize = mreg.register("SparseStorageSize", () -> database().forGroupPageStores(ctx, PageStore::getSparseSize), "Storage space allocated for group adjusted for possible sparsity, in bytes."); idxBuildCntPartitionsLeft = mreg.longMetric("IndexBuildCountPartitionsLeft", "Number of partitions need processed for finished indexes create or rebuilding."); DataRegion region = ctx.dataRegion(); if (region != null) { DataRegionMetricsImpl dataRegionMetrics = ctx.dataRegion().memoryMetrics(); grpPageAllocationTracker = dataRegionMetrics.getOrAllocateGroupPageAllocationTracker(ctx.cacheOrGroupName()); } else grpPageAllocationTracker = new LongAdderMetric("NO_OP", null); }</code><technical_language>ClassCastException if IgniteCacheDatabaseSharedManager instead of GridCacheDatabaseSharedManager private GridCacheDatabaseSharedManager database() { return (GridCacheDatabaseSharedManager)ctx.shared().database(); }</technical_language>

Target:
public CacheGroupMetricsImpl(CacheGroupContext ctx) { this.ctx = ctx; CacheConfiguration cacheCfg = ctx.config(); DataStorageConfiguration dsCfg = ctx.shared().kernalContext().config().getDataStorageConfiguration(); boolean persistentEnabled = CU.isPersistentCache(cacheCfg, dsCfg); MetricRegistry mreg = ctx.shared().kernalContext().metric().registry(metricGroupName()); mreg.register("Caches", this::getCaches, List.class, null); storageSize = mreg.register("StorageSize", () -> persistentEnabled ? database().forGroupPageStores(ctx, PageStore::size) : 0, "Storage space allocated for group, in bytes."); sparseStorageSize = mreg.register("SparseStorageSize", () -> persistentEnabled ? database().forGroupPageStores(ctx, PageStore::getSparseSize) : 0, "Storage space allocated for group adjusted for possible sparsity, in bytes."); idxBuildCntPartitionsLeft = mreg.longMetric("IndexBuildCountPartitionsLeft", "Number of partitions need processed for finished indexes create or rebuilding."); DataRegion region = ctx.dataRegion(); if (region != null) { DataRegionMetricsImpl dataRegionMetrics = ctx.dataRegion().memoryMetrics(); grpPageAllocationTracker = dataRegionMetrics.getOrAllocateGroupPageAllocationTracker(ctx.cacheOrGroupName()); } else grpPageAllocationTracker = new LongAdderMetric("NO_OP", null); }
Source:
<code>public DefaultSocks5CommandRequest( Socks5CommandType type, Socks5AddressType dstAddrType, String dstAddr, int dstPort) { ObjectUtil.checkNotNull(dstAddrType, "dstAddrType"); ObjectUtil.checkNotNull(dstAddr, "dstAddr"); if (dstAddrType == Socks5AddressType.IPv4) { if (!NetUtil.isValidIpV4Address(dstAddr)) { throw new IllegalArgumentException("dstAddr: " + dstAddr + " (expected: a valid IPv4 address)"); } } else if (dstAddrType == Socks5AddressType.DOMAIN) { dstAddr = IDN.toASCII(dstAddr); if (dstAddr.length() > 255) { throw new IllegalArgumentException("dstAddr: " + dstAddr + " (expected: less than 256 chars)"); } } else if (dstAddrType == Socks5AddressType.IPv6) { if (!NetUtil.isValidIpV6Address(dstAddr)) { throw new IllegalArgumentException("dstAddr: " + dstAddr + " (expected: a valid IPv6 address"); } } if (dstPort < 0 || dstPort > 65535) { throw new IllegalArgumentException("dstPort: " + dstPort + " (expected: 0~65535)"); } <START> this.type = ObjectUtil.checkNotNull(type, "type"); <END> this.dstAddrType = dstAddrType; this.dstAddr = dstAddr; this.dstPort = dstPort; }</code><technical_language>lets move check assignment other stuff behaviour before</technical_language>

Target:
public DefaultSocks5CommandRequest( Socks5CommandType type, Socks5AddressType dstAddrType, String dstAddr, int dstPort) { this.type = ObjectUtil.checkNotNull(type, "type"); ObjectUtil.checkNotNull(dstAddrType, "dstAddrType"); ObjectUtil.checkNotNull(dstAddr, "dstAddr"); if (dstAddrType == Socks5AddressType.IPv4) { if (!NetUtil.isValidIpV4Address(dstAddr)) { throw new IllegalArgumentException("dstAddr: " + dstAddr + " (expected: a valid IPv4 address)"); } } else if (dstAddrType == Socks5AddressType.DOMAIN) { dstAddr = IDN.toASCII(dstAddr); if (dstAddr.length() > 255) { throw new IllegalArgumentException("dstAddr: " + dstAddr + " (expected: less than 256 chars)"); } } else if (dstAddrType == Socks5AddressType.IPv6) { if (!NetUtil.isValidIpV6Address(dstAddr)) { throw new IllegalArgumentException("dstAddr: " + dstAddr + " (expected: a valid IPv6 address"); } } if (dstPort < 0 || dstPort > 65535) { throw new IllegalArgumentException("dstPort: " + dstPort + " (expected: 0~65535)"); } this.dstAddrType = dstAddrType; this.dstAddr = dstAddr; this.dstPort = dstPort; }
Source:
<code>public Lifecycle initLifecycle(Injector injector) { try { final Lifecycle lifecycle = injector.getInstance(Lifecycle.class); final StartupLoggingConfig startupLoggingConfig = injector.getInstance(StartupLoggingConfig.class); Long directSizeBytes = null; try { directSizeBytes = JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes(); } catch (UnsupportedOperationException ignore) { } log.info( "Starting up with processors[%,d], memory[%,d], maxMemory[%,d]%s.", JvmUtils.getRuntimeInfo().getAvailableProcessors(), JvmUtils.getRuntimeInfo().getTotalHeapSizeBytes(), JvmUtils.getRuntimeInfo().getMaxHeapSizeBytes(), <START> directSizeBytes != null ? String.format(", directMemory[%,d]", directSizeBytes) : "" <END> ); if (startupLoggingConfig.isLogProperties()) { final Set<String> maskProperties = Sets.newHashSet(startupLoggingConfig.getMaskProperties()); final Properties props = injector.getInstance(Properties.class); for (String propertyName : Ordering.natural().sortedCopy(props.stringPropertyNames())) { String property = props.getProperty(propertyName); for (String masked : maskProperties) { if (propertyName.contains(masked)) { property = "<masked>"; break; } } log.info("* %s: %s", propertyName, property); } } try { lifecycle.start(); } catch (Throwable t) { log.error(t, "Error when starting up. Failing."); System.exit(1); } return lifecycle; } catch (Exception e) { throw new RuntimeException(e); } }</code><technical_language>Ah, this StringUtils.format instead of String.format</technical_language>

Target:
public Lifecycle initLifecycle(Injector injector) { try { final Lifecycle lifecycle = injector.getInstance(Lifecycle.class); final StartupLoggingConfig startupLoggingConfig = injector.getInstance(StartupLoggingConfig.class); Long directSizeBytes = null; try { directSizeBytes = JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes(); } catch (UnsupportedOperationException ignore) { } log.info( "Starting up with processors[%,d], memory[%,d], maxMemory[%,d]%s.", JvmUtils.getRuntimeInfo().getAvailableProcessors(), JvmUtils.getRuntimeInfo().getTotalHeapSizeBytes(), JvmUtils.getRuntimeInfo().getMaxHeapSizeBytes(), directSizeBytes != null ? StringUtils.format(", directMemory[%,d]", directSizeBytes) : "" ); if (startupLoggingConfig.isLogProperties()) { final Set<String> maskProperties = Sets.newHashSet(startupLoggingConfig.getMaskProperties()); final Properties props = injector.getInstance(Properties.class); for (String propertyName : Ordering.natural().sortedCopy(props.stringPropertyNames())) { String property = props.getProperty(propertyName); for (String masked : maskProperties) { if (propertyName.contains(masked)) { property = "<masked>"; break; } } log.info("* %s: %s", propertyName, property); } } try { lifecycle.start(); } catch (Throwable t) { log.error(t, "Error when starting up. Failing."); System.exit(1); } return lifecycle; } catch (Exception e) { throw new RuntimeException(e); } }
Source:
<code>public void setPreferredAgencies(String s) { if (!s.isEmpty()) { <START> preferredAgencies = new HashSet<>(); Collections.addAll( preferredAgencies, Arrays.stream(s.split(",")) .map(FeedScopedId::convertFromString) .toArray(FeedScopedId[]::new) ); <END> } }</code><technical_language>This is repeated times. I suggest making a static parse function in FeedScopedId</technical_language>

Target:
public void setPreferredAgencies(String s) { if (!s.isEmpty()) { preferredAgencies = FeedScopedId.parseListOfIds(s); } }
Source:
<code>private AccountGroup createGroup(ReviewDb db, String groupName, AccountGroup.UUID adminGroupUUID, String description) throws OrmException { <START> final AccountGroup.Id groupId = <END> new AccountGroup.Id(db.nextAccountGroupId()); final AccountGroup.NameKey nameKey = new AccountGroup.NameKey(groupName); final AccountGroup.UUID uuid = GroupUUID.make(groupName, serverUser); final AccountGroup group = new AccountGroup(nameKey, groupId, uuid); group.setOwnerGroupUUID(adminGroupUUID); group.setDescription(description); final AccountGroupName gn = new AccountGroupName(group); db.accountGroupNames().insert(Collections.singleton(gn)); db.accountGroups().insert(Collections.singleton(group)); return group; }</code><technical_language>need finals here</technical_language>

Target:
private AccountGroup createGroup(ReviewDb db, String groupName, AccountGroup.UUID adminGroupUUID, String description) throws OrmException { AccountGroup.Id groupId = new AccountGroup.Id(db.nextAccountGroupId()); AccountGroup.NameKey nameKey = new AccountGroup.NameKey(groupName); AccountGroup.UUID uuid = GroupUUID.make(groupName, serverUser); AccountGroup group = new AccountGroup(nameKey, groupId, uuid); group.setOwnerGroupUUID(adminGroupUUID); group.setDescription(description); AccountGroupName gn = new AccountGroupName(group); db.accountGroupNames().insert(Collections.singleton(gn)); db.accountGroups().insert(Collections.singleton(group)); return group; }
Source:
<code>protected double apply(double a) { <START> return Double.NaN; <END> }</code><technical_language>I for this code get called parser accept *3 /3 NaN right result. throw a new IllegalStateException() wrong</technical_language>

Target:
protected double apply(double a) { throw new IllegalStateException("Illegal unary input to " + getLabel() + "()"); }
Source:
<code>public Predicate<String> create(final String resourceGroup, final URI vaultUri, final boolean isRecovered) { checkNotNull(resourceGroup, "resourceGroup cannot be null"); checkNotNull(vaultUri, "vaultUri cannot be null"); return retry(new Predicate<String>() { @Override public boolean apply(final String name) { checkNotNull(name, "name cannot be null"); boolean result = false; KeyBundle key = api.getVaultApi(resourceGroup).getKey(vaultUri, name); if (key != null) { if (isRecovered) { result = true; } else { result = key.attributes().recoveryLevel().contains("Recoverable"); <START> } <END> } return result; } }, operationTimeout, initialPeriod, maxPeriod); }</code><technical_language>[minor style] Prefer inline conditionals</technical_language>

Target:
public Predicate<String> create(final String resourceGroup, final URI vaultUri, final boolean isRecovered) { checkNotNull(resourceGroup, "resourceGroup cannot be null"); checkNotNull(vaultUri, "vaultUri cannot be null"); return retry(new Predicate<String>() { @Override public boolean apply(final String name) { checkNotNull(name, "name cannot be null"); boolean result = false; KeyBundle key = api.getVaultApi(resourceGroup).getKey(vaultUri, name); return key != null ? (isRecovered ? true : key.attributes().recoveryLevel().contains("Recoverable")) : false; } }, operationTimeout, initialPeriod, maxPeriod); }
Source:
<code>protected void findAndResetInvoiceColumn(ResultRow row) { row.getColumns().stream() <START> .filter(col -> StringUtils.equalsAnyIgnoreCase(col.getPropertyName(), INVOICE_LINK_COLUMN_NAME)) <END> .findFirst() .ifPresent(col -> resetInvoiceColumn(row, col)); }</code><technical_language>Another spot "equalsIgnoreCase" instead of "equalsAnyIgnoreCase"</technical_language>

Target:
protected void findAndResetInvoiceColumn(ResultRow row) { row.getColumns().stream() .filter(col -> StringUtils.equalsIgnoreCase(col.getPropertyName(), INVOICE_LINK_COLUMN_NAME)) .findFirst() .ifPresent(col -> resetInvoiceColumn(row, col)); }
Source:
<code>public static SnippetType fromString(String type) { if (type == null) { throw new IllegalArgumentException(); } for (SnippetType snippetType : SnippetType.values()) { if (type.equalsIgnoreCase(snippetType.type)) { return snippetType; } } <START> throw new IllegalArgumentException(); <END> }</code><technical_language>throw CucumberException give user a clue wrong needs do</technical_language>

Target:
public static SnippetType fromString(String type) { if (type == null) { throw new CucumberException("Cannot pass null as SnippetType"); } for (SnippetType snippetType : SnippetType.values()) { if (type.equalsIgnoreCase(snippetType.type)) { return snippetType; } } throw new CucumberException(String.format("Unrecognized SnippetType %s", type)); }
Source:
<code>public void testIssue() throws Exception { int port = SocketUtil.getAvailablePort(); final WebSocketClient client = new WebSocketClient(new URI("ws://localhost:" + port)) { @Override public void onOpen(ServerHandshake handshakedata) { } @Override public void onMessage(String message) { } @Override public void onClose(int code, String reason, boolean remote) { } @Override public void onError(Exception ex) { } }; WebSocketServer server = new WebSocketServer(new InetSocketAddress(port)) { @Override public void onOpen(WebSocket conn, ClientHandshake handshake) { } @Override public void onClose(WebSocket conn, int code, String reason, boolean remote) { countCloseCallsDownLatch.countDown(); } @Override public void onMessage(WebSocket conn, String message) { } @Override public void onError(WebSocket conn, Exception ex) { } @Override public void onStart() { countServerDownLatch.countDown(); } }; new Thread(server).start(); countServerDownLatch.await(); client.connectBlocking(); <START> WebSocketImpl websocketImpl = (WebSocketImpl)new ArrayList<WebSocket>(server.getConnections()).get(0); <END> websocketImpl.setChannel(new ExceptionThrowingByteChannel()); server.broadcast("test"); countCloseCallsDownLatch.await(); }</code><technical_language>Is a reason for writing this: java WebSocketImpl websocketImpl = (WebSocketImpl) server.getConnections().get(0)</technical_language>

Target:
public void testIssue() throws Exception { int port = SocketUtil.getAvailablePort(); final WebSocketClient client = new WebSocketClient(new URI("ws://localhost:" + port)) { @Override public void onOpen(ServerHandshake handshakedata) { } @Override public void onMessage(String message) { } @Override public void onClose(int code, String reason, boolean remote) { } @Override public void onError(Exception ex) { } }; WebSocketServer server = new WebSocketServer(new InetSocketAddress(port)) { @Override public void onOpen(WebSocket conn, ClientHandshake handshake) { } @Override public void onClose(WebSocket conn, int code, String reason, boolean remote) { closeCalledLatch.countDown(); } @Override public void onMessage(WebSocket conn, String message) { } @Override public void onError(WebSocket conn, Exception ex) { } @Override public void onStart() { serverStartLatch.countDown(); } }; new Thread(server).start(); serverStartLatch.await(); client.connectBlocking(); WebSocketImpl websocketImpl = (WebSocketImpl)new ArrayList<WebSocket>(server.getConnections()).get(0); websocketImpl.setChannel(new ExceptionThrowingByteChannel()); server.broadcast("test"); closeCalledLatch.await(); }
Source:
<code>private boolean equalButForId(SCMSource a, SCMSource b) { if (!a.getClass().equals(b.getClass())) { return false; } boolean fallBack = false; Class<?> clazz = a.getClass(); REFLECTION: while (clazz != null && SCMSource.class.isAssignableFrom(clazz) && clazz != SCMSource.class) { <START> for (Field field : clazz.getDeclaredFields()) { <END> int modifiers = field.getModifiers(); if (Modifier.isStatic(modifiers)) { continue; } if (Modifier.isTransient(modifiers)) { continue; } if (!field.isAccessible()) { field.setAccessible(true); } if (!field.isAccessible()) { fallBack = true; break REFLECTION; } Object aField; Object bField; try { aField = field.get(a); bField = field.get(b); } catch (IllegalAccessException e) { fallBack = true; break REFLECTION; } if (aField == null && bField == null) { continue; } if (aField == null || bField == null) { return false; } if (aField.equals(bField)) { continue; } if (aField instanceof Boolean || aField instanceof Number || aField instanceof String) { return false; } if (SOURCE_ID_OMITTED_XSTREAM.toXML(aField).equals(SOURCE_ID_OMITTED_XSTREAM.toXML(bField))) { continue; } return false; } clazz = clazz.getSuperclass(); } return !fallBack || SOURCE_ID_OMITTED_XSTREAM.toXML(a).equals(SOURCE_ID_OMITTED_XSTREAM.toXML(b)); }</code><technical_language>Surely easier XStream form for SCMSource white out <id> </id></technical_language>

Target:
private boolean equalButForId(SCMSource a, SCMSource b) { if (!a.getClass().equals(b.getClass())) { return false; } return SOURCE_ID_OMITTED_XSTREAM.toXML(a).equals(SOURCE_ID_OMITTED_XSTREAM.toXML(b)); }