auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public List<Container> findAllContainers() throws DotDataException { DotConnect dc = new DotConnect(); <START> String sql = "SELECT " + Inode.Type.CONTAINERS.getTableName() + ".* from " + Inode.Type.CONTAINERS.getTableName() + ", inode dot_containers_1_, container_version_info vv " + <END> "where vv.working_inode= " + Inode.Type.CONTAINERS.getTableName() + ".inode and " + Inode.Type.CONTAINERS.getTableName() + ".inode = dot_containers_1_.inode and " + "dot_containers_1_.type='containers' order by " + Inode.Type.CONTAINERS.getTableName() + ".title"; dc.setSQL(sql); try { return ConvertToPOJOUtil.convertDotConnectMapToContainer(dc.loadResults()); } catch (ParseException e) { throw new DotDataException(e); } }</code><technical_language>StringBuilder</technical_language>

Target:
public List<Container> findAllContainers() throws DotDataException { DotConnect dc = new DotConnect(); StringBuilder sql = new StringBuilder(); String tableName = Type.CONTAINERS.getTableName(); sql.append("SELECT "); sql.append(tableName); sql.append(".* from "); sql.append(tableName); sql.append(", inode dot_containers_1_, container_version_info vv where vv.working_inode= "); sql.append(tableName); sql.append(".inode and "); sql.append(tableName); sql.append(".inode = dot_containers_1_.inode and dot_containers_1_.type='containers' order by "); sql.append(tableName); sql.append(".title"); dc.setSQL(sql.toString()); try { return ConvertToPOJOUtil.convertDotConnectMapToContainer(dc.loadResults()); } catch (ParseException e) { throw new DotDataException(e); } }
Source:
<code>private void exposeInContainerIfNeeded(ServicePort servicePort) { <START> Optional<ContainerPort> exposedOpt = <END> container .getPorts() .stream() .filter( p -> p.getContainerPort().equals(servicePort.getPort()) && servicePort.getProtocol().equals(p.getProtocol())) .findAny(); if (!exposedOpt.isPresent()) { ContainerPort containerPort = new ContainerPortBuilder() .withContainerPort(servicePort.getPort()) .withProtocol(servicePort.getProtocol()) .build(); container.getPorts().add(containerPort); } }</code><technical_language>stream().noneMatch()</technical_language>

Target:
private void exposeInContainerIfNeeded(ServicePort servicePort) { if (container .getPorts() .stream() .noneMatch( p -> p.getContainerPort().equals(servicePort.getPort()) && servicePort.getProtocol().equals(p.getProtocol()))) { ContainerPort containerPort = new ContainerPortBuilder() .withContainerPort(servicePort.getPort()) .withProtocol(servicePort.getProtocol()) .build(); container.getPorts().add(containerPort); } }
Source:
<code><START> public int read(int offset, int[] positions, int positionCount) <END> throws IOException { if (!rowGroupOpen) { openRowGroup(); } checkState(!valuesInUse, "BlockLease hasn't been closed yet"); if (outputRequired) { ensureValuesCapacity(positionCount, presentStream != null && nullsAllowed); } if (filter != null) { outputPositions = ensureCapacity(outputPositions, positionCount); } else { outputPositions = positions; } systemMemoryContext.setBytes(getRetainedSizeInBytes()); if (readOffset < offset) { skip(offset - readOffset); } prepareForNextRead(positionCount, positions); int streamPosition; if (dataStream == null && lengthVector == null && isNullVector != null) { streamPosition = readAllNulls(positions, positionCount); } else if (filter == null) { streamPosition = readNoFilter(positions, positionCount); } else { streamPosition = readWithFilter(positions, positionCount); } readOffset = offset + streamPosition; return outputPositionCount; }</code><technical_language>is a bit late check outputType for null; in this.outputRequired = outputType.isPresent();; move outputRequired outputType this.outputType = requireNonNull(outputType, "outputType is null").orElse(null); this.outputRequired = outputType.isPresent();</technical_language>

Target:
public int read(int offset, int[] positions, int positionCount) throws IOException { if (!rowGroupOpen) { openRowGroup(); } checkState(!valuesInUse, "BlockLease hasn't been closed yet"); if (filter != null) { outputPositions = ensureCapacity(outputPositions, positionCount); } else { outputPositions = positions; outputPositionsReadOnly = true; } systemMemoryContext.setBytes(getRetainedSizeInBytes()); if (readOffset < offset) { skip(offset - readOffset); } prepareForNextRead(positionCount, positions); int streamPosition; if (lengthStream == null) { streamPosition = readAllNulls(positions, positionCount); } else if (filter == null) { streamPosition = readNoFilter(positions, positionCount); } else { streamPosition = readWithFilter(positions, positionCount); } readOffset = offset + streamPosition; return outputPositionCount; }
Source:
<code>public PinotQueryGeneratorContext withAggregation( LinkedHashMap<VariableReferenceExpression, Selection> newSelections, LinkedHashSet<VariableReferenceExpression> groupByColumns, int aggregations, Set<VariableReferenceExpression> hiddenColumnSet) { Iterator<Selection> selectionIterator = newSelections.values().iterator(); boolean passed = false; while (selectionIterator.hasNext()) { <START> if (selectionIterator.next().getDefinition().startsWith(DISTINCT_COUNT_FUNCTION_NAME.toUpperCase(Locale.ENGLISH))) { <END> hiddenColumnSet = Collections.emptySet(); passed = true; } } if (!passed) { checkSupported(!hasAggregation(), "Pinot doesn't support aggregation on top of the aggregated data"); } checkSupported(!hasLimit(), "Pinot doesn't support aggregation on top of the limit"); checkSupported(aggregations > 0, "Invalid number of aggregations"); return new PinotQueryGeneratorContext(newSelections, from, filter, aggregations, groupByColumns, topNColumnOrderingMap, limit, variablesInAggregation, hiddenColumnSet); }</code><technical_language>I understand fully need change hiddenColumnSet ? Also, this loop written some java8 streams</technical_language>

Target:
public PinotQueryGeneratorContext withAggregation( LinkedHashMap<VariableReferenceExpression, Selection> newSelections, LinkedHashSet<VariableReferenceExpression> groupByColumns, int aggregations, Set<VariableReferenceExpression> hiddenColumnSet) { AtomicBoolean pushDownDistinctCount = new AtomicBoolean(false); newSelections.values().forEach(selection -> { if (selection.getDefinition().startsWith(PINOT_DISTINCT_COUNT_FUNCTION_NAME.toUpperCase(Locale.ENGLISH))) { pushDownDistinctCount.set(true); } }); if (pushDownDistinctCount.get()) { hiddenColumnSet = ImmutableSet.of(); } else { checkSupported(!hasAggregation(), "Pinot doesn't support aggregation on top of the aggregated data"); } checkSupported(!hasLimit(), "Pinot doesn't support aggregation on top of the limit"); checkSupported(aggregations > 0, "Invalid number of aggregations"); return new PinotQueryGeneratorContext(newSelections, from, filter, aggregations, groupByColumns, topNColumnOrderingMap, limit, variablesInAggregation, hiddenColumnSet); }
Source:
<code>protected void executeCommand() { AuditLog auditLog = getAuditLog(); auditLogDao.remove(getParameters().getAuditLogId()); setAuditLogDetails(auditLog); auditLog.setUserId(Guid.Empty); <START> AuditLogableBase logableToClear = Injector.injectMembers(new AuditLogableBase(auditLog)); <END> EventFloodRegulator eventFloodRegulator = new EventFloodRegulator(logableToClear, auditLog.getLogType()); eventFloodRegulator.evict(); setSucceeded(true); }</code><technical_language>good me. do identify other occurrences of this issue</technical_language>

Target:
protected void executeCommand() { AuditLog auditLog = getAuditLog(); auditLogDao.remove(getParameters().getAuditLogId()); setAuditLogDetails(auditLog); auditLog.setUserId(Guid.Empty); AuditLogable logableToClear = createAuditLogableImpl(auditLog); EventFloodRegulator eventFloodRegulator = new EventFloodRegulator(logableToClear, auditLog.getLogType()); eventFloodRegulator.evict(); setSucceeded(true); }
Source:
<code>private Throwable getRootCauseException(Throwable re) { <START> if (re.getCause() == null) return re; <END> Throwable cause = re.getCause(); if (cause instanceof RuntimeException) return getRootCauseException(cause); else return re; }</code><technical_language>This works this line :)</technical_language>

Target:
private Throwable getRootCauseException(Throwable re) { Throwable cause = re.getCause(); if (cause instanceof RuntimeException) return getRootCauseException(cause); else return re; }
Source:
<code>public void should_fail_when_two_elements_satisfy_the_given_restrictions() { Consumer<String> restrictions = name -> assertThat(name).startsWith("L"); <START> Throwable assertionError = catchThrowable(() -> iterables.assertNoneSatisfy(someInfo(), actual, restrictions)); <END> verify(failures).failure(info, noElementsShouldSatisfy(actual, list("Luke", "Leia"))); assertThat(assertionError).isNotNull(); }</code><technical_language>replaced AssertionsUtil.expectAssertionError checks assertThat(assertionError).isNotNull(); internally</technical_language>

Target:
public void should_fail_when_two_elements_satisfy_the_given_restrictions() { Consumer<String> restrictions = name -> assertThat(name).startsWith("L"); Throwable assertionError = expectAssertionError(() -> iterables.assertNoneSatisfy(someInfo(), actual, restrictions)); verify(failures).failure(info, noElementsShouldSatisfy(actual, list("Luke", "Leia"))); assertThat(assertionError).isNotNull(); }
Source:
<code>Mono<Void> sendCloudEvents(Iterable<CloudEvent> events, Context context) { this.addCloudEventTracePlaceHolder(events); return Flux.fromIterable(events) .map(CloudEvent::toImpl) .collectList() .flatMap(list -> this.impl.publishCloudEventEventsAsync(this.hostname, list, <START> context.addData(AZ_TRACING_NAMESPACE_KEY, Constants.EVENT_GRID_TRACING_NAMESPACE_VALUE))); <END> }</code><technical_language>check context for null calling function avoid NPE addData</technical_language>

Target:
Mono<Void> sendCloudEvents(Iterable<CloudEvent> events, Context context) { final Context finalContext = context != null ? context : Context.NONE; this.addCloudEventTracePlaceHolder(events); return Flux.fromIterable(events) .map(CloudEvent::toImpl) .collectList() .flatMap(list -> this.impl.publishCloudEventEventsAsync(this.hostname, list, finalContext.addData(AZ_TRACING_NAMESPACE_KEY, Constants.EVENT_GRID_TRACING_NAMESPACE_VALUE))); }
Source:
<code>protected final void fireStateChangeEvent(final ITeamStateChangeEvent event) { Object[] allListeners = listeners.getListeners(); for (Object <START> allListener : <END> allListeners) { final ITeamStateChangeListener listener = (ITeamStateChangeListener) allListener; SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { listener.teamStateChanged(event); } @Override public void handleException(Throwable exception) { } }); } }</code><technical_language>listener</technical_language>

Target:
protected final void fireStateChangeEvent(final ITeamStateChangeEvent event) { Object[] allListeners = listeners.getListeners(); for (Object l : allListeners) { final ITeamStateChangeListener listener = (ITeamStateChangeListener)l; SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { listener.teamStateChanged(event); } @Override public void handleException(Throwable exception) { } }); } }
Source:
<code>public void removeGroupUnion(PerunSession sess, Group resultGroup, Group operandGroup) throws InternalErrorException, GroupNotExistsException, PrivilegeException, GroupOperationsException { Utils.checkPerunSession(sess); getGroupsManagerBl().checkGroupExists(sess, resultGroup); getGroupsManagerBl().checkGroupExists(sess, operandGroup); <START> if (!getGroupsManagerBl().isOneWayRelationBetweenGroups(resultGroup, operandGroup)) { <END> throw new InternalErrorException("Relation does not exist between result group " + resultGroup + " and operand group" + operandGroup + "."); } if ( (!AuthzResolver.isAuthorized(sess, Role.VOADMIN, resultGroup) && !AuthzResolver.isAuthorized(sess, Role.GROUPADMIN, resultGroup)) || (!AuthzResolver.isAuthorized(sess, Role.VOADMIN, operandGroup) && !AuthzResolver.isAuthorized(sess, Role.GROUPADMIN, operandGroup)) ) { throw new PrivilegeException(sess, "removeGroupUnion"); } getGroupsManagerBl().removeGroupUnion(sess, resultGroup, operandGroup, false); }</code><technical_language>Check if this test of relation is in BlImpl part. If not, move there</technical_language>

Target:
public void removeGroupUnion(PerunSession sess, Group resultGroup, Group operandGroup) throws InternalErrorException, GroupNotExistsException, PrivilegeException, GroupOperationsException { Utils.checkPerunSession(sess); getGroupsManagerBl().checkGroupExists(sess, resultGroup); getGroupsManagerBl().checkGroupExists(sess, operandGroup); if ( (!AuthzResolver.isAuthorized(sess, Role.VOADMIN, resultGroup) && !AuthzResolver.isAuthorized(sess, Role.GROUPADMIN, resultGroup)) || (!AuthzResolver.isAuthorized(sess, Role.VOADMIN, operandGroup) && !AuthzResolver.isAuthorized(sess, Role.GROUPADMIN, operandGroup)) ) { throw new PrivilegeException(sess, "removeGroupUnion"); } getGroupsManagerBl().removeGroupUnion(sess, resultGroup, operandGroup, false); }
Source:
<code>public void end(Xid xid, int flags) throws XAException { <START> System.out.println("[" + Thread.currentThread().getName() + "] DummyXAResource (" + serverId + ") XA_END [" + xid + "] Flags=" + flags); <END> }</code><technical_language>worth debugging for this QS</technical_language>

Target:
public void end(Xid xid, int flags) throws XAException { }
Source:
<code>public void initializeObjects(List<EntityInfo> entityInfos, LinkedHashMap<EntityInfoLoadKey, Object> idToObjectMap, ObjectInitializationContext objectInitializationContext) { boolean traceEnabled = log.isTraceEnabled(); final int maxResults = entityInfos.size(); if ( maxResults == 0 ) { if ( traceEnabled ) { <START> log.tracef( "No object to initialize", (Integer) maxResults ); <END> } return; } for ( EntityInfo entityInfo : entityInfos ) { Object o = ObjectLoaderHelper.load( entityInfo, objectInitializationContext.getSession() ); if ( o != null ) { EntityInfoLoadKey key = new EntityInfoLoadKey( entityInfo.getClazz(), entityInfo.getId() ); idToObjectMap.put( key, o ); } } if ( traceEnabled ) { log.tracef( "Initialized %d objects by lookup method.", (Integer) maxResults ); } }</code><technical_language>simply remove parameter</technical_language>

Target:
public void initializeObjects(List<EntityInfo> entityInfos, LinkedHashMap<EntityInfoLoadKey, Object> idToObjectMap, ObjectInitializationContext objectInitializationContext) { boolean traceEnabled = log.isTraceEnabled(); final int maxResults = entityInfos.size(); if ( maxResults == 0 ) { if ( traceEnabled ) { log.tracef( "No object to initialize" ); } return; } for ( EntityInfo entityInfo : entityInfos ) { Object o = ObjectLoaderHelper.load( entityInfo, objectInitializationContext.getSession() ); if ( o != null ) { EntityInfoLoadKey key = new EntityInfoLoadKey( entityInfo.getClazz(), entityInfo.getId() ); idToObjectMap.put( key, o ); } } if ( traceEnabled ) { log.tracef( "Initialized %d objects by lookup method.", (Integer) maxResults ); } }
Source:
<code>public boolean equals(Object o) { <START> if (!(o instanceof ImportConfiguration)) { <END> return false; } ImportConfiguration other = (ImportConfiguration) o; return m_moduleProps.equals(other.m_moduleProps) && m_formatterBuilder.equals(other.m_formatterBuilder); }</code><technical_language>add if (o == this) return true;</technical_language>

Target:
public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof ImportConfiguration)) { return false; } ImportConfiguration other = (ImportConfiguration) o; return m_moduleProps.equals(other.m_moduleProps) && m_formatterBuilder.equals(other.m_formatterBuilder); }
Source:
<code>public void validatePluginNames(List<? extends PluginBase> plugins) throws InternalInfrastructureException { for (PluginBase plugin : plugins) { <START> final String formattedPluginName = plugin.getName().toLowerCase(); <END> if (!namePattern.matcher(formattedPluginName).matches()) { throw new InternalInfrastructureException( format( "Plugin named `%s` contains unacceptable symbols and cannot be used as part of container naming.", formattedPluginName)); } } }</code><technical_language>check container name</technical_language>

Target:
public void validatePluginNames(List<? extends PluginBase> plugins) throws ValidationException { for (PluginBase plugin : plugins) { if (plugin.getName() != null) { final String formattedPluginName = plugin.getName().toLowerCase(); checkValid( formattedPluginName, "Plugin name `%s` contains unacceptable symbols and cannot be used as part of container naming."); } for (CheContainer container : plugin.getContainers()) { if (container.getName() != null) { final String formattedContainerName = container.getName().toLowerCase(); checkValid( formattedContainerName, "Container name `%s` contains unacceptable symbols and cannot be used as part of container naming."); } } } }
Source:
<code>public void setVisible(boolean visible) { <START> _visible = visible; <END> }</code><technical_language>warn setVisible is implemented, setting effect (just setFocus)</technical_language>

Target:
public void setVisible(boolean visible) { System.out.println("warning: TextEditor::setVisible(boolean) not implemented (" + visible + ")"); visible = visible; }
Source:
<code>void saveScript() throws IOException { try ( BufferedWriter bw = Files.newBufferedWriter(file.toPath(), ExtensionScript.DEFAULT_CHARSET)) { bw.append(getContents()); } this.lastModified = file.lastModified(); <START> } <END></code><technical_language>update charset (to default)</technical_language>

Target:
void saveScript() throws IOException { this.charset = ExtensionScript.DEFAULT_CHARSET; try ( BufferedWriter bw = Files.newBufferedWriter(file.toPath(), charset)) { bw.append(getContents()); } this.lastModified = file.lastModified(); }
Source:
<code>private int buildMatrix(ProgressMonitor pm) throws IOException { matrix = new long[srcs.size() * dsts.size()]; long[] srcSizes = new long[srcs.size()]; long[] dstSizes = new long[dsts.size()]; Arrays.fill(srcSizes, -1); Arrays.fill(dstSizes, -1); int mNext = 0; for (int srcIdx = 0; srcIdx < srcs.size(); srcIdx++) { DiffEntry srcEnt = srcs.get(srcIdx); if (!isFile(srcEnt.oldMode)) { pm.update(dsts.size()); continue; } SimilarityIndex s = hash(srcEnt.oldId.toObjectId()); for (int dstIdx = 0; dstIdx < dsts.size(); dstIdx++) { DiffEntry dstEnt = dsts.get(dstIdx); if (!isFile(dstEnt.newMode)) { pm.update(1); continue; } if (!RenameDetector.sameType(srcEnt.oldMode, dstEnt.newMode)) { pm.update(1); continue; } long srcSize = srcSizes[srcIdx]; if (srcSize < 0) { srcSize = size(srcEnt.oldId.toObjectId()); srcSizes[srcIdx] = srcSize; } long dstSize = dstSizes[dstIdx]; if (dstSize < 0) { dstSize = size(dstEnt.newId.toObjectId()); dstSizes[dstIdx] = dstSize; } long max = Math.max(srcSize, dstSize); long min = Math.min(srcSize, dstSize); <START> if ((max * renameScore) / 100 > min) { <END> pm.update(1); continue; } SimilarityIndex d = hash(dstEnt.newId.toObjectId()); int score = s.score(d); if (score < renameScore) { pm.update(1); continue; } matrix[mNext++] = encode(score, srcIdx, dstIdx); pm.update(1); } } Arrays.sort(matrix, 0, mNext); return mNext; }</code><technical_language>I find this awkward phrase condition. talk common * 100 / max, do here? min * 100 / max < renameScore</technical_language>

Target:
private int buildMatrix(ProgressMonitor pm) throws IOException { matrix = new long[srcs.size() * dsts.size()]; long[] srcSizes = new long[srcs.size()]; long[] dstSizes = new long[dsts.size()]; Arrays.fill(srcSizes, -1); Arrays.fill(dstSizes, -1); int mNext = 0; for (int srcIdx = 0; srcIdx < srcs.size(); srcIdx++) { DiffEntry srcEnt = srcs.get(srcIdx); if (!isFile(srcEnt.oldMode)) { pm.update(dsts.size()); continue; } SimilarityIndex s = hash(srcEnt.oldId.toObjectId()); for (int dstIdx = 0; dstIdx < dsts.size(); dstIdx++) { DiffEntry dstEnt = dsts.get(dstIdx); if (!isFile(dstEnt.newMode)) { pm.update(1); continue; } if (!RenameDetector.sameType(srcEnt.oldMode, dstEnt.newMode)) { pm.update(1); continue; } long srcSize = srcSizes[srcIdx]; if (srcSize < 0) { srcSize = size(srcEnt.oldId.toObjectId()); srcSizes[srcIdx] = srcSize; } long dstSize = dstSizes[dstIdx]; if (dstSize < 0) { dstSize = size(dstEnt.newId.toObjectId()); dstSizes[dstIdx] = dstSize; } long max = Math.max(srcSize, dstSize); long min = Math.min(srcSize, dstSize); if (min * 100 / max < renameScore) { pm.update(1); continue; } SimilarityIndex d = hash(dstEnt.newId.toObjectId()); int score = s.score(d); if (score < renameScore) { pm.update(1); continue; } matrix[mNext++] = encode(score, srcIdx, dstIdx); pm.update(1); } } Arrays.sort(matrix, 0, mNext); return mNext; }
Source:
<code>public float getPrice() { <START> return pickupService ? type.getPrice() + 5 : type.getPrice(); <END> }</code><technical_language>ok. Lets a solution. Worst case: constant top of class</technical_language>

Target:
public float getPrice() { float finalPrice = type.getPrice(); finalPrice += pickupService ? TicketOptions.PICKUPSERVICE.getPrice() : 0; finalPrice += chMember ? TicketOptions.CHMEMBER.getPrice() : 0; return finalPrice; }
Source:
<code>public Field(String field) { if (field.startsWith(User.SCHEMA)) { fieldName = field.substring(User.SCHEMA.length() + 1).toLowerCase(Locale.ENGLISH); <START> <END> } else { fieldName = field.toLowerCase(Locale.ENGLISH); } queryField = UserQueryField.fromString(fieldName); if (queryField == null) { int lastIndexOfPeriod = field.lastIndexOf('.'); int lastIndexOfColon = field.lastIndexOf(':'); if (lastIndexOfPeriod > lastIndexOfColon) { splitString(field, lastIndexOfPeriod); LOG.warn( String.format("Period (.) used as field separator in %s. " + "This is not SCIM conform and deprecated!", field)); } else if (lastIndexOfColon > lastIndexOfPeriod) { splitString(field, lastIndexOfColon); } else { throw new IllegalArgumentException(String.format("Unable to parse field or extension from %s", field)); } } else { urn = User.SCHEMA; } }</code><technical_language>Remove this empty line</technical_language>

Target:
public Field(String field) { if (field.toLowerCase().startsWith(User.SCHEMA.toLowerCase())) { if (field.charAt(User.SCHEMA.length()) == '.') { throw new IllegalArgumentException(String.format("Period (.) is not a valid field separator: %s", field)); } name = field.substring(User.SCHEMA.length() + 1).toLowerCase(Locale.ENGLISH); } else { name = field.toLowerCase(Locale.ENGLISH); } queryField = UserQueryField.fromString(name); urn = User.SCHEMA; if (queryField == null) { int lastIndexOfPeriod = field.lastIndexOf('.'); int lastIndexOfColon = field.lastIndexOf(':'); if (lastIndexOfPeriod > lastIndexOfColon) { urn = field.substring(0, lastIndexOfPeriod); name = field.substring(lastIndexOfPeriod + 1); logger.warn( String.format("Period (.) used as field separator in %s. This is not SCIM conform and deprecated!", field)); } else if (lastIndexOfColon > lastIndexOfPeriod) { urn = field.substring(0, lastIndexOfColon); name = field.substring(lastIndexOfColon + 1); } else { throw new IllegalArgumentException(String.format("Unable to parse field or extension from %s", field)); } } }
Source:
<code>private static DoubleSummaryStats processContentTimestamps(List<Long> contentTimestamps) { requireNonNull(contentTimestamps, "contentTimestamps is null"); if (contentTimestamps.size() == 0) { return null; } DoubleSummaryStatistics statistics = new DoubleSummaryStatistics(); <START> if (contentTimestamps.size() == 1) { <END> statistics.accept(0); return new DoubleSummaryStats(statistics); } long previousTimestamp = contentTimestamps.get(0); for (int i = 1; i < contentTimestamps.size(); i++) { long timestamp = contentTimestamps.get(i); statistics.accept(NANOSECONDS.toMillis(timestamp - previousTimestamp)); previousTimestamp = timestamp; } return new DoubleSummaryStats(statistics); }</code><technical_language>happen if a negative duration due a bad nanoTime implementation (we this happen in past)</technical_language>

Target:
private static DoubleSummaryStats processContentTimestamps(List<Long> contentTimestamps) { requireNonNull(contentTimestamps, "contentTimestamps is null"); if (contentTimestamps.size() == 0 || contentTimestamps.size() == 1) { return null; } DoubleSummaryStatistics statistics = new DoubleSummaryStatistics(); long previousTimestamp = contentTimestamps.get(0); for (int i = 1; i < contentTimestamps.size(); i++) { long timestamp = contentTimestamps.get(i); statistics.accept(NANOSECONDS.toMillis(timestamp - previousTimestamp)); previousTimestamp = timestamp; } return new DoubleSummaryStats(statistics); }
Source:
<code>public boolean commit() throws LoginException { LOG.debug("hadoop login commit"); if (!subject.getPrincipals(User.class).isEmpty()) { LOG.debug("Using existing subject: {}", subject.getPrincipals()); return true; } Principal user = getCanonicalUser(KerberosPrincipal.class); if (user != null) { LOG.debug("Using kerberos user: {}", user); } if (!isSecurityEnabled() && (user == null)) { String envUser = System.getenv(HADOOP_USER_NAME); if (envUser == null) { envUser = System.getProperty(HADOOP_USER_NAME); } user = envUser == null ? null : new User(envUser); } if (user == null) { user = getCanonicalUser(OS_PRINCIPAL_CLASS); LOG.debug("Using local user: {}", user); } if (user != null) { LOG.debug("Using user: \"{}\" with name: {}", user, user.getName()); User userEntry = null; try { AuthenticationMethod authMethod = (user instanceof KerberosPrincipal) ? AuthenticationMethod.KERBEROS : AuthenticationMethod.SIMPLE; userEntry = new User(user.getName(), authMethod, null); } catch (Exception e) { throw (LoginException)(new LoginException(e.toString()).initCause(e)); } LOG.debug("User entry: \"{}\"", userEntry); subject.getPrincipals().add(userEntry); return true; } <START> LOG.error("Failed to find user name in " + subject); <END> throw new LoginException("Failed to find user in name"); }</code><technical_language>{}</technical_language>

Target:
public boolean commit() throws LoginException { LOG.debug("hadoop login commit"); if (!subject.getPrincipals(User.class).isEmpty()) { LOG.debug("Using existing subject: {}", subject.getPrincipals()); return true; } Principal user = getCanonicalUser(KerberosPrincipal.class); if (user != null) { LOG.debug("Using kerberos user: {}", user); } if (!isSecurityEnabled() && (user == null)) { String envUser = System.getenv(HADOOP_USER_NAME); if (envUser == null) { envUser = System.getProperty(HADOOP_USER_NAME); } user = envUser == null ? null : new User(envUser); } if (user == null) { user = getCanonicalUser(OS_PRINCIPAL_CLASS); LOG.debug("Using local user: {}", user); } if (user != null) { LOG.debug("Using user: \"{}\" with name: {}", user, user.getName()); User userEntry = null; try { AuthenticationMethod authMethod = (user instanceof KerberosPrincipal) ? AuthenticationMethod.KERBEROS : AuthenticationMethod.SIMPLE; userEntry = new User(user.getName(), authMethod, null); } catch (Exception e) { throw (LoginException)(new LoginException(e.toString()).initCause(e)); } LOG.debug("User entry: \"{}\"", userEntry); subject.getPrincipals().add(userEntry); return true; } throw new LoginException("Failed to find user in name " + subject); }
Source:
<code>public void lockInterruptibly() throws InterruptedException { boolean locked = false; if (this.delegate.isHeldByCurrentThread()) { locked = true; } this.delegate.lockInterruptibly(); if (locked) { return; } while (!locked) { try { locked = doLock(); } catch (Exception e) { this.delegate.unlock(); <START> throw e; <END> } } }</code><technical_language>Thank you, @dsyer , for contribution! afraid this fit current 4.3 GA dead line this Friday. switch 5.0 based Java 8 already, this issue :smile: :spring-integration-jdbc:compileJava/home/travis/build/spring-projects/spring-integration/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java:158: error: unreported exception Exception; caught declared thrown throw e; is a JIRA track: <LINK_0> if works for</technical_language>

Target:
public void lockInterruptibly() throws InterruptedException { boolean locked = false; if (this.delegate.isHeldByCurrentThread()) { locked = true; } this.delegate.lockInterruptibly(); if (locked) { return; } while (!locked) { try { locked = doLock(); } catch (TransactionTimedOutException e) { throw new InterruptedException("Transaction timed out"); } catch (DuplicateKeyException e) { throw new InterruptedException("Duplicate key"); } catch (RuntimeException e) { this.delegate.unlock(); throw e; } if (Thread.currentThread().isInterrupted()) { throw new InterruptedException(); } } }
Source:
<code>public void send(Send request) throws IOException { if (!connected) { throw new ClosedChannelException(); } while (!request.isSendComplete()) { request.writeTo(writeChannel); } <START> request.release(); <END> }</code><technical_language>releases request if IOException is thrown</technical_language>

Target:
public void send(Send request) throws IOException { try { if (!connected) { throw new ClosedChannelException(); } while (!request.isSendComplete()) { request.writeTo(writeChannel); } } finally { request.release(); } }
Source:
<code>public boolean syntaxErrorInProperties(Map<String, String> properties) { boolean error = false; if (properties != null && !properties.isEmpty()) { for (Map.Entry<String, String> e : properties.entrySet()) { String key = e.getKey(); if (key == null || !key.matches(KEY_REGEX)) { error = true; break; } if <START> (!Optional.ofNullable(e.getValue()).orElse("").matches(VALUE_REGEX)) <END> { error = true; break; } } } return error; }</code><technical_language>StringUtils::defaultString</technical_language>

Target:
public boolean syntaxErrorInProperties(Map<String, String> properties) { boolean error = false; if (properties != null && !properties.isEmpty()) { for (Map.Entry<String, String> e : properties.entrySet()) { String key = e.getKey(); if (key == null || !key.matches(KEY_REGEX)) { error = true; break; } if (!Objects.toString(e.getValue(), "").matches(VALUE_REGEX)) { error = true; break; } } } return error; }
Source:
<code>private Configuration getServiceConfiguration() { final Configuration groupCommServiceConf = groupCommDriver.getServiceConfiguration(); final Configuration outputServiceConf = outputService.getServiceConfiguration(); <START> final Configuration metricTrackerServiceConf = MetricsCollectionService.getServiceConfiguration(); <END> final Configuration emServiceConf = emConf.getServiceConfigurationWithoutNameResolver(); final Configuration traceConf = traceParameters.getConfiguration(); final Configuration metricsMessageServiceConf = MetricsMessageSender.getServiceConfiguration(); return Configurations.merge( userParameters.getServiceConf(), groupCommServiceConf, emServiceConf, metricTrackerServiceConf, outputServiceConf, traceConf, metricsMessageServiceConf); }</code><technical_language>variable name class name match</technical_language>

Target:
private Configuration getServiceConfiguration() { final Configuration groupCommServiceConf = groupCommDriver.getServiceConfiguration(); final Configuration outputServiceConf = outputService.getServiceConfiguration(); final Configuration metricCollectionServiceConf = MetricsCollectionService.getServiceConfiguration(); final Configuration emServiceConf = emConf.getServiceConfigurationWithoutNameResolver(); final Configuration traceConf = traceParameters.getConfiguration(); final Configuration metricsMessageServiceConf = MetricsMessageSender.getServiceConfiguration(); return Configurations.merge( userParameters.getServiceConf(), groupCommServiceConf, emServiceConf, metricCollectionServiceConf, outputServiceConf, traceConf, metricsMessageServiceConf); }
Source:
<code>public OffsetDateTime getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { <START> return (OffsetDateTime) cs.getObject(columnIndex); <END> }</code><technical_language>argument of getObject() instead of cast. suggestion return cs.getObject(columnIndex, OffsetDateTime.class);</technical_language>

Target:
public OffsetDateTime getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { return cs.getObject(columnIndex, OffsetDateTime.class); }
Source:
<code>public void setup() { log.info("Navigate to installation details"); new WorkbenchShell().maximize(); new ShellMenuItem(HELP_BUTTON, ABOUT_MENU_BUTTON).select(); DefaultStyledText dt = new DefaultStyledText(); String text = dt.getText(); int versionIndex = 0; jbossToolsVersion = text.substring(versionIndex = text.indexOf("Version:") + 9, text.indexOf("Build id", ++versionIndex)); log.info("JBossTools version: " + jbossToolsVersion); assertFalse("The JBossTools version value is empty!", jbossToolsVersion.isEmpty()); new PushButton(MODAL_DIALOG_ABOUT_DEVSTUDIO_INSTALLATION_DETAILS_BUTTON).click(); TabFolder tabFolder = new DefaultTabItem(MODAL_DIALOG_CONFIG_MENU_BUTTON).getTabFolder(); Optional<TabItem> configurationItem = tabFolder.getItems().stream() .filter(i -> i.getText().matches(MODAL_DIALOG_CONFIG_MENU_BUTTON)).findAny(); assertTrue("Tab item '" + MODAL_DIALOG_CONFIG_MENU_BUTTON + "' is missing", configurationItem.isPresent()); TabItem tabItem = configurationItem.get(); <START> tabItem.activate(); <END> new WaitWhile(new JobIsRunning(new RegexMatcher("Configuration Fetch Job"), true), TimePeriod.LONG); }</code><technical_language>add new DefaultShell(shelltitle) required shell is opened</technical_language>

Target:
public void setup() { log.info("Navigate to installation details"); WorkbenchShell ws = new WorkbenchShell(); ws.maximize(); if (RunningPlatform.isOSX()) { log.info("Open " + HELP_BUTTON + " -> " + ABOUT_MENU_BUTTON + "directly on Mac OSX"); Display.asyncExec(new Runnable() { @Override public void run() { @SuppressWarnings("restriction") AboutDialog dialog = new AboutDialog(ws.getSWTWidget()); dialog.open(); } }); } else { new ShellMenuItem(HELP_BUTTON, ABOUT_MENU_BUTTON).select(); } about = new DefaultShell(ABOUT_MENU_BUTTON); DefaultStyledText dt = new DefaultStyledText(); String text = dt.getText(); int versionIndex = 0; jbossToolsVersion = text.substring(versionIndex = text.indexOf("Version:") + 9, text.indexOf("Build id", ++versionIndex)); log.info("JBossTools version: " + jbossToolsVersion); assertFalse("The JBossTools version value is empty!", jbossToolsVersion.isEmpty()); new PushButton(MODAL_DIALOG_ABOUT_DEVSTUDIO_INSTALLATION_DETAILS_BUTTON).click(); installationDetails = new DefaultShell(MODAL_DIALOG_ABOUT_DEVSTUDIO_INSTALLATION_DETAILS_TITLE); TabFolder tabFolder = new DefaultTabItem(MODAL_DIALOG_CONFIG_MENU_BUTTON).getTabFolder(); Optional<TabItem> configurationItem = tabFolder.getItems().stream() .filter(i -> i.getText().matches(MODAL_DIALOG_CONFIG_MENU_BUTTON)).findAny(); assertTrue("Tab item '" + MODAL_DIALOG_CONFIG_MENU_BUTTON + "' is missing", configurationItem.isPresent()); TabItem tabItem = configurationItem.get(); tabItem.activate(); new WaitWhile(new JobIsRunning(new RegexMatcher("Configuration Fetch Job"), true), TimePeriod.LONG); }
Source:
<code>public AbstractSubTabAffinityLabelsView(SearchableDetailModelProvider<Label, M, T> modelProvider) { super(modelProvider); generateIds(); entitiesNameMap = <START> new HashMap<>(); <END> entitiesNameMap.putAll(getDetailModel().getEntitiesNameMap().getEntity()); getDetailModel().getEntitiesNameMap().getEntityChangedEvent().addListener((ev, sender, args) -> { entitiesNameMap.putAll(getDetailModel().getEntitiesNameMap().getEntity()); }); initTable(); initWidget(getTable()); }</code><technical_language>simply do this part of field declaration? Map<Guid, String> entitiesNameMap = new HashMap<>(); Also, consider if a field final. performance perspective, code readability perspective</technical_language>

Target:
public AbstractSubTabAffinityLabelsView(SearchableDetailModelProvider<Label, M, T> modelProvider) { super(modelProvider); generateIds(); updateEntitiesNameMap(); getDetailModel().getEntitiesNameMap().getEntityChangedEvent().addListener((ev, sender, args) -> { updateEntitiesNameMap(); }); initTable(); initWidget(getTable()); }
Source:
<code>public List<AuditMessage> getMessages(PerunSession perunSession, int count) throws InternalErrorException { try { return jdbc.query("select " + auditMessageMappingSelectQuery + " from (select " + auditMessageMappingSelectQuery + Compatibility.getRowNumberOver() + " from auditer_log ORDER BY id Desc limit ?) "+Compatibility.getAsAlias("temp"), <START> AUDIT_MESSAGE_MAPPER, count); <END> } catch (EmptyResultDataAccessException ex) { return new ArrayList<>(); } catch (RuntimeException err) { throw new InternalErrorException(err); } }</code><technical_language>I limit is supported oracle DB</technical_language>

Target:
public List<AuditMessage> getMessages(PerunSession perunSession, int count) throws InternalErrorException { try { return jdbc.query("select " + auditMessageMappingSelectQuery + " from (select " + auditMessageMappingSelectQuery + Compatibility.getRowNumberOver() + " from auditer_log ORDER BY id desc) "+Compatibility.getAsAlias("temp")+" where rownumber <= ?", AUDIT_MESSAGE_MAPPER, count); } catch (EmptyResultDataAccessException ex) { return new ArrayList<>(); } catch (RuntimeException err) { throw new InternalErrorException(err); } }
Source:
<code>private Player determinePlayer(Entity source) { if (source instanceof GlowTntPrimed) { return (Player)((GlowTntPrimed)source).getPlayer(); } <START> else if (source instanceof GlowPlayer) { <END> return (Player)source; } else if (source instanceof GlowWolf) { return (Player)((GlowWolf)source).getOwner(); } return null; }</code><technical_language>returning if-blocks, elses redundant omitted</technical_language>

Target:
private Player determinePlayer(Entity source) { if (source instanceof GlowTntPrimed) { return (Player)((GlowTntPrimed) source).getSource(); } if (source instanceof GlowPlayer) { return (Player) source; } if (source instanceof GlowWolf) { return (Player)((GlowWolf) source).getOwner(); } return null; }
Source:
<code>public void testApplicationFailsAsSoonAsOneJobFails() throws Throwable { final ConcurrentLinkedDeque<JobID> submittedJobIds = new ConcurrentLinkedDeque<>(); final TestingDispatcherGateway.Builder dispatcherBuilder = new TestingDispatcherGateway.Builder() .setSubmitFunction(jobGraph -> { submittedJobIds.add(jobGraph.getJobID()); return CompletableFuture.completedFuture(Acknowledge.get()); }) .setRequestJobStatusFunction(jobId -> { if (jobId.equals(submittedJobIds.peek())) { return CompletableFuture.completedFuture(JobStatus.FAILED); } return CompletableFuture.completedFuture(JobStatus.RUNNING); }) .setRequestJobResultFunction(jobId -> { if (jobId.equals(submittedJobIds.peek())) { return CompletableFuture.completedFuture(createFailedJobResult(jobId)); } return new CompletableFuture<>(); }); final CompletableFuture<Void> applicationFuture = runApplication(dispatcherBuilder, 2); <START> assertException(applicationFuture, ApplicationFailedException.class); <END> }</code><technical_language>fact this worked is indicator ApplicationDispatcherBootstrap class is a procedural style. change takes a DispatcherGateway for easy test implementations rethink it</technical_language>

Target:
public void testApplicationFailsAsSoonAsOneJobFails() throws Throwable { final ConcurrentLinkedDeque<JobID> submittedJobIds = new ConcurrentLinkedDeque<>(); final TestingDispatcherGateway.Builder dispatcherBuilder = new TestingDispatcherGateway.Builder() .setSubmitFunction(jobGraph -> { submittedJobIds.add(jobGraph.getJobID()); return CompletableFuture.completedFuture(Acknowledge.get()); }) .setRequestJobStatusFunction(jobId -> { if (jobId.equals(submittedJobIds.peek())) { return CompletableFuture.completedFuture(JobStatus.FAILED); } return CompletableFuture.completedFuture(JobStatus.RUNNING); }) .setRequestJobResultFunction(jobId -> { if (jobId.equals(submittedJobIds.peek())) { return CompletableFuture.completedFuture(createFailedJobResult(jobId)); } return new CompletableFuture<>(); }); final CompletableFuture<Void> applicationFuture = runApplication(dispatcherBuilder, 2); final ApplicationFailureException exception = assertException(applicationFuture, ApplicationFailureException.class); assertEquals(exception.getStatus(), ApplicationStatus.FAILED); }
Source:
<code>public void tearDown() throws Exception { clearCatalogAndWait(); configureRestForGuest(); urlResourceReaderConfigurator.setUrlResourceReaderRootDirs( DEFAULT_URL_RESOURCE_READER_ROOT_RESOURCE_DIRS); for (String resource : resourcesToDelete) { FileUtils.deleteQuietly(new File(resource)); } resourcesToDelete.clear(); cswServer.stop(); getSecurityPolicy().configureRestForGuest(); if (server != null) { server.stop(); } <START> } <END></code><technical_language>remove tests TestCatalog</technical_language>

Target:
public void tearDown() throws Exception { clearCatalogAndWait(); configureRestForGuest(); urlResourceReaderConfigurator.setUrlResourceReaderRootDirs( DEFAULT_URL_RESOURCE_READER_ROOT_RESOURCE_DIRS); for (String resource : resourcesToDelete) { FileUtils.deleteQuietly(new File(resource)); } resourcesToDelete.clear(); cswServer.stop(); if (server != null) { server.stop(); } }
Source:
<code>public void checkClientTrusted(X509Certificate[] certificates, String authType) throws CertificateException { if (certificates != null) { if (LOGGER.isDebugEnabled()) { <START> for (int c = 0; c < certificates.length; c++) { <END> X509Certificate cert = certificates[c]; LOGGER.debug(" Client certificate " + (c + 1) + ":"); LOGGER.debug(" Subject DN: " + cert.getSubjectDN()); LOGGER.debug(" Signature Algorithm: " + cert.getSigAlgName()); LOGGER.debug(" Valid from: " + cert.getNotBefore()); LOGGER.debug(" Valid until: " + cert.getNotAfter()); LOGGER.debug(" Issuer: " + cert.getIssuerDN()); } } defaultTrustManager.checkClientTrusted(certificates, authType); } }</code><technical_language>While here, this replaced a foreach (and below)</technical_language>

Target:
public void checkClientTrusted(X509Certificate[] certificates, String authType) throws CertificateException { if (certificates != null) { if (LOGGER.isDebugEnabled()) { debugLogCertificates("Client", certificates); } defaultTrustManager.checkClientTrusted(certificates, authType); } }
Source:
<code>private void updatePath() { mPath.reset(); mBorderPath.reset(); mTempRectangle.set(getBounds()); switch (mType){ case CLIPPING: mTempRectangle.inset(mPadding, mPadding); if (mIsCircle) { mPath.addCircle( mTempRectangle.centerX(), mTempRectangle.centerY(), Math.min(mTempRectangle.width(), mTempRectangle.height()) / 2, Path.Direction.CW); } else { mPath.addRoundRect(mTempRectangle, mRadii, Path.Direction.CW); } mTempRectangle.inset(-mPadding, -mPadding); break; case OVERLAY_COLOR: mTempRectangle.inset(mPadding, mPadding); if (mIsCircle) { mPath.addCircle( mTempRectangle.centerX(), mTempRectangle.centerY(), Math.min(mTempRectangle.width(), mTempRectangle.height()) / 2, Path.Direction.CW); } else { mPath.addRoundRect(mTempRectangle, mRadii, Path.Direction.CW); } mTempRectangle.inset(-mPadding, -mPadding); break; } <START> <END> mTempRectangle.inset(mBorderWidth/2, mBorderWidth/2); if (mIsCircle) { mBorderPath.addCircle( mTempRectangle.centerX(), mTempRectangle.centerY(), Math.min(mTempRectangle.width(), mTempRectangle.height())/2, Path.Direction.CW); } else { mBorderRadii[0] = mBorderRadii[1] = mRadii[0] + mPadding - mBorderWidth/2; mBorderRadii[2] = mBorderRadii[3] = mRadii[2] + mPadding - mBorderWidth/2; mBorderRadii[4] = mBorderRadii[5] = mRadii[4] + mPadding - mBorderWidth/2; mBorderRadii[6] = mBorderRadii[7] = mRadii[6] + mPadding - mBorderWidth/2; mBorderPath.addRoundRect(mTempRectangle, mBorderRadii, Path.Direction.CW); } mTempRectangle.inset(-mBorderWidth/2, -mBorderWidth/2); }</code><technical_language>This logic is in cases, remove switch statement do this once</technical_language>

Target:
private void updatePath() { mPath.reset(); mBorderPath.reset(); mTempRectangle.set(getBounds()); mTempRectangle.inset(mPadding, mPadding); if (mIsCircle) { mPath.addCircle( mTempRectangle.centerX(), mTempRectangle.centerY(), Math.min(mTempRectangle.width(), mTempRectangle.height())/2, Path.Direction.CW); } else { mPath.addRoundRect(mTempRectangle, mRadii, Path.Direction.CW); } mTempRectangle.inset(-mPadding, -mPadding); mTempRectangle.inset(mBorderWidth/2, mBorderWidth/2); if (mIsCircle) { float radius = Math.min(mTempRectangle.width(), mTempRectangle.height())/2; mBorderPath.addCircle(mTempRectangle.centerX(), mTempRectangle.centerY(), radius, Path.Direction.CW); } else { for (int i = 0; i < mBorderRadii.length; i++) { mBorderRadii[i] = mRadii[i] + mPadding - mBorderWidth/2; } mBorderPath.addRoundRect(mTempRectangle, mBorderRadii, Path.Direction.CW); } mTempRectangle.inset(-mBorderWidth/2, -mBorderWidth/2); }
Source:
<code>public boolean equals(Object obj) { if (this == obj) { return true; } <START> if (obj == null) { <END> return false; } if (getClass() != obj.getClass()) { return false; } I18nMap other = (I18nMap) obj; return values.equals(other.values); }</code><technical_language>Objects.equals() handle nulls concisely</technical_language>

Target:
public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof I18nMap) { I18nMap other = (I18nMap) obj; return Objects.equals(values, other.values); } return false; }
Source:
<code>public void getFieldTest() { assertNotNull(getField(Person.class, "firstName")); <START> assertNotNull(getField(SubPerson.class, "firstName")); <END> Assertions.assertThatThrownBy(() -> getField(Person.class, "notExistingField")) .isInstanceOf(ScenarioException.class) .hasMessageStartingWith("Impossible to find field with name "); }</code><technical_language>please add assertion assertNotNull(getField(SubPerson.class, "additionalField"));</technical_language>

Target:
public void getFieldTest() { assertNotNull(getField(Person.class, "firstName")); assertNotNull(getField(SubPerson.class, "firstName")); assertNotNull(getField(SubPerson.class, "additionalField")); Assertions.assertThatThrownBy(() -> getField(Person.class, "notExistingField")) .isInstanceOf(ScenarioException.class) .hasMessageStartingWith("Impossible to find field with name "); }
Source:
<code>public void outEvent() { assert (!ioError); if (outsize == 0) { if (encoder == null) { assert (handshaking); return; } outpos.set(null); outsize = encoder.encode(outpos, 0); <START> final int outBatchSize = options.sndbuf > Config.OUT_BATCH_SIZE.getValue() ? options.sndbuf : Config.OUT_BATCH_SIZE.getValue(); <END> while (outsize < outBatchSize) { Msg msg = nextMsg.get(); if (msg == null) { break; } encoder.loadMsg(msg); int n = encoder.encode(outpos, outBatchSize - outsize); assert (n > 0); outsize += n; } if (outsize == 0) { outputStopped = true; ioObject.resetPollOut(handle); return; } encoder.encoded(); } int nbytes = write(outpos.get()); if (nbytes == -1) { ioObject.resetPollOut(handle); return; } outsize -= nbytes; if (handshaking) { if (outsize == 0) { ioObject.resetPollOut(handle); } } }</code><technical_language>deal re: Math.max</technical_language>

Target:
public void outEvent() { assert (!ioError); if (outsize == 0) { if (encoder == null) { assert (handshaking); return; } outpos.set(null); outsize = encoder.encode(outpos, 0); final int outBatchSize = Math.max(options.sndbuf, Config.OUT_BATCH_SIZE.getValue()); while (outsize < outBatchSize) { Msg msg = nextMsg.get(); if (msg == null) { break; } encoder.loadMsg(msg); int n = encoder.encode(outpos, outBatchSize - outsize); assert (n > 0); outsize += n; } if (outsize == 0) { outputStopped = true; ioObject.resetPollOut(handle); return; } encoder.encoded(); } int nbytes = write(outpos.get()); if (nbytes == -1) { ioObject.resetPollOut(handle); return; } outsize -= nbytes; if (handshaking) { if (outsize == 0) { ioObject.resetPollOut(handle); } } }
Source:
<code>public void init() { super.init(); connectSensors(); <START> this.addTag(String.format("ibm.mms.tenant.entity:%s", getConfig(BrooklynNode.MANAGEMENT_USER))); <END> getMutableEntityType().addEffector(Effectors.effector(Startable.STOP).impl(new StopAndExpungeEffector()).build()); }</code><technical_language>MMS specific code in generic Brooklyn</technical_language>

Target:
public void init() { super.init(); connectSensors(); }