auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void destroyServerStore(String name) throws ClusterException { <START> unRegisterStoreStatistics(name); <END> final ServerStoreImpl store = stores.remove(name); if (store == null) { throw new InvalidStoreException("Clustered tier '" + name + "' does not exist"); } else { releaseDedicatedPool(name, store.getPageSource()); store.close(); } stateRepositoryManager.destroyStateRepository(name); }</code><technical_language>need EhcacheActiveEntity.destroy method triggers this well</technical_language>

Target:
public void destroyServerStore(String name) throws ClusterException { final ServerStoreImpl store = stores.remove(name); unRegisterStoreStatistics(store); if (store == null) { throw new InvalidStoreException("Clustered tier '" + name + "' does not exist"); } else { releaseDedicatedPool(name, store.getPageSource()); store.close(); } stateRepositoryManager.destroyStateRepository(name); }
Source:
<code>private synchronized void restoreFilterActivation() { SafeRunner.run(new NavigatorSafeRunnable() { @Override <START> public void run() throws Exception { <END> CommonFilterDescriptor[] visibleFilterDescriptors = CommonFilterDescriptorManager.getInstance().findVisibleFilters(contentService); for (CommonFilterDescriptor filterDescription : visibleFilterDescriptors) { if (!filterDescription.isVisibleInUi() && filterDescription.isActiveByDefault()) { activeFilters.add(filterDescription.getId()); } } IEclipsePreferences prefs = NavigatorContentService.getPreferencesRoot(); if (prefs.get(getFilterActivationPreferenceKey(), null) != null) { String activatedFiltersPreferenceValue = prefs.get( getFilterActivationPreferenceKey(), null); String[] activeFilterIds = activatedFiltersPreferenceValue.split(DELIM); for (int i = 0; i < activeFilterIds.length; i++) { activeFilters.add(activeFilterIds[i]); } } else { for (CommonFilterDescriptor filterDescription : visibleFilterDescriptors) { if (filterDescription.isVisibleInUi() && filterDescription.isActiveByDefault()) { activeFilters.add(filterDescription.getId()); } } } } }); }</code><technical_language>please remove useless whitespaces</technical_language>

Target:
private synchronized void restoreFilterActivation() { SafeRunner.run(new NavigatorSafeRunnable() { @Override public void run() throws Exception { CommonFilterDescriptor[] visibleFilterDescriptors = CommonFilterDescriptorManager.getInstance() .findVisibleFilters(contentService); for (CommonFilterDescriptor filterDescription : visibleFilterDescriptors) { if (!filterDescription.isVisibleInUi() && filterDescription.isActiveByDefault()) { activeFilters.add(filterDescription.getId()); } } IEclipsePreferences prefs = NavigatorContentService.getPreferencesRoot(); if (prefs.get(getFilterActivationPreferenceKey(), null) != null) { String activatedFiltersPreferenceValue = prefs.get( getFilterActivationPreferenceKey(), null); String[] activeFilterIds = activatedFiltersPreferenceValue.split(DELIM); for (String activeFilterId : activeFilterIds) { if (activeFilterId.isEmpty()) { continue; } activeFilters.add(activeFilterId); } } else { for (CommonFilterDescriptor filterDescription : visibleFilterDescriptors) { if (filterDescription.isVisibleInUi() && filterDescription.isActiveByDefault()) { activeFilters.add(filterDescription.getId()); } } } } }); }
Source:
<code>public Map<String, Object> getVariables() { Map<String, Object> result = new HashMap<>(); variables.values().stream() <START> .filter(v -> !(v instanceof CaseVariableInstance)) <END> .forEach(v -> result.put(v.name(), v.getReference().get())); return Collections.unmodifiableMap(result); }</code><technical_language>filtering out case variables</technical_language>

Target:
public Map<String, Object> getVariables() { Map<String, Object> result = new HashMap<>(); variables.values().stream() .filter(v -> !(v instanceof CaseVariableInstance)) .filter(v -> v.getReference().get() != null) .forEach(v -> result.put(v.name(), v.getReference().get())); return Collections.unmodifiableMap(result); }
Source:
<code>public void run() { try { final RecoveryInfo recoveryInfo = proxyToMaster.getRecoveringGroups(taskHostname); while (true) { if (recoveryInfo.getRecoveryGroupList().isEmpty()) { isRecoveryRunning.set(false); break; } else { final List<Future> futureList = new ArrayList<>(); for (final String recoveryGroup : recoveryInfo.getRecoveryGroupList()) { futureList.add(singleThreadedExecutorService.submit(new RecoveryRunner(recoveryGroup, checkpointManager))); } <START> futureList.get(futureList.size() - 1).get(); <END> } } } catch (final AvroRemoteException | InterruptedException | ExecutionException e) { e.printStackTrace(); } }</code><technical_language>a list of futures completed in order added</technical_language>

Target:
public void run() { try { while (true) { final RecoveryInfo recoveryInfo = proxyToMaster.getRecoveringGroups(taskHostname); LOG.log(Level.INFO, "Recovering groups: {0}", recoveryInfo.getRecoveryGroupList().toString()); if (recoveryInfo.getRecoveryGroupList().isEmpty()) { isRecoveryRunning.set(false); break; } else { final List<Future> futureList = new ArrayList<>(); for (final String recoveryGroup : recoveryInfo.getRecoveryGroupList()) { futureList.add(singleThreadedExecutorService.submit(new RecoveryRunner(recoveryGroup, checkpointManager))); } futureList.get(futureList.size() - 1).get(); } } } catch (final AvroRemoteException | InterruptedException | ExecutionException e) { e.printStackTrace(); } }
Source:
<code>public PlanNode optimize(PlanNode plan, Session session, Map<Symbol, Type> types, SymbolAllocator symbolAllocator, PlanNodeIdAllocator idAllocator) { <START> Optional<ApplyNode> applyNode = searchFrom(plan).where(ApplyNode.class::isInstance).findFirst(); <END> Optional<LateralJoinNode> lateralJoinNode = searchFrom(plan).where(LateralJoinNode.class::isInstance).findFirst(); if (applyNode.isPresent()) { throw error(applyNode.get().getCorrelation(), applyNode.get().getOriginSubquery()); } else if (lateralJoinNode.isPresent()) { throw error(lateralJoinNode.get().getCorrelation(), lateralJoinNode.get().getOriginSubquery()); } return plan; }</code><technical_language>inline ifPresent emphasize complex if logic in this method: searchFrom(plan).where(ApplyNode.class::isInstance) .findFirst() .ifPresent(applyNode -> { throw error(....); });</technical_language>

Target:
public PlanNode optimize(PlanNode plan, Session session, Map<Symbol, Type> types, SymbolAllocator symbolAllocator, PlanNodeIdAllocator idAllocator) { searchFrom(plan).where(ApplyNode.class::isInstance) .findFirst() .ifPresent(node -> { ApplyNode applyNode = (ApplyNode) node; throw error(applyNode.getCorrelation(), applyNode.getOriginSubquery()); }); searchFrom(plan).where(LateralJoinNode.class::isInstance) .findFirst() .ifPresent(node -> { LateralJoinNode lateralJoinNode = (LateralJoinNode) node; throw error(lateralJoinNode.getCorrelation(), lateralJoinNode.getOriginSubquery()); }); return plan; }
Source:
<code>static SMRRecord deserializeFromBuffer(ByteBuf b, CorfuRuntime rt) { SMRRecord record = new SMRRecord(); short methodLength = b.readShort(); byte[] methodBytes = new byte[methodLength]; b.readBytes(methodBytes, 0, methodLength); <START> record.SMRMethod = new String(methodBytes); <END> record.serializerType = Serializers.getSerializer(b.readByte()); byte numArguments = b.readByte(); Object[] arguments = new Object[numArguments]; for (byte arg = 0; arg < numArguments; arg++) { int len = b.readInt(); ByteBuf objBuf = b.slice(b.readerIndex(), len); arguments[arg] = record.serializerType.deserialize(objBuf, rt); b.skipBytes(len); } record.SMRArguments = arguments; return record; }</code><technical_language>Explicitly set Encoding</technical_language>

Target:
static SMRRecord deserializeFromBuffer(ByteBuf b, CorfuRuntime rt) { SMRRecord record = new SMRRecord(); short methodLength = b.readShort(); byte[] methodBytes = new byte[methodLength]; b.readBytes(methodBytes, 0, methodLength); record.SMRMethod = new String(methodBytes, DEFAULT_CHAR_SET); record.serializerType = Serializers.getSerializer(b.readByte()); byte numArguments = b.readByte(); Object[] arguments = new Object[numArguments]; for (byte arg = 0; arg < numArguments; arg++) { int len = b.readInt(); ByteBuf objBuf = b.slice(b.readerIndex(), len); arguments[arg] = record.serializerType.deserialize(objBuf, rt); b.skipBytes(len); } record.SMRArguments = arguments; return record; }
Source:
<code>protected void beforeInvoke() throws Exception { disposedOperators = false; LOG.debug("Initializing {}.", getName()); operatorChain = new OperatorChain<>(this, recordWriter); headOperator = operatorChain.getHeadOperator(); init(); if (canceled) { throw new CancelTaskException(); } LOG.debug("Invoking {}", getName()); actionExecutor.runThrowing(() -> { operatorChain.initializeStateAndOpenOperators(createStreamTaskStateInitializer()); ResultPartitionWriter[] writers = getEnvironment().getAllWriters(); if (writers != null) { for (ResultPartitionWriter writer : writers) { writer.initializeState(); } } }); <START> <END> isRunning = true; }</code><technical_language>close reader here? for InputChannels later</technical_language>

Target:
protected void beforeInvoke() throws Exception { disposedOperators = false; LOG.debug("Initializing {}.", getName()); operatorChain = new OperatorChain<>(this, recordWriter); headOperator = operatorChain.getHeadOperator(); init(); if (canceled) { throw new CancelTaskException(); } LOG.debug("Invoking {}", getName()); actionExecutor.runThrowing(() -> { operatorChain.initializeStateAndOpenOperators(createStreamTaskStateInitializer()); ResultPartitionWriter[] writers = getEnvironment().getAllWriters(); if (writers != null) { for (ResultPartitionWriter writer : writers) { writer.initializeState(ChannelStateReader.NO_OP); } } }); isRunning = true; }
Source:
<code>public Iterable<Directive> process(final XML xml) { final Directives directives = new Directives() .xpath("/talk/daemon[not(started)]") .strict(1); <START> final XML node = xml.node("/p/entry[@key='assets']/entry"); <END> if(StartsDaemon.IMAGE.equals(node.xpath(" StartsDaemon.deprecate(directives); } final Directives dirs = directives .add("started").set(new Time().iso()).up(); try { final String dir = this.run(xml); dirs.add("dir").set(dir); } catch (final IOException ex) { dirs.add("ended").set(new Time().iso()).up() .add("code").set("128").up() .add("tail").set(ex.getLocalizedMessage()); Logger.warn(this, "%[exception]s", ex); } return dirs; }</code><technical_language>@sebing this line compile</technical_language>

Target:
public Iterable<Directive> process(final XML xml) { final Directives dirs = new Directives() .xpath("/talk/daemon[not(started)]") .strict(1) .add("started").set(new Time().iso()).up(); try { final String dir = this.run(xml); dirs.add("dir").set(dir); } catch (final IOException ex) { dirs.add("ended").set(new Time().iso()).up() .add("code").set("128").up() .add("tail").set(ex.getLocalizedMessage()); Logger.warn(this, "%[exception]s", ex); } return dirs; }
Source:
<code>public OUT readRecord(OUT reuse, byte[] bytes, int offset, int numBytes) { <START> if(this.lineDelimiterIsLinebreak == true && bytes[offset + numBytes -1] == "\r".getBytes(Charsets.UTF_8)[0]) { <END> numBytes--; } if (parseRecord(parsedValues, bytes, offset, numBytes)) { for (int i = 0; i < parsedValues.length; i++) { reuse.setField(parsedValues[i], i); } return reuse; } else { return null; } }</code><technical_language>"\r".getBytes(Charsets.UTF_8)[0] is a expensive call. charset codecs. do a bytes[offset + numBytes -1] == '\r'</technical_language>

Target:
public OUT readRecord(OUT reuse, byte[] bytes, int offset, int numBytes) { if(this.lineDelimiterIsLinebreak == true && bytes[offset + numBytes -1] == '\r' ) { numBytes--; } if (parseRecord(parsedValues, bytes, offset, numBytes)) { for (int i = 0; i < parsedValues.length; i++) { reuse.setField(parsedValues[i], i); } return reuse; } else { return null; } }
Source:
<code>public static String listUsers(final IEssentials ess, final List<User> users, final String seperator) { final StringBuilder groupString = new StringBuilder(); Collections.sort(users); boolean needComma = false; for (final User user : users) { if (needComma) { groupString.append(seperator); } needComma = true; if (user.isAfk()) { groupString.append(tl("listAfkTag")); } if (user.isHidden()) { groupString.append(tl("listHiddenTag")); } user.setDisplayNick(); groupString.append(user.getDisplayName()); <START> final String strippedNick = FormatUtil.stripEssentialsFormat(user.getNickname()); <END> if (ess.getSettings().realNamesOnList() && strippedNick != null && !strippedNick.equals(user.getName())) { groupString.append(" (").append(user.getName()).append(")"); } groupString.append(ChatColor.WHITE.toString()); } return groupString.toString(); }</code><technical_language>stripFormat stripEssentialsFormat untranslated color codes afaik? suggestion final String strippedNick = FormatUtil.stripFormat(user.getNickname());</technical_language>

Target:
public static String listUsers(final IEssentials ess, final List<User> users, final String seperator) { final StringBuilder groupString = new StringBuilder(); Collections.sort(users); boolean needComma = false; for (final User user : users) { if (needComma) { groupString.append(seperator); } needComma = true; if (user.isAfk()) { groupString.append(tl("listAfkTag")); } if (user.isHidden()) { groupString.append(tl("listHiddenTag")); } user.setDisplayNick(); groupString.append(user.getDisplayName()); final String strippedNick = FormatUtil.stripFormat(user.getNickname()); if (ess.getSettings().realNamesOnList() && strippedNick != null && !strippedNick.equals(user.getName())) { groupString.append(" (").append(user.getName()).append(")"); } groupString.append(ChatColor.WHITE.toString()); } return groupString.toString(); }
Source:
<code>private ResourceEstimates parseResourceEstimate(HttpServletRequest servletRequest) { ResourceEstimateBuilder builder = new ResourceEstimateBuilder(); for (String header : splitSessionHeader(servletRequest.getHeaders(PRESTO_RESOURCE_ESTIMATE))) { List<String> nameValue = Splitter.on('=').limit(2).trimResults().splitToList(header); assertRequest(nameValue.size() == 2, "Invalid %s header", PRESTO_RESOURCE_ESTIMATE); String name = nameValue.get(0); long value; try { value = Long.parseLong(nameValue.get(1)); } catch (NumberFormatException ignored) { throw badRequest(format("Expected integral value for resource estimate %s", name)); } <START> if (name.equalsIgnoreCase(ResourceEstimates.EXECUTION_TIME_MILLIS)) { <END> builder.setExecutionTimeMillis(value); } else if (name.equalsIgnoreCase(ResourceEstimates.CPU_TIME_MILLIS)) { builder.setCpuTimeMillis(value); } else if (name.equalsIgnoreCase(ResourceEstimates.PEAK_MEMORY_BYTES)) { builder.setPeakMemoryBytes(value); } else { throw badRequest(format("Unsupported resource estimate %s", name)); } } return builder.build(); }</code><technical_language>underscore consistent session properties</technical_language>

Target:
private ResourceEstimates parseResourceEstimate(HttpServletRequest servletRequest) { ResourceEstimateBuilder builder = new ResourceEstimateBuilder(); for (String header : splitSessionHeader(servletRequest.getHeaders(PRESTO_RESOURCE_ESTIMATE))) { List<String> nameValue = Splitter.on('=').limit(2).trimResults().splitToList(header); assertRequest(nameValue.size() == 2, "Invalid %s header", PRESTO_RESOURCE_ESTIMATE); String name = nameValue.get(0); String value = nameValue.get(1); try { switch (name.toUpperCase()) { case ResourceEstimates.EXECUTION_TIME: builder.setExecutionTime(Duration.valueOf(value)); break; case ResourceEstimates.CPU_TIME: builder.setCpuTime(Duration.valueOf(value)); break; case ResourceEstimates.PEAK_MEMORY: builder.setPeakMemory(DataSize.valueOf(value)); break; default: throw badRequest(format("Unsupported resource name %s", name)); } } catch (IllegalArgumentException e) { throw badRequest(format("Unsupported format for resource estimate '%s': %s", value, e)); } } return builder.build(); }
Source:
<code><START> default <A> A getAttribute(String name) { <END> return (A) getAttributes().get(name); }</code><technical_language>putting some thought this method, a question for you. While SAML spec allows multiple AttributeValues for a single Attribute, encourages one-to-one. of that, I imagine applications want do: java String email = principal.getAttribute("email"); instead of: java List<String> emails = principal.getAttribute("email"); String email = emails == null || emails.isEmpty() ? null : emails.get(0); expectation? If expect do option, want change this method to: java List<A> values = getAttributes().get(name); return (A) CollectionUtils.firstElement(values); possibly rename getFirstAttribute. If expect option, signature change <A> List<A> getAttribute(String)</technical_language>

Target:
default <A> List<A> getAttribute(String name) { return (List<A>) getAttributes().get(name); }
Source:
<code>private void internalDeleteBundleAndDependenciesThrowRuntime(final String bundleId, final User user, final int currentCount, final int bundleSleepCount, final long millisBundleSleep) { try { this.internalDeleteBundleAndDependencies(bundleId, user); if (currentCount % bundleSleepCount == 0) { DateUtil.sleep(millisBundleSleep); } } catch (DotDataException e) { <START> <END> throw new DotRuntimeException(e); } }</code><technical_language>Please log debugging data here</technical_language>

Target:
private void internalDeleteBundleAndDependenciesThrowRuntime(final String bundleId, final User user, final int currentCount, final int bundleSleepCount, final long millisBundleSleep) { try { this.internalDeleteBundleAndDependencies(bundleId, user); if (currentCount % bundleSleepCount == 0) { DateUtil.sleep(millisBundleSleep); } } catch (DotDataException e) { Logger.error(this,"Error Removing bundle: " + bundleId + " by the user :" + user.getUserId(),e); throw new DotRuntimeException(e); } }
Source:
<code>public void executesInParallel() { final AtomicInteger count = new AtomicInteger(ParallelizerTest.COUNT); new Runnable() { @Override @Parallel(threads = ParallelizerTest.COUNT) public void run() { count.decrementAndGet(); } } <START> .run(); <END> MatcherAssert.assertThat(count.get(), Matchers.equalTo(0)); }</code><technical_language>new line? leave previous line, like: new Runnable() { } .run();</technical_language>

Target:
public void executesInParallel() { final AtomicInteger count = new AtomicInteger(Tv.TEN); new Runnable() { @Override @Parallel(threads = Tv.TEN) public void run() { count.decrementAndGet(); } } .run(); MatcherAssert.assertThat(count.get(), Matchers.equalTo(0)); }
Source:
<code>public static byte[] inputStreamToBytes(final InputStream inputStream) throws IOException { ByteArrayOutputStream bufferedArray = new ByteArrayOutputStream(); int nRead; <START> byte[] buffer = new byte[4096]; <END> while ((nRead = inputStream.read(buffer, 0, buffer.length)) != -1) { bufferedArray.write(buffer, 0, nRead); } return bufferedArray.toByteArray(); }</code><technical_language>this a bit large, 512</technical_language>

Target:
public static byte[] inputStreamToBytes(final InputStream inputStream) throws IOException { ByteArrayOutputStream bufferedArray = new ByteArrayOutputStream(); int nRead; byte[] buffer = new byte[512]; while ((nRead = inputStream.read(buffer, 0, buffer.length)) != -1) { bufferedArray.write(buffer, 0, nRead); } return bufferedArray.toByteArray(); }
Source:
<code>private void iterateOverHigherLevelMetadata(DocStructInterface enricher, Map<String, Map<String, MetadataInterface>> higherLevelMetadata) { for (Entry<String, Map<String, MetadataInterface>> availableHigherMetadata : higherLevelMetadata .entrySet()) { String enrichable = availableHigherMetadata.getKey(); boolean addable = false; List<MetadataTypeInterface> addableTypesNotNull = enricher.getAddableMetadataTypes(); if (addableTypesNotNull == null) { addableTypesNotNull = Collections.emptyList(); } for (MetadataTypeInterface addableMetadata : addableTypesNotNull) { if (addableMetadata.getName().equals(enrichable)) { addable = true; break; } } if (!addable) { continue; } there: for (Entry<String, MetadataInterface> higherElement : availableHigherMetadata.getValue() .entrySet()) { List<MetadataInterface> amNotNull = enricher.getAllMetadata(); <START> if (amNotNull == null) { <END> amNotNull = Collections.emptyList(); } for (MetadataInterface existentMetadata : amNotNull) { if (existentMetadata.getMetadataType().getName().equals(enrichable) && existentMetadata.getValue().equals(higherElement.getKey())) { continue there; } } try { enricher.addMetadata(higherElement.getValue()); } catch (UGHException e) { Helper.setErrorMessage("errorAdding", new Object[] {Helper.getTranslation("metadata") }, logger, e); } } } }</code><technical_language>a Objects.isNull(amNotNull) other places changes</technical_language>

Target:
private void iterateOverHigherLevelMetadata(DocStructInterface enricher, Map<String, Map<String, MetadataInterface>> higherLevelMetadata) { for (Entry<String, Map<String, MetadataInterface>> availableHigherMetadata : higherLevelMetadata .entrySet()) { String enrichable = availableHigherMetadata.getKey(); boolean addable = false; List<MetadataTypeInterface> addableTypesNotNull = enricher.getAddableMetadataTypes(); if (Objects.isNull(addableTypesNotNull)) { addableTypesNotNull = Collections.emptyList(); } for (MetadataTypeInterface addableMetadata : addableTypesNotNull) { if (addableMetadata.getName().equals(enrichable)) { addable = true; break; } } if (!addable) { continue; } there: for (Entry<String, MetadataInterface> higherElement : availableHigherMetadata.getValue() .entrySet()) { List<MetadataInterface> amNotNull = enricher.getAllMetadata(); if (Objects.isNull(amNotNull)) { amNotNull = Collections.emptyList(); } for (MetadataInterface existentMetadata : amNotNull) { if (existentMetadata.getMetadataType().getName().equals(enrichable) && existentMetadata.getValue().equals(higherElement.getKey())) { continue there; } } try { enricher.addMetadata(higherElement.getValue()); } catch (UGHException e) { Helper.setErrorMessage("errorAdding", new Object[] {Helper.getTranslation("metadata") }, logger, e); } } } }
Source:
<code>public void applyWithChildContextPublisherCompleted() { AtomicBoolean fluxCompleted = new AtomicBoolean(false); final FluxSinkRecorder<CoreEvent> emitter = new FluxSinkRecorder<>(); Flux.create(emitter) <START> .transform(pub -> { <END> return applyWithChildContext(pub, pubInner -> pubInner, Optional.empty()); }) .subscribe(event -> { }, e -> { }, () -> fluxCompleted.set(true)); emitter.complete(); assertThat(fluxCompleted.get(), is(true)); }</code><technical_language>this change</technical_language>

Target:
public void applyWithChildContextPublisherCompleted() { AtomicBoolean fluxCompleted = new AtomicBoolean(false); final FluxSinkRecorder<CoreEvent> emitter = new FluxSinkRecorder<>(); Flux.create(emitter) .transform(pub -> applyWithChildContext(pub, pubInner -> pubInner, Optional.empty())) .subscribe(event -> { }, e -> { }, () -> fluxCompleted.set(true)); emitter.complete(); assertThat(fluxCompleted.get(), is(true)); }
Source:
<code>protected void checkOperations(DistributionSnapshot snapshot) throws IOException { List<OperationInfo> ops = snapshot.getOperations(); <START> Collections.sort(ops, new Comparator<OperationInfo>() { <END> @Override public int compare(OperationInfo arg0, OperationInfo arg1) { return arg0.getId().compareTo(arg1.getId()); } }); StringBuilder sb = new StringBuilder(); for (OperationInfo op : ops) { sb.append(represent(op)); } checkContentEquals("apidoc_snapshot/operations.txt", sb.toString()); }</code><technical_language>Collections.sort(ops, Comparator.comparing(OperationInfo::getId))</technical_language>

Target:
protected void checkOperations(DistributionSnapshot snapshot) throws IOException { List<OperationInfo> ops = snapshot.getOperations(); Collections.sort(ops, Comparator.comparing(OperationInfo::getId)); StringBuilder sb = new StringBuilder(); ops.forEach(op -> sb.append(represent(op))); checkContentEquals("apidoc_snapshot/operations.txt", sb.toString()); }
Source:
<code>public @Nullable String toString() { <START> return String.valueOf(fValue); <END> }</code><technical_language>String.valueof(String).toString();? return string, final</technical_language>

Target:
public @Nullable String toString() { return fValue; }
Source:
<code>public StoreDescriptor(String dataDir) throws IOException { File storeDescriptorFile = new File(dataDir, StoreDescriptor.STORE_DESCRIPTOR); if (storeDescriptorFile.exists()) { DataInputStream dataInputStream = new DataInputStream(new FileInputStream(storeDescriptorFile)); short version = dataInputStream.readShort(); switch (version) { case VERSION_0: String incarnationId = Utils.readIntString(dataInputStream); this.incarnationId = UUID.fromString(incarnationId); break; default: throw new IllegalArgumentException("Unrecognized version in StoreDescriptor: " + version); } } else { this.incarnationId = UUID.randomUUID(); <START> storeDescriptorFile.createNewFile(); <END> DataOutputStream dataOutputStream = new DataOutputStream(new FileOutputStream(storeDescriptorFile)); dataOutputStream.write(toBytes()); dataOutputStream.close(); } }</code><technical_language>this returns a boolean - need check if file created</technical_language>

Target:
StoreDescriptor(String dataDir) throws IOException { File storeDescriptorFile = new File(dataDir, STORE_DESCRIPTOR_FILENAME); if (storeDescriptorFile.exists()) { CrcInputStream crcStream = new CrcInputStream(new FileInputStream(storeDescriptorFile)); DataInputStream stream = new DataInputStream(crcStream); short version = stream.readShort(); switch (version) { case VERSION_0: String incarnationIdStr = Utils.readIntString(stream); incarnationId = UUID.fromString(incarnationIdStr); long crc = crcStream.getValue(); long crcValueInFile = stream.readLong(); if (crc != crcValueInFile) { throw new IllegalStateException( "CRC mismatch for StoreDescriptor. CRC of the stream " + crc + ", CRC from file " + crcValueInFile); } break; default: throw new IllegalArgumentException("Unrecognized version in StoreDescriptor: " + version); } } else { incarnationId = UUID.randomUUID(); File tempFile = new File(dataDir, STORE_DESCRIPTOR_FILENAME + ".tmp"); File actual = new File(dataDir, STORE_DESCRIPTOR_FILENAME); if (tempFile.createNewFile()) { FileOutputStream fileStream = new FileOutputStream(tempFile); CrcOutputStream crc = new CrcOutputStream(fileStream); DataOutputStream writer = new DataOutputStream(crc); writer.write(toBytes()); long crcValue = crc.getValue(); writer.writeLong(crcValue); fileStream.getChannel().force(true); if (!tempFile.renameTo(actual)) { throw new IllegalStateException( "File " + tempFile.getAbsolutePath() + " renaming to " + actual.getAbsolutePath() + " failed "); } } else { throw new IllegalStateException("File " + tempFile.getAbsolutePath() + " creation failed "); } } }
Source:
<code>public void tearDown() { <START> if (fModule != null) { <END> fModule.close(); } if (fTrace != null) { fTrace.dispose(); File suppDir = new File(TmfTraceManager.getSupplementaryFileDir(fTrace)); deleteDirectory(suppDir); } }</code><technical_language>a null check here, in previous test classes? this null more others</technical_language>

Target:
public void tearDown() { fModule.close(); if (fTrace != null) { fTrace.dispose(); File suppDir = new File(TmfTraceManager.getSupplementaryFileDir(fTrace)); deleteDirectory(suppDir); } }
Source:
<code>public String getWSAddressingAction() { <START> return "urn:ihe:iti:xdr:2007:X12RealTimeRequestMessage"; <END> }</code><technical_language>namespace is wrong here</technical_language>

Target:
public String getWSAddressingAction() { return "RealTimeTransaction"; }
Source:
<code>private Response(Builder builder) { <START> checkState(builder.status >= 100 && builder.status < 600, "Invalid status code: %s", <END> builder.status); checkState(builder.request != null, "original request is required"); this.status = builder.status; this.request = builder.request; this.reason = builder.reason; this.headers = (builder.headers != null) ? Collections.unmodifiableMap(caseInsensitiveCopyOf(builder.headers)) : new LinkedHashMap<>(); this.body = builder.body; }</code><technical_language>said, I objections this PR</technical_language>

Target:
private Response(Builder builder) { checkState(builder.request != null, "original request is required"); this.status = builder.status; this.request = builder.request; this.reason = builder.reason; this.headers = (builder.headers != null) ? Collections.unmodifiableMap(caseInsensitiveCopyOf(builder.headers)) : new LinkedHashMap<>(); this.body = builder.body; }
Source:
<code>void writeEntityStatusOfAggregate() { LifecycleFlags status = LifecycleFlags.newBuilder() .setArchived(true) .build(); storage.writeLifecycleFlags(id, status); Optional<LifecycleFlags> readStatus = storage.readLifecycleFlags(id); <START> Truth8.assertThat(readStatus) <END> .hasValue(status); }</code><technical_language>Please static imports. compiler able assertThat(Optional) assertThat(Comparable)</technical_language>

Target:
void writeEntityStatusOfAggregate() { LifecycleFlags status = LifecycleFlags.newBuilder() .setArchived(true) .build(); storage.writeLifecycleFlags(id, status); Optional<LifecycleFlags> readStatus = storage.readLifecycleFlags(id); assertThat(readStatus) .hasValue(status); }
Source:
<code>private void assertTaskFormModelIsCorrect(TaskFormModel taskFormModel, String processId, String taskName) { assertEquals(processId, taskFormModel.getProcessId()); <START> final String EXPECTED_FORM_NAME = Parser.xmlParser().parseInput(taskName, <END> "") + BPMNVariableUtils.TASK_FORM_SUFFIX; assertEquals(EXPECTED_FORM_NAME, taskFormModel.getFormName()); }</code><technical_language>I understand this parser is needed. taskName simple String</technical_language>

Target:
private void assertTaskFormModelIsCorrect(TaskFormModel taskFormModel, String processId, String taskName) { assertEquals(processId, taskFormModel.getProcessId()); final String EXPECTED_FORM_NAME = taskName + BPMNVariableUtils.TASK_FORM_SUFFIX; assertEquals(EXPECTED_FORM_NAME, taskFormModel.getFormName()); }
Source:
<code>private boolean hasMetatypesForService( Map<String, Object> service, Set<MetaTypeInformation> metatypeInformations) { String id = (String) service.get("id"); Boolean isFactory = (Boolean) service.get("factory"); <START> if (id == null || isFactory == null) { <END> return false; } Stream<MetaTypeInformation> infoStream = metatypeInformations.stream().filter(Objects::nonNull); return (isFactory ? infoStream.map(MetaTypeInformation::getFactoryPids) : infoStream.map(MetaTypeInformation::getPids)) .filter(Objects::nonNull) .flatMap(Arrays::stream) .anyMatch(id::equals); }</code><technical_language>Move if (id == null) defining isFactory avoid if needed</technical_language>

Target:
private boolean hasMetatypesForService( Map<String, Object> service, Set<MetaTypeInformation> metatypeInformations) { String id = (String) service.get("id"); if (id == null) { return false; } Boolean isFactory = (Boolean) service.get("factory"); if (isFactory == null) { return false; } Stream<MetaTypeInformation> infoStream = metatypeInformations.stream().filter(Objects::nonNull); return (isFactory ? infoStream.map(MetaTypeInformation::getFactoryPids) : infoStream.map(MetaTypeInformation::getPids)) .filter(Objects::nonNull) .flatMap(Arrays::stream) .anyMatch(id::equals); }
Source:
<code>public void onStart() { super.onStart(); if (config.getFabricConfig().getKitsConfig().getBranchConfig().isEnabled()) { <START> Branch branch = Branch.getInstance(getApplicationContext()); <END> branch.initSession(new Branch.BranchReferralInitListener() { @Override public void onInitFinished(JSONObject referringParams, BranchError error) { if (error == null) { } else { logger.error(new Exception("Branch not configured properly, error:\n" + error.getMessage()), true); } } }, this.getIntent().getData(), this); finish(); } }</code><technical_language>final</technical_language>

Target:
public void onStart() { super.onStart(); if (Config.FabricBranchConfig.isBranchEnabled(config.getFabricConfig())) { final Branch branch = Branch.getInstance(getApplicationContext()); branch.initSession(new Branch.BranchReferralInitListener() { @Override public void onInitFinished(JSONObject referringParams, BranchError error) { if (error == null) { } else { logger.error(new Exception("Branch not configured properly, error:\n" + error.getMessage()), true); } } }, this.getIntent().getData(), this); finish(); } }
Source:
<code>@Override public String toString() { final StringBuilder outputStreamStats = new StringBuilder( "OutputStream Statistics{"); <START> outputStreamStats.append(IOStatisticsLogging.ioStatisticsSourceToString(ioStatisticsStore)); <END> outputStreamStats.append("}"); return outputStreamStats.toString(); }</code><technical_language>ioStatisticsStore.toString() too; get logging API is resilience failures</technical_language>

Target:
@Override public String toString() { final StringBuilder outputStreamStats = new StringBuilder( "OutputStream Statistics{"); outputStreamStats.append(ioStatisticsStore.toString()); outputStreamStats.append("}"); return outputStreamStats.toString(); }
Source:
<code>public void testInvalidCassandraHostsFailsValidation() { Configuration config = Configuration.getInstance(); config.setProperty(CoreConfig.CASSANDRA_HOSTS, "something"); BluefloodServiceStarterException ex = null; try { BluefloodServiceStarter.validateCassandraHosts(); } catch (BluefloodServiceStarterException e) { ex = e; } <START> assertNotNull(ex); <END> assertEquals(-1, ex.getStatus()); }</code><technical_language>@Test(expected = ...), above</technical_language>

Target:
public void testInvalidCassandraHostsFailsValidation() { Configuration config = Configuration.getInstance(); config.setProperty(CoreConfig.CASSANDRA_HOSTS, "something"); BluefloodServiceStarter.validateCassandraHosts(); }
Source:
<code>public SaslClient createSaslClient(String[] mechanisms, String authorizationId, String protocol, String serverName, Map<String, ?> props, CallbackHandler cbh) throws SaslException { <START> if (cbh == null) throw ElytronMessages.log.mechCallbackHandlerMissing().toSaslException(); <END> if (props == null) props = Collections.emptyMap(); if (! matches(props)) return null; String selectedMech = select(mechanisms); if (selectedMech == null) return null; Boolean utf8 = (Boolean)props.get(WildFlySasl.USE_UTF8); Charset charset = (utf8==null || utf8.booleanValue()) ? StandardCharsets.UTF_8 : StandardCharsets.ISO_8859_1; String qopsString = (String)props.get(Sasl.QOP); String[] qops = qopsString==null ? null : qopsString.split(","); String supportedCipherOpts = (String)props.get(WildFlySasl.SUPPORTED_CIPHER_NAMES); String[] ciphers = supportedCipherOpts == null ? DEFAULT_CIPHERS : supportedCipherOpts.split(","); final DigestSaslClient client = new DigestSaslClient(selectedMech, protocol, serverName, cbh, authorizationId, false, charset, qops, ciphers, providers); client.init(); return client; }</code><technical_language>Null parameter checks "Assert.checkNotNullParam" if possible</technical_language>

Target:
public SaslClient createSaslClient(String[] mechanisms, String authorizationId, String protocol, String serverName, Map<String, ?> props, CallbackHandler cbh) throws SaslException { Assert.checkNotNullParam("cbh", cbh); if (props == null) props = Collections.emptyMap(); if (! matches(props)) return null; String selectedMech = select(mechanisms); if (selectedMech == null) return null; Boolean utf8 = (Boolean)props.get(WildFlySasl.USE_UTF8); Charset charset = (utf8==null || utf8.booleanValue()) ? StandardCharsets.UTF_8 : StandardCharsets.ISO_8859_1; String qopsString = (String)props.get(Sasl.QOP); String[] qops = qopsString==null ? null : qopsString.split(","); String supportedCipherOpts = (String)props.get(WildFlySasl.SUPPORTED_CIPHER_NAMES); String[] ciphers = supportedCipherOpts == null ? DEFAULT_CIPHERS : supportedCipherOpts.split(","); final DigestSaslClient client = new DigestSaslClient(selectedMech, protocol, serverName, cbh, authorizationId, false, charset, qops, ciphers, providers); client.init(); return client; }
Source:
<code><START> public UpdaterIssuesSelector getIssueSelector() { <END> UpdaterIssuesSelector uis = this.issueSelector; if (uis == null) uis = new Updater.DefaultUpdaterIssuesSelector(); return (this.issueSelector = uis); }</code><technical_language>Please conform naming standard i.e. singular plurar form for classes methods</technical_language>

Target:
public UpdaterIssueSelector getIssueSelector() { UpdaterIssueSelector uis = this.issueSelector; if (uis == null) uis = new DefaultUpdaterIssueSelector(); return (this.issueSelector = uis); }
Source:
<code>public double[] transformToDoubleValuesSV(ProjectionBlock projectionBlock) { if (_results == null) { _results = new double[DocIdSetPlanNode.MAX_DOC_PER_CALL]; } int numDocs = projectionBlock.getNumDocs(); <START> double sumRes; <END> switch (_argument.getResultMetadata().getDataType()) { case INT: int[][] intValuesMV = _argument.transformToIntValuesMV(projectionBlock); for (int i = 0; i < numDocs; i++) { sumRes = 0; for (int j = 0; j < intValuesMV[i].length; j++) { sumRes += intValuesMV[i][j]; } _results[i] = sumRes / intValuesMV[i].length; } break; case LONG: long[][] longValuesMV = _argument.transformToLongValuesMV(projectionBlock); for (int i = 0; i < numDocs; i++) { sumRes = 0; for (int j = 0; j < longValuesMV[i].length; j++) { sumRes += longValuesMV[i][j]; } _results[i] = sumRes / longValuesMV[i].length; } break; case FLOAT: float[][] floatValuesMV = _argument.transformToFloatValuesMV(projectionBlock); for (int i = 0; i < numDocs; i++) { sumRes = 0; for (int j = 0; j < floatValuesMV[i].length; j++) { sumRes += floatValuesMV[i][j]; } _results[i] = sumRes / floatValuesMV[i].length; } break; case DOUBLE: double[][] doubleValuesMV = _argument.transformToDoubleValuesMV(projectionBlock); for (int i = 0; i < numDocs; i++) { sumRes = 0; for (int j = 0; j < doubleValuesMV[i].length; j++) { sumRes += doubleValuesMV[i][j]; } _results[i] = sumRes / doubleValuesMV[i].length; } break; default: throw new IllegalStateException(); } return _results; }</code><technical_language>(nit) Move declaration for for readability</technical_language>

Target:
public double[] transformToDoubleValuesSV(ProjectionBlock projectionBlock) { if (_results == null) { _results = new double[DocIdSetPlanNode.MAX_DOC_PER_CALL]; } int numDocs = projectionBlock.getNumDocs(); switch (_argument.getResultMetadata().getDataType()) { case INT: int[][] intValuesMV = _argument.transformToIntValuesMV(projectionBlock); for (int i = 0; i < numDocs; i++) { double sumRes = 0; for (int value : intValuesMV[i]) { sumRes += value; } _results[i] = sumRes / intValuesMV[i].length; } break; case LONG: long[][] longValuesMV = _argument.transformToLongValuesMV(projectionBlock); for (int i = 0; i < numDocs; i++) { double sumRes = 0; for (long value : longValuesMV[i]) { sumRes += value; } _results[i] = sumRes / longValuesMV[i].length; } break; case FLOAT: float[][] floatValuesMV = _argument.transformToFloatValuesMV(projectionBlock); for (int i = 0; i < numDocs; i++) { double sumRes = 0; for (float value : floatValuesMV[i]) { sumRes += value; } _results[i] = sumRes / floatValuesMV[i].length; } break; case DOUBLE: double[][] doubleValuesMV = _argument.transformToDoubleValuesMV(projectionBlock); for (int i = 0; i < numDocs; i++) { double sumRes = 0; for (double value : doubleValuesMV[i]) { sumRes += value; } _results[i] = sumRes / doubleValuesMV[i].length; } break; default: throw new IllegalStateException(); } return _results; }
Source:
<code>public void testHashCodeSame() { RuntimeSettingProvider runtimeSettingProvider1 = createPropsWithDriverName("org.talend.Driver1"); JdbcRuntimeInfo jarRuntimeInfo1 = new JdbcRuntimeInfo(runtimeSettingProvider1, "anyRuntimeClassName"); int hashCode1 = jarRuntimeInfo1.hashCode(); RuntimeSettingProvider runtimeSettingProvider2 = createPropsWithDriverName("org.talend.Driver1"); JdbcRuntimeInfo jarRuntimeInfo2 = new JdbcRuntimeInfo(runtimeSettingProvider2, "anyRuntimeClassName"); int hashCode2 = jarRuntimeInfo2.hashCode(); assertEquals(269161086, hashCode1); <START> assertEquals(269161086, hashCode2); <END> assertEquals(hashCode1, hashCode2); }</code><technical_language>hashcodes hardcoded ? depend HashCodeBuilder.toHashCode() implementation</technical_language>

Target:
public void testHashCodeSame() { RuntimeSettingProvider runtimeSettingProvider1 = createPropsWithDriverName("org.talend.Driver1"); JdbcRuntimeInfo jdbcRuntimeInfo1 = new JdbcRuntimeInfo(runtimeSettingProvider1, "anyRuntimeClassName"); int hashCode1 = jdbcRuntimeInfo1.hashCode(); RuntimeSettingProvider runtimeSettingProvider2 = createPropsWithDriverName("org.talend.Driver1"); JdbcRuntimeInfo jdbcRuntimeInfo2 = new JdbcRuntimeInfo(runtimeSettingProvider2, "anyRuntimeClassName"); int hashCode2 = jdbcRuntimeInfo2.hashCode(); assertEquals(jdbcRuntimeInfo1, jdbcRuntimeInfo2); assertEquals(hashCode1, hashCode2); }
Source:
<code>public final Map<K, V> removeAllWithHash(int keyHash) { Map<K, V> invalidated = new HashMap<K, V>(); int hash = spread(keyHash); for (Node<K, V>[] tab = table; ; ) { Node<K, V> f; int n, i; if (tab == null || (n = tab.length) == 0 || (f = tabAt(tab, i = (n - 1) & hash)) == null) break; else if (f.hash == MOVED) tab = helpTransfer(tab, f); else { Map<K, V> nodes = null; synchronized (f) { if (tabAt(tab, i) == f) { nodes = nodesAt(f); setTabAt(tab, i, null); <START> invalidated.putAll(nodes); <END> } } if (nodes != null) { addCount(-nodes.size(), -nodes.size()); } } } return invalidated; }</code><technical_language>map creations + putAll. I code pay more attention ... if means map in a side effect argument</technical_language>

Target:
public final Map<K, V> removeAllWithHash(int keyHash) { Map<K, V> invalidated = new HashMap<K, V>(); int hash = spread(keyHash); for (Node<K, V>[] tab = table; ; ) { Node<K, V> f; int n, i; if (tab == null || (n = tab.length) == 0 || (f = tabAt(tab, i = (n - 1) & hash)) == null) break; else if (f.hash == MOVED) tab = helpTransfer(tab, f); else { int nodesCount = 0; synchronized (f) { if (tabAt(tab, i) == f) { nodesCount = nodesAt(f, invalidated); setTabAt(tab, i, null); } } if (nodesCount > 0) { addCount(-nodesCount, -nodesCount); } } } return invalidated; }
Source:
<code>public void run() throws Exception { MaxwellAbstractRowsEvent event; this.start(); for(;;) { event = getEvent(); if ( event == null ) continue; if ( !skipEvent(event)) { producer.push(event); BinlogPosition p = eventBinlogPosition(event); } } <START> } <END></code><technical_language>do p this? remove eventBinlogPosition well</technical_language>

Target:
public void run() throws Exception { MaxwellAbstractRowsEvent event; this.start(); for(;;) { event = getEvent(); if ( event == null ) continue; if ( !skipEvent(event)) { producer.push(event); } } }
Source:
<code>public ImmutableList<InsightsLastSeen> getAll(final Long accountId) { final PrimaryKey key = new PrimaryKey(AttributeName.ACCOUNT_ID.shortName(), accountId); final Item item = table.getItem(key); if (item == null) { <START> LOGGER.debug("debug=get-all-last-seen-insights-fail-insight-missing account_id={}", accountId); <END> final List<InsightsLastSeen> insightsLastSeen = new ArrayList<>(); return ImmutableList.copyOf(insightsLastSeen); } final ImmutableList<InsightsLastSeen> insightsLastSeen = fromItem(accountId, item); return insightsLastSeen; }</code><technical_language>msg=get-all-last-seen-insights-fail-insight-missing repeat debug. for error sense error=xxxxx key</technical_language>

Target:
public ImmutableList<InsightsLastSeen> getAll(final Long accountId) { final PrimaryKey key = new PrimaryKey(AttributeName.ACCOUNT_ID.shortName(), accountId); final Item item = table.getItem(key); if (item == null) { LOGGER.debug("msg=get-all-last-seen-insights-fail-insight-missing account_id={}", accountId); final List<InsightsLastSeen> insightsLastSeen = new ArrayList<>(); return ImmutableList.copyOf(insightsLastSeen); } final ImmutableList<InsightsLastSeen> insightsLastSeen = fromItem(accountId, item); return insightsLastSeen; }
Source:
<code>public void resourceChanged(IResourceChangeEvent event) { try { IResourceDelta d = event.getDelta(); if (d == null || !autoIgnoreDerived()) return; <START> final Set<IPath> toBeIgnored = new HashSet<IPath>(); <END> d.accept(new IResourceDeltaVisitor() { public boolean visit(IResourceDelta delta) throws CoreException { if ((delta.getKind() & (IResourceDelta.ADDED | IResourceDelta.CHANGED)) == 0) return false; int flags = delta.getFlags(); if ((flags != 0) && ((flags & IResourceDelta.DERIVED_CHANGED) == 0)) return false; final IResource r = delta.getResource(); if ((r.getProject() != null) && (RepositoryMapping.getMapping(r) == null)) return false; if (r.isTeamPrivateMember()) return false; if (r.isDerived()) { try { if (!RepositoryUtil.isIgnored(r.getLocation())) toBeIgnored.add(r.getLocation()); } catch (IOException e) { logError( MessageFormat.format( CoreText.Activator_ignoreResourceFailed, r.getFullPath()), e); } return false; } return true; } }); if (toBeIgnored.size() > 0) JobUtil.scheduleUserJob(new IgnoreOperation(toBeIgnored), CoreText.Activator_autoIgnoreDerivedResources, JobFamilies.AUTO_IGNORE); } catch (CoreException e) { Activator.logError(e.getMessage(), e); return; } }</code><technical_language>a LinkedHashSet order stable</technical_language>

Target:
public void resourceChanged(IResourceChangeEvent event) { try { IResourceDelta d = event.getDelta(); if (d == null || !autoIgnoreDerived()) return; final Set<IPath> toBeIgnored = new LinkedHashSet<IPath>(); d.accept(new IResourceDeltaVisitor() { public boolean visit(IResourceDelta delta) throws CoreException { if ((delta.getKind() & (IResourceDelta.ADDED | IResourceDelta.CHANGED)) == 0) return false; int flags = delta.getFlags(); if ((flags != 0) && ((flags & IResourceDelta.DERIVED_CHANGED) == 0)) return false; final IResource r = delta.getResource(); if ((r.getProject() != null) && (RepositoryMapping.getMapping(r) == null)) return false; if (r.isTeamPrivateMember()) return false; if (r.isDerived()) { try { if (!RepositoryUtil.isIgnored(r.getLocation())) toBeIgnored.add(r.getLocation()); } catch (IOException e) { logError( MessageFormat.format( CoreText.Activator_ignoreResourceFailed, r.getFullPath()), e); } return false; } return true; } }); if (toBeIgnored.size() > 0) JobUtil.scheduleUserJob(new IgnoreOperation(toBeIgnored), CoreText.Activator_autoIgnoreDerivedResources, JobFamilies.AUTO_IGNORE); } catch (CoreException e) { Activator.logError(e.getMessage(), e); return; } }
Source:
<code><START> public void stop() { <END> if (isAlive.get()) { stop(handle); } }</code><technical_language>this a getAndSet(false)</technical_language>

Target:
public void stop() { if (isAlive.getAndSet(false)) { stop(handle); } }