auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static void flush(boolean expectRemoval, ControlledScatteredVersionManager... svms) { int[] regularCounters = new int[svms.length]; int[] removeCounters = new int[svms.length]; for (int i = 0; i < svms.length; ++i) { regularCounters[i] = svms[i].regularCounter.get(); removeCounters[i] = svms[i].removeCounter.get(); if (!svms[i].startFlush()) { regularCounters[i] = Integer.MIN_VALUE; removeCounters[i] = Integer.MIN_VALUE; } } for (;;) { boolean done = true; for (int i = 0; i < svms.length; ++i) { <START> if (regularCounters[i] >= svms[i].regularCounter.get()) { <END> log.tracef("SVM %d had %d regular invalidations, now has %d", i, regularCounters[i], svms[i].regularCounter.get()); done = false; } if (expectRemoval && removeCounters[i] >= svms[i].removeCounter.get()) { log.tracef("SVM %d had %d remove invalidations, now has %d", i, removeCounters[i], svms[i].removeCounter.get()); done = false; } } if (done) break; LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(10)); } }</code><technical_language>put svms[i].regularCounter.get() a field variable? removeCounter below? cases standard</technical_language>

Target:
public static void flush(boolean expectRemoval, ControlledScatteredVersionManager... svms) { int[] regularCounters = new int[svms.length]; int[] removeCounters = new int[svms.length]; for (int i = 0; i < svms.length; ++i) { regularCounters[i] = svms[i].regularCounter.get(); removeCounters[i] = svms[i].removeCounter.get(); if (!svms[i].startFlush()) { regularCounters[i] = Integer.MIN_VALUE; removeCounters[i] = Integer.MIN_VALUE; } } for (;;) { boolean done = true; for (int i = 0; i < svms.length; ++i) { int svmRegularCounters = svms[i].regularCounter.get(); int svmRemoveCounters = svms[i].removeCounter.get(); if (regularCounters[i] >= svmRegularCounters) { log.tracef("SVM %d had %d regular invalidations, now has %d", i, regularCounters[i], svmRegularCounters); done = false; } if (expectRemoval && removeCounters[i] >= svmRemoveCounters) { log.tracef("SVM %d had %d remove invalidations, now has %d", i, removeCounters[i], svmRemoveCounters); done = false; } } if (done) break; LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(10)); } }
Source:
<code>public Map<String, IndexStats> getIndicesStats() { final Request request = new Request("GET", "/_stats"); final Map<String, Object> jsonMap = performLowLevelRequest(request); <START> Map<String, IndexStats> indexStatsMap = new HashMap<>(); <END> final Map<String, Object> indices = (Map<String, Object>)jsonMap.get("indices"); indices.forEach((key, value)-> { Map<String, Object> indexStats = (Map<String, Object>) ((Map<String, Object>) indices.get(key)).get("primaries"); int numOfDocs = (int) ((Map<String, Object>) indexStats.get("docs")) .get("count"); int sizeInBytes = (int) ((Map<String, Object>) indexStats.get("store")) .get("size_in_bytes"); indexStatsMap.put(key, new IndexStats(key, numOfDocs, sizeInBytes)); }); return indexStatsMap; }</code><technical_language>![Codacy](<LINK_0> Issue found: [Local variable 'indexStatsMap' declared final](<LINK_1></technical_language>

Target:
public Map<String, IndexStats> getIndicesStats() { final Request request = new Request("GET", "/_stats"); final Map<String, Object> jsonMap = performLowLevelRequest(request); Map<String, IndexStats> indexStatsMap = new HashMap<>(); final Map<String, Object> indices = (Map<String, Object>)jsonMap.get("indices"); indices.forEach((key, value)-> { if (hasClusterPrefix(key)) { final Map<String, Object> indexStats = (Map<String, Object>) ((Map<String, Object>) indices.get(key)).get("primaries"); int numOfDocs = (int) ((Map<String, Object>) indexStats.get("docs")) .get("count"); int sizeInBytes = (int) ((Map<String, Object>) indexStats.get("store")) .get("size_in_bytes"); final String indexNameWithoutPrefix = removeClusterIdFromName(key); indexStatsMap.put(indexNameWithoutPrefix, new IndexStats(indexNameWithoutPrefix, numOfDocs, sizeInBytes)); } }); return indexStatsMap; }
Source:
<code>public void shouldRegisterActionContribution() { assertNotNull(directoryTreeService); assertTrue(directoryTreeService.getDirectoryTrees().contains("anyNavigation")); <START> ActionService actionService = (ActionService) Framework.getService(ActionManager.class); <END> assertNotNull(actionService); Action action = actionService.getAction(DirectoryTreeDescriptor.ACTION_ID_PREFIX + "anyNavigation"); assertNotNull(action); }</code><technical_language>injecting ActionService directly</technical_language>

Target:
public void shouldRegisterActionContribution() { assertNotNull(directoryTreeService); assertNotNull(actionService); assertTrue(directoryTreeService.getDirectoryTrees().contains("anyNavigation")); Action action = actionService.getAction(DirectoryTreeDescriptor.ACTION_ID_PREFIX + "anyNavigation"); assertNotNull(action); }
Source:
<code>public Response getVendor(@PathParam(PurapPropertyConstants.VENDOR_NUMBER) String vendorNumber, @Context HttpHeaders headers) { try { HashMap<String, String> vendorCombinedPk = parseVendorNumber(vendorNumber); VendorDetail vendorDetail = getLookupDao().findObjectByMap(VendorDetail.class.newInstance(), vendorCombinedPk); <START> if (vendorDetail == null) { <END> return respondNotFound(); } String responseBody = gson.toJson(getVendorProperties(vendorDetail)); return Response.ok(responseBody).build(); } catch (BadRequestException ex) { return respondGetVendorBadRequest(); } catch (Exception ex) { LOG.error(ex); return respondInternalServerError(ex); } }</code><technical_language>want ObjectUtils for this null check</technical_language>

Target:
public Response getVendor(@PathParam(PurapPropertyConstants.VENDOR_NUMBER) String vendorNumber, @Context HttpHeaders headers) { try { HashMap<String, String> vendorCombinedPk = parseVendorNumber(vendorNumber); VendorDetail vendorDetail = getLookupDao().findObjectByMap(VendorDetail.class.newInstance(), vendorCombinedPk); if (ObjectUtils.isNull(vendorDetail)) { return respondNotFound(); } String responseBody = gson.toJson(getVendorProperties(vendorDetail)); return Response.ok(responseBody).build(); } catch (BadRequestException ex) { return respondGetVendorBadRequest(); } catch (Exception ex) { LOG.error(ex); return respondInternalServerError(ex); } }
Source:
<code>protected IStructuredSelection getStructuredSelection(StructuredViewer viewer) throws ClassCastException { ISelection selection = viewer.getSelection(); if (selection instanceof IStructuredSelection) { return (IStructuredSelection) selection; } throw new <START> ClassCastException("StructuredViewer should return an instance of IStructuredSelection from its getSelection() method."); <END> }</code><technical_language>Set message in plugin.properties key in org.eclipse.eef.ide.ui.internal.Messages</technical_language>

Target:
protected IStructuredSelection getStructuredSelection(StructuredViewer viewer) throws ClassCastException { ISelection selection = viewer.getSelection(); if (selection instanceof IStructuredSelection) { return (IStructuredSelection) selection; } throw new ClassCastException(Messages.AbstractEEFWidgetLifecycleManager_invalidSelectionType); }
Source:
<code>private static ValueMatcher makeDictionaryEncodedValueMatcherGeneric( final DimensionSelector selector, Predicate<String> predicate ) { <START> final BitSet checkedIds = new BitSet(selector.getValueCardinality()); <END> final BitSet matchingIds = new BitSet(selector.getValueCardinality()); final boolean matchNull = predicate.apply(null); return new ValueMatcher() { @Override public boolean matches() { final IndexedInts row = selector.getRow(); final int size = row.size(); if (size == 0) { return matchNull; } else { for (int i = 0; i < size; ++i) { final int id = row.get(i); final boolean matches; if (checkedIds.get(id)) { matches = matchingIds.get(id); } else { matches = predicate.apply(selector.lookupName(id)); checkedIds.set(id); matchingIds.set(id, matches); } if (matches) { return true; } } return false; } } @Override public void inspectRuntimeShape(RuntimeShapeInspector inspector) { inspector.visit("selector", selector); } }; }</code><technical_language>bitset (with two-bit "blocks") separate bitsets, for locality. Also, in future replaced specialized class fetches writes bits a time, in order ops in hot loop</technical_language>

Target:
private static ValueMatcher makeDictionaryEncodedValueMatcherGeneric( final DimensionSelector selector, Predicate<String> predicate ) { final BitSet checkedIds = new BitSet(selector.getValueCardinality()); final BitSet matchingIds = new BitSet(selector.getValueCardinality()); final boolean matchNull = predicate.apply(null); return new ValueMatcher() { @Override public boolean matches() { final IndexedInts row = selector.getRow(); final int size = row.size(); if (size == 0) { return matchNull; } else { for (int i = 0; i < size; ++i) { final int id = row.get(i); final boolean matches; if (checkedIds.get(id)) { matches = matchingIds.get(id); } else { matches = predicate.apply(selector.lookupName(id)); checkedIds.set(id); if (matches) { matchingIds.set(id); } } if (matches) { return true; } } return false; } } @Override public void inspectRuntimeShape(RuntimeShapeInspector inspector) { inspector.visit("selector", selector); } }; }
Source:
<code>private Collection<MediaType> getAcceptedMediaTypes(Module module) { Collection<?> acceptedTypes = module.getComponent(MEDIA_TYPE_BEAN_NAME, Collection.class); if (CollectionUtils.isEmpty(acceptedTypes)) { return DEFAULT_ACCEPTED_MEDIA_TYPES; } else { Collection<MediaType> acceptedMediaTypes = new ArrayList<MediaType>(acceptedTypes.size()); for (Object acceptedType: acceptedTypes) { <START> if (acceptedType instanceof String) { <END> acceptedMediaTypes.add(MediaType.parseMediaType((String) acceptedType)); } } return Collections.unmodifiableCollection(acceptedMediaTypes); } }</code><technical_language>accept actual MediaType instances here</technical_language>

Target:
private Collection<MediaType> getAcceptedMediaTypes(Module module) { Collection<?> acceptedTypes = module.getComponent(MEDIA_TYPE_BEAN_NAME, Collection.class); if (CollectionUtils.isEmpty(acceptedTypes)) { return DEFAULT_ACCEPTED_MEDIA_TYPES; } else { Collection<MediaType> acceptedMediaTypes = new ArrayList<MediaType>(acceptedTypes.size()); for (Object acceptedType: acceptedTypes) { if (acceptedType instanceof String) { acceptedMediaTypes.add(MediaType.parseMediaType((String) acceptedType)); } else if (acceptedType instanceof MediaType) { acceptedMediaTypes.add((MediaType) acceptedType); } } return Collections.unmodifiableCollection(acceptedMediaTypes); } }
Source:
<code><START> public String resolve(String originalHost) { <END> String currentHost = originalHost; if (isLocalOrIp(currentHost)) { return originalHost; } try { String targetHost = null; do { Attributes attrs = getDirContext().getAttributes(currentHost, new String[]{A_RECORD_TYPE, CNAME_RECORD_TYPE}); Attribute attr = attrs.get(A_RECORD_TYPE); if (attr != null) { targetHost = attr.get().toString(); } attr = attrs.get(CNAME_RECORD_TYPE); if (attr != null) { currentHost = attr.get().toString(); } else { targetHost = currentHost; } } while (targetHost == null); return targetHost; } catch (Exception e) { logger.warn("Cannot resolve eureka server address {}; returning original value {}", currentHost, originalHost, e); return originalHost; } }</code><technical_language>DnsResolver written a utility class static methods. This PR changes implementation detail of this class need instantiate DnsResolver directly. Also, concerned making breaking changes public methods. PR greatly simplified if static change reverted</technical_language>

Target:
public static String resolve(String originalHost) { String currentHost = originalHost; if (isLocalOrIp(currentHost)) { return originalHost; } try { String targetHost = null; do { Attributes attrs = getDirContext().getAttributes(currentHost, new String[]{A_RECORD_TYPE, CNAME_RECORD_TYPE}); Attribute attr = attrs.get(A_RECORD_TYPE); if (attr != null) { targetHost = attr.get().toString(); } attr = attrs.get(CNAME_RECORD_TYPE); if (attr != null) { currentHost = attr.get().toString(); } else { targetHost = currentHost; } } while (targetHost == null); return targetHost; } catch (NamingException e) { logger.warn("Cannot resolve eureka server address {}; returning original value {}", currentHost, originalHost, e); return originalHost; } }
Source:
<code>private Object[][] validHeadersProvider() { return new Object[][] { {"token123", "token123"}, {"bearer token123", "token123"}, <START> {"bearer token123", "token123"}, <END> }; }</code><technical_language>this is valid</technical_language>

Target:
private Object[][] validHeadersProvider() { return new Object[][] { {"token123", "token123"}, {"bearer token123", "token123"}, {"Bearer token123", "token123"}, }; }
Source:
<code>private Object handleJoinPoint(ProceedingJoinPoint proceedingJoinPoint, io.github.resilience4j.ratelimiter.RateLimiter rateLimiter, String methodName) throws Throwable { try { <START> io.github.resilience4j.ratelimiter.RateLimiter.waitForPermission(rateLimiter); <END> return proceedingJoinPoint.proceed(); } catch (Exception exception) { if (logger.isDebugEnabled()) { logger.debug("Invocation of method '" + methodName + "' failed!", exception); } throw exception; } }</code><technical_language>add a rateLimiter.executeCheckedSupplier default <T> T executeCheckedSupplier(CheckedFunction0<T> checkedSupplier) throws Throwable { return decorateCheckedSupplier(this, checkedSupplier).apply(); } rateLimiter.executeCheckedSupplier(proceedingJoinPoint::proceed)</technical_language>

Target:
private Object handleJoinPoint(ProceedingJoinPoint proceedingJoinPoint, io.github.resilience4j.ratelimiter.RateLimiter rateLimiter, String methodName) throws Throwable { if (logger.isDebugEnabled()) { logger.debug("Rate limiter invocation for method ", methodName); } return rateLimiter.executeCheckedSupplier(proceedingJoinPoint::proceed); }
Source:
<code>private void runFafReplayFile(Path path) throws IOException { byte[] rawReplayBytes = replayFileReader.readRawReplayData(path); Path tempSupComReplayFile = preferencesService.getCacheDirectory().resolve(TEMP_SCFA_REPLAY_FILE_NAME); createDirectories(tempSupComReplayFile.getParent()); Files.copy(new ByteArrayInputStream(rawReplayBytes), tempSupComReplayFile, StandardCopyOption.REPLACE_EXISTING); LocalReplayInfo replayInfo = replayFileReader.parseMetaData(path); String gameType = replayInfo.getFeaturedMod(); Integer replayId = replayInfo.getUid(); Map<String, Integer> modVersions = replayInfo.getFeaturedModVersions(); String mapName = replayInfo.getMapname(); if (gameType.equals("coop")) <START> mapName = parseCoopMapName(rawReplayBytes); <END> Set<String> simMods = replayInfo.getSimMods() != null ? replayInfo.getSimMods().keySet() : emptySet(); Integer version = parseSupComVersion(rawReplayBytes); gameService.runWithReplay(tempSupComReplayFile, replayId, gameType, version, modVersions, simMods, mapName); }</code><technical_language>IS AWESOME. do for generated maps pls? map is null aswell due ID in db</technical_language>

Target:
private void runFafReplayFile(Path path) throws IOException { byte[] rawReplayBytes = replayFileReader.readRawReplayData(path); Path tempSupComReplayFile = preferencesService.getCacheDirectory().resolve(TEMP_SCFA_REPLAY_FILE_NAME); createDirectories(tempSupComReplayFile.getParent()); Files.copy(new ByteArrayInputStream(rawReplayBytes), tempSupComReplayFile, StandardCopyOption.REPLACE_EXISTING); LocalReplayInfo replayInfo = replayFileReader.parseMetaData(path); String gameType = replayInfo.getFeaturedMod(); Integer replayId = replayInfo.getUid(); Map<String, Integer> modVersions = replayInfo.getFeaturedModVersions(); String mapName = replayInfo.getMapname(); if (StringUtils.isEmptyOrNull(mapName)) { mapName = parseMapFolderName(rawReplayBytes); } Set<String> simMods = replayInfo.getSimMods() != null ? replayInfo.getSimMods().keySet() : emptySet(); Integer version = parseSupComVersion(rawReplayBytes); gameService.runWithReplay(tempSupComReplayFile, replayId, gameType, version, modVersions, simMods, mapName); }
Source:
<code>private void readDecimal( int total, DecimalColumnVector c, int rowId) throws IOException { int left = total; c.precision = (short) type.asPrimitiveType().getDecimalMetadata().getPrecision(); c.scale = (short) type.asPrimitiveType().getDecimalMetadata().getScale(); while (left > 0) { consume(); readRepetitionAndDefinitionLevels(); if (definitionLevel >= maxDefLevel) { <START> c.vector[rowId] = new HiveDecimalWritable(dataColumn.readBytes().getBytesUnsafe(), <END> type.asPrimitiveType().getDecimalMetadata().getScale()); c.isNull[rowId] = false; c.isRepeating = c.isRepeating && (c.vector[0] == c.vector[rowId]); } else { c.isNull[rowId] = true; c.isRepeating = false; c.noNulls = false; } rowId++; left--; } }</code><technical_language>Init a new HiveDecimalWritable for row sound good, especially in this hot path. reuse objects? Also, need call getScale again</technical_language>

Target:
private void readDecimal( int total, DecimalColumnVector c, int rowId) throws IOException { int left = total; c.precision = (short) type.asPrimitiveType().getDecimalMetadata().getPrecision(); c.scale = (short) type.asPrimitiveType().getDecimalMetadata().getScale(); while (left > 0) { readRepetitionAndDefinitionLevels(); if (definitionLevel >= maxDefLevel) { c.vector[rowId].set(dataColumn.readBytes().getBytesUnsafe(), c.scale); c.isNull[rowId] = false; c.isRepeating = c.isRepeating && (c.vector[0] == c.vector[rowId]); } else { c.isNull[rowId] = true; c.isRepeating = false; c.noNulls = false; } rowId++; left--; } }
Source:
<code>public static org.kframework.definition.Definition from(String definitionText, String mainModuleName, Source source, List<File> lookupDirectories) throws IOException { File tmpDir = Files.createTempDir(); File tempDir = new File(tmpDir.getAbsolutePath() + File.pathSeparator + "tempDir"); File definitionDir = new File(tmpDir.getAbsolutePath() + File.pathSeparator + "definitionDir"); File workingDir = new File(tmpDir.getAbsolutePath() + File.pathSeparator + "workingDir"); <START> File kompiledDir = new File(tmpDir.getAbsolutePath() + File.pathSeparator + "kompiledDir"); <END> if(!tempDir.mkdir() || !definitionDir.mkdir() || !workingDir.mkdir() || !kompiledDir.mkdir()) { throw new AssertionError("Could not create one of the temporary directories"); } GlobalOptions globalOptions = new GlobalOptions(); KExceptionManager kem = new KExceptionManager(globalOptions); FileUtil fileUtil = new FileUtil(tempDir, Providers.of(definitionDir), workingDir, Providers.of(kompiledDir), globalOptions, System.getenv()); ParserUtils parserUtils = new ParserUtils(fileUtil::resolveWorkingDirectory, kem, globalOptions); org.kframework.definition.Definition definition = parserUtils.loadDefinition( mainModuleName, mainModuleName, definitionText, source, workingDir, lookupDirectories, true, false ); return definition; }</code><technical_language>tmpDir tempDir. names of variables important for code readability. tempDirBase</technical_language>

Target:
public static org.kframework.definition.Definition from(String definitionText, String mainModuleName, Source source, List<File> lookupDirectories) { File tempDir = Files.createTempDir(); File theFileUtilTempDir = new File(tempDir.getAbsolutePath() + File.pathSeparator + "tempDir"); File definitionDir = new File(tempDir.getAbsolutePath() + File.pathSeparator + "definitionDir"); File workingDir = new File(tempDir.getAbsolutePath() + File.pathSeparator + "workingDir"); File kompiledDir = new File(tempDir.getAbsolutePath() + File.pathSeparator + "kompiledDir"); if(!theFileUtilTempDir.mkdir() || !definitionDir.mkdir() || !workingDir.mkdir() || !kompiledDir.mkdir()) { throw new AssertionError("Could not create one of the temporary directories"); } GlobalOptions globalOptions = new GlobalOptions(); KExceptionManager kem = new KExceptionManager(globalOptions); FileUtil fileUtil = new FileUtil(theFileUtilTempDir, Providers.of(definitionDir), workingDir, Providers.of(kompiledDir), globalOptions, System.getenv()); ParserUtils parserUtils = new ParserUtils(fileUtil::resolveWorkingDirectory, kem, globalOptions); org.kframework.definition.Definition definition = parserUtils.loadDefinition( mainModuleName, mainModuleName, definitionText, source, workingDir, lookupDirectories, true, false ); return definition; }
Source:
<code>public void scheduleInitial(SourceScheduler scheduler) { checkState(!initialScheduled); initialScheduled = true; int driverGroupsScheduledPerTask = 0; <START> while (!driverGroupQueue.isEmpty()) { <END> for (int i = 0; i < nodeByTaskId.size() && !driverGroupQueue.isEmpty(); i++) { int driverGroupId = driverGroupQueue.dequeueInt(); checkState(!bucketNodeMap.getAssignedNode(driverGroupId).isPresent()); bucketNodeMap.assignOrUpdateBucketToNode(driverGroupId, nodeByTaskId.get(i)); scheduler.startLifespan(Lifespan.driverGroup(driverGroupId), partitionHandles.get(driverGroupId)); taskByDriverGroup[driverGroupId] = i; runningDriverGroupIdsByTask[i].add(driverGroupId); } driverGroupsScheduledPerTask++; if (concurrentLifespansPerTask.isPresent() && driverGroupsScheduledPerTask == concurrentLifespansPerTask.getAsInt()) { break; } } }</code><technical_language>/ question: i this method is synchronized, other methods are? For pure safety purposes i synchronized</technical_language>

Target:
public void scheduleInitial(SourceScheduler scheduler) { checkState(!initialScheduled, "Initial scheduling happened before scheduleInitial is called"); int driverGroupsScheduledPerTask = 0; synchronized (this) { while (!driverGroupQueue.isEmpty()) { for (int i = 0; i < nodeByTaskId.size() && !driverGroupQueue.isEmpty(); i++) { int driverGroupId = driverGroupQueue.dequeueInt(); checkState(!bucketNodeMap.getAssignedNode(driverGroupId).isPresent()); bucketNodeMap.assignOrUpdateBucketToNode(driverGroupId, nodeByTaskId.get(i)); scheduler.startLifespan(Lifespan.driverGroup(driverGroupId), partitionHandles.get(driverGroupId)); taskByDriverGroup[driverGroupId] = i; runningDriverGroupIdsByTask[i].add(driverGroupId); } driverGroupsScheduledPerTask++; if (concurrentLifespansPerTask.isPresent() && driverGroupsScheduledPerTask == concurrentLifespansPerTask.getAsInt()) { break; } } initialScheduled = true; } }
Source:
<code>private void setTextViewTypefaceToCurrentFont(TextView textView, int textStyle) { if (textStyle < 0 || textStyle > 3) { textStyle = textView.getTypeface() == null ? Typeface.NORMAL : textView.getTypeface().getStyle(); } if (currentFont != null) textView.setTypeface(currentFont, textStyle); else <START> Timber.e("currentFont is null"); <END> }</code><technical_language>Timber.w plx</technical_language>

Target:
private void setTextViewTypefaceToCurrentFont(TextView textView, int textStyle) { if (!isValidTextStyle(textStyle)) { textStyle = textView.getTypeface() != null ? textView.getTypeface().getStyle() : Typeface.NORMAL; } if (currentFont != null) textView.setTypeface(currentFont, textStyle); else Timber.w("Couldn't set typeface as currentFont is null"); }
Source:
<code>public boolean matches(Method method) throws SignatureMismatchException { if (skipMethod(method)) { return false; } Collection<SignatureMismatch> mismatches = match(method); boolean hasErrors = mismatches.stream() .anyMatch(mismatch -> ERROR == mismatch.getSeverity()); List<SignatureMismatch> warnings = mismatches.stream() .filter(mismatch -> WARN == <START> mismatch.getSeverity()) <END> .collect(toList()); if (hasErrors) { throw new SignatureMismatchException(mismatches); } if (!warnings.isEmpty()) { Logger logger = Logging.get(MethodSignature.class); warnings.forEach(warning -> logger.warn(warning.toString())); } return true; }</code><technical_language>This ugly</technical_language>

Target:
public boolean matches(Method method) throws SignatureMismatchException { if (skipMethod(method)) { return false; } Collection<SignatureMismatch> mismatches = match(method); boolean hasErrors = mismatches.stream() .anyMatch(SignatureMismatch::isError); List<SignatureMismatch> warnings = mismatches.stream() .filter(SignatureMismatch::isWarning) .collect(toList()); if (hasErrors) { throw new SignatureMismatchException(mismatches); } if (!warnings.isEmpty()) { warnings.stream() .map(SignatureMismatch::toString) .forEach(this::_warn); } return true; }
Source:
<code><START> public void testOverride() throws Exception { <END> deployContrib(Thread.currentThread().getContextClassLoader().getResource("test-nxtreemanager-contrib.xml")); applyInlineDeployments(); postSetUp(); String filterName = "navigation"; assertEquals("tree_children", treeManager.getPageProviderName(filterName)); assertNotNull(treeManager.getFilter(filterName)); assertNull(treeManager.getLeafFilter(filterName)); assertNotNull(treeManager.getSorter(filterName)); }</code><technical_language>postSetUp called applyInlineDeployments - pushInlineDeployments ? - of deployContrib a test contribution</technical_language>

Target:
public void testOverride() throws Exception { pushInlineDeployments("org.nuxeo.ecm.webapp.base.tests:test-nxtreemanager-contrib.xml"); String filterName = "navigation"; assertEquals("tree_children", treeManager.getPageProviderName(filterName)); assertNotNull(treeManager.getFilter(filterName)); assertNull(treeManager.getLeafFilter(filterName)); assertNotNull(treeManager.getSorter(filterName)); }
Source:
<code>public boolean hasRadiologyOrderCompletedRadiologyReport(RadiologyOrder radiologyOrder) { List<RadiologyReport> radiologyReports = sessionFactory.getCurrentSession().createCriteria(RadiologyReport.class) .add(Restrictions.like("radiologyOrder", radiologyOrder)).add( Restrictions.like("radiologyReportStatus", RadiologyReportStatus.COMPLETED)).list(); <START> if (radiologyReports.size() == 1) { <END> return true; } else { return false; } }</code><technical_language>please ternary this</technical_language>

Target:
public boolean hasRadiologyOrderCompletedRadiologyReport(RadiologyOrder radiologyOrder) { List<RadiologyReport> radiologyReports = sessionFactory.getCurrentSession().createCriteria(RadiologyReport.class) .add(Restrictions.eq("radiologyOrder", radiologyOrder)).add( Restrictions.eq("reportStatus", RadiologyReportStatus.COMPLETED)).list(); return radiologyReports.size() == 1 ? true : false; }
Source:
<code>public void testBetaMemoryLeakOnFactDelete() { String drl = "rule R1 when\n" + " $a : Integer(this == 1)\n" + " $b : String()\n" + " $c : Integer(this == 2)\n" + "then \n" + "end\n" + "rule R2 when\n" + " $a : Integer(this == 1)\n" + " $b : String()\n" + "then \n" + "end\n"; KieSession ksession = new KieHelper().addContent(drl, ResourceType.DRL) .build() .newKieSession(); FactHandle fh1 = ksession.insert(1); FactHandle fh2 = ksession.insert("test"); ksession.fireAllRules(); ksession.delete(fh1); ksession.delete(fh2); ksession.fireAllRules(); NodeMemories nodeMemories = ((InternalWorkingMemory) ksession).getNodeMemories(); for (int i = 0; i < nodeMemories.length(); i++) { Memory memory = nodeMemories.peekNodeMemory(i); if (memory != null && memory.getSegmentMemory() != null) { LeftTuple deleteFirst = memory.getSegmentMemory().getStagedLeftTuples().getDeleteFirst(); assertThat(deleteFirst).isNull(); <START> } <END> } }</code><technical_language>Consider if empty lines add here. Personally, I code harder read of fits screen. this is a stylistic choice, I guess</technical_language>

Target:
public void testBetaMemoryLeakOnFactDelete() { final String drl = "rule R1 when\n" + " $a : Integer(this == 1)\n" + " $b : String()\n" + " $c : Integer(this == 2)\n" + "then \n" + "end\n" + "rule R2 when\n" + " $a : Integer(this == 1)\n" + " $b : String()\n" + "then \n" + "end\n"; final KieSession ksession = new KieHelper().addContent(drl, ResourceType.DRL) .build() .newKieSession(); final FactHandle fh1 = ksession.insert(1); final FactHandle fh2 = ksession.insert("test"); ksession.fireAllRules(); ksession.delete(fh1); ksession.delete(fh2); ksession.fireAllRules(); final NodeMemories nodeMemories = ((InternalWorkingMemory) ksession).getNodeMemories(); for (int i = 0; i < nodeMemories.length(); i++) { final Memory memory = nodeMemories.peekNodeMemory(i); if (memory != null && memory.getSegmentMemory() != null) { final LeftTuple deleteFirst = memory.getSegmentMemory().getStagedLeftTuples().getDeleteFirst(); assertThat(deleteFirst).isNull(); } } }
Source:
<code>public Object execute(ExecutionEvent event) throws ExecutionException { final RepositoryTreeNode node = getSelectedNodes(event).get(0); if (node.getType() == RepositoryTreeNodeType.ADDITIONALREF) { Ref ref = (Ref) node.getObject(); try { RevCommit baseCommit = new RevWalk(node.getRepository()) .parseCommit(ref.getLeaf().getObjectId()); WizardDialog dlg = new WizardDialog( getShell(event), new CreateBranchWizard(node.getRepository(), baseCommit.name())); dlg.setHelpAvailable(false); dlg.open(); } catch (IOException e) { Activator.handleError(e.getMessage(), e, true); } return null; } String base = null; if (node.getObject() instanceof Ref) base = ((Ref) node.getObject()).getName(); <START> else { <END> Ref branch; try { String sourceRef = node.getRepository().getConfig().getString( ConfigConstants.CONFIG_WORKFLOW_SECTION, null, ConfigConstants.CONFIG_KEY_DEFBRANCHSTARTPOINT); if (node.getRepository().getRef(sourceRef) != null) branch = node.getRepository().getRef(sourceRef); else { if (node.getRepository().getFullBranch() .startsWith(Constants.R_HEADS)) { branch = node.getRepository().getRef( node.getRepository().getFullBranch()); } else { String ref = Activator .getDefault() .getRepositoryUtil() .mapCommitToRef(node.getRepository(), node.getRepository().getFullBranch(), false); if (ref == null) branch = null; else { if (ref.startsWith(Constants.R_TAGS)) branch = null; else branch = node.getRepository().getRef(ref); } } } } catch (IOException e) { branch = null; } if (branch != null) base = branch.getName(); } new WizardDialog(getShell(event), new CreateBranchWizard(node .getRepository(), base)).open(); return null; }</code><technical_language>Btw. I currently this else branch reached anymore, plugin.xml command is visible RefNode, TagNode AdditionalRefNode. I miss something</technical_language>

Target:
public Object execute(ExecutionEvent event) throws ExecutionException { final RepositoryTreeNode node = getSelectedNodes(event).get(0); if (node.getType() == RepositoryTreeNodeType.ADDITIONALREF) { Ref ref = (Ref) node.getObject(); try { RevCommit baseCommit = new RevWalk(node.getRepository()) .parseCommit(ref.getLeaf().getObjectId()); WizardDialog dlg = new WizardDialog( getShell(event), new CreateBranchWizard(node.getRepository(), baseCommit.name())); dlg.setHelpAvailable(false); dlg.open(); } catch (IOException e) { Activator.handleError(e.getMessage(), e, true); } return null; } String base = null; if (node.getObject() instanceof Ref) base = ((Ref) node.getObject()).getName(); new WizardDialog(getShell(event), new CreateBranchWizard(node .getRepository(), base)).open(); return null; }
Source:
<code>public Builder runSafeService(Executor runSafeService) { this.runSafeService = runSafeService; <START> return null; <END> }</code><technical_language>This return this null</technical_language>

Target:
public Builder runSafeService(Executor runSafeService) { this.runSafeService = runSafeService; return this; }
Source:
<code>public App(AppConfig appConfig) { this.appConfig = appConfig; ExecutorService collectionThreadPool = null; ExecutorService recoveryThreadPool = null; if (!appConfig.isEmbedded()) { collectionThreadPool = buildExecutorService(appConfig.getThreadPoolSize()); recoveryThreadPool = buildExecutorService(appConfig.getReconnectionThreadPoolSize()); } recoveryProcessor = new TaskProcessor(recoveryThreadPool, appConfig.getReporter()); collectionProcessor = new TaskProcessor(collectionThreadPool, appConfig.getReporter()); if (appConfig.remoteEnabled()) { client = new HttpClient(appConfig.getIpcHost(), appConfig.getIpcPort(), false); } <START> this.configs = getConfigs(appConfig); <END> }</code><technical_language>instead of embedded setting, ExecutorService option? is impact if threadpools</technical_language>

Target:
public App(AppConfig appConfig) { this.appConfig = appConfig; ExecutorService collectionThreadPool = null; ExecutorService recoveryThreadPool = null; if (!appConfig.isEmbedded()) { collectionThreadPool = buildExecutorService(appConfig.getThreadPoolSize(), COLLECTION_POOL_NAME); recoveryThreadPool = buildExecutorService(appConfig.getReconnectionThreadPoolSize(), RECOVERY_POOL_NAME); } recoveryProcessor = new TaskProcessor(recoveryThreadPool, appConfig.getReporter()); collectionProcessor = new TaskProcessor(collectionThreadPool, appConfig.getReporter()); if (appConfig.remoteEnabled()) { client = new HttpClient(appConfig.getIpcHost(), appConfig.getIpcPort(), false); } this.configs = getConfigs(appConfig); }
Source:
<code>public void testTwoNodesDieOnRequest() throws Exception { CountDownLatch nodeStopLatch = new CountDownLatch(2); Ignite srv1 = startGrid(0); replaceWithStoppingMappingRequestListener( ((GridKernalContext)U.field(srv1, "ctx")).io(), 0, nodeStopLatch); Ignite srv2 = startGrid(1); replaceWithStoppingMappingRequestListener( ((GridKernalContext)U.field(srv2, "ctx")).io(), 1, nodeStopLatch); Ignite srv3 = startGrid(2); replaceWithCountingMappingRequestListener(((GridKernalContext)U.field(srv3, "ctx")).io()); srv3.cache(DEFAULT_CACHE_NAME).put( 1, new Organization(1, "Microsoft", "One Microsoft Way Redmond, WA 98052-6399, USA")); <START> clientMode = true; <END> Ignite cl1 = startClientGrid(4); cl1.cache(DEFAULT_CACHE_NAME).get(1); nodeStopLatch.await(5_000, TimeUnit.MILLISECONDS); int result = mappingReqsCounter.get(); assertEquals("Expected requests count is 3, actual is " + result, 3, result); }</code><technical_language>This is redundant</technical_language>

Target:
public void testTwoNodesDieOnRequest() throws Exception { CountDownLatch nodeStopLatch = new CountDownLatch(2); Ignite srv1 = startGrid(0); replaceWithStoppingMappingRequestListener( ((GridKernalContext)U.field(srv1, "ctx")).io(), 0, nodeStopLatch); Ignite srv2 = startGrid(1); replaceWithStoppingMappingRequestListener( ((GridKernalContext)U.field(srv2, "ctx")).io(), 1, nodeStopLatch); Ignite srv3 = startGrid(2); replaceWithCountingMappingRequestListener(((GridKernalContext)U.field(srv3, "ctx")).io()); srv3.cache(DEFAULT_CACHE_NAME).put( 1, new Organization(1, "Microsoft", "One Microsoft Way Redmond, WA 98052-6399, USA")); Ignite cl1 = startClientGrid(4); cl1.cache(DEFAULT_CACHE_NAME).get(1); nodeStopLatch.await(5_000, TimeUnit.MILLISECONDS); int result = mappingReqsCounter.get(); assertEquals("Expected requests count is 3, actual is " + result, 3, result); }
Source:
<code>public OvfEntityData mapRow(ResultSet rs, int rowNum) throws SQLException { OvfEntityData entity = new OvfEntityData(); entity.setEntityId(getGuid(rs, "entity_guid")); entity.setEntityName(rs.getString("entity_name")); entity.setEntityType(rs.getString("entity_type")); <START> entity.setArchitecture(rs.getInt("architecture")); <END> entity.setLowestCompVersion(new Version(rs.getString("lowest_comp_version"))); entity.setStorageDomainId(getGuid(rs, "storage_domain_id")); entity.setOvfData(rs.getString("ovf_data")); entity.setOvfExtraData(rs.getString("ovf_extra_data")); return entity; }</code><technical_language>ArchitectureType.forValue(rs.getInt("architecture")</technical_language>

Target:
public OvfEntityData mapRow(ResultSet rs, int rowNum) throws SQLException { OvfEntityData entity = new OvfEntityData(); entity.setEntityId(getGuid(rs, "entity_guid")); entity.setEntityName(rs.getString("entity_name")); entity.setEntityType(VmEntityType.valueOf(rs.getString("entity_type"))); entity.setArchitecture(ArchitectureType.forValue(rs.getInt("architecture"))); entity.setLowestCompVersion(new Version(rs.getString("lowest_comp_version"))); entity.setStorageDomainId(getGuid(rs, "storage_domain_id")); entity.setOvfData(rs.getString("ovf_data")); entity.setOvfExtraData(rs.getString("ovf_extra_data")); return entity; }
Source:
<code>public static void registerFormat(String name, Format<?> fmt) { if (fmt == null) throw new NullPointerException(); FormatEntry old = null; <START> FormatEntry entry = new FormatEntry(fmt, 1); <END> while (!replace(formats, name, old, entry)) { old = formats.get(name); if (old == null) { entry = new FormatEntry(fmt, 1); continue; } if (!old.format.equals(fmt)) throw new JGitInternalException(MessageFormat.format( JGitText.get().archiveFormatAlreadyRegistered, name)); entry = new FormatEntry(old.format, old.refcnt + 1); } }</code><technical_language>If a do loop, do in unregisterFormat, need this initialization loop I think</technical_language>

Target:
public static void registerFormat(String name, Format<?> fmt) { if (fmt == null) throw new NullPointerException(); FormatEntry old, entry; do { old = formats.get(name); if (old == null) { entry = new FormatEntry(fmt, 1); continue; } if (!old.format.equals(fmt)) throw new JGitInternalException(MessageFormat.format( JGitText.get().archiveFormatAlreadyRegistered, name)); entry = new FormatEntry(old.format, old.refcnt + 1); } while (!replace(formats, name, old, entry)); }
Source:
<code>public InstrumentTextSegmentExporter(IObservingLogSegment segment) { <START> this(segment, null); <END> }</code><technical_language>instead _thisProgramOnly = None.instance() avoid null</technical_language>

Target:
public InstrumentTextSegmentExporter(IObservingLogSegment segment) { super(segment); _thisProgramOnly = None.instance(); }
Source:
<code>public void onSuccess(List<DepictedItem> mediaList) { isLoading = false; hasMoreImages = false; progressBar.setVisibility(View.GONE); depictionNotFound.setVisibility(GONE); bottomProgressBar.setVisibility(GONE); <START> int itemCount=layoutManager.getItemCount(); <END> depictionsAdapter.addAll(mediaList); if(itemCount!=0) { depictionsAdapter.notifyItemRangeInserted(itemCount, mediaList.size()-1); }else{ depictionsAdapter.notifyDataSetChanged(); } }</code><technical_language>space =</technical_language>

Target:
public void onSuccess(List<DepictedItem> mediaList) { isLoading = false; progressBar.setVisibility(View.GONE); depictionNotFound.setVisibility(GONE); bottomProgressBar.setVisibility(GONE); int itemCount = layoutManager.getItemCount(); depictionsAdapter.addAll(mediaList); if(itemCount!=0) { depictionsAdapter.notifyItemRangeInserted(itemCount, mediaList.size()-1); }else{ depictionsAdapter.notifyDataSetChanged(); } }
Source:
<code>public boolean apply(URI uri) { <START> return DiModel.DI_FILE_EXTENSION.equals(uri.fileExtension()); <END> }</code><technical_language>di file account, do want other parts of triplet account? this dependency provider notation files right</technical_language>

Target:
public boolean apply(URI uri) { return fileExtensions.contains(uri.fileExtension()); }
Source:
<code>public void clearLevel(String loggerName) { <START> loggers.computeIfAbsent(loggerName, java.util.logging.Logger::getLogger) <END> .setLevel(null); }</code><technical_language>need hold logger level is cleared</technical_language>

Target:
public synchronized void clearLevel(String loggerName) { java.util.logging.Logger logger = loggers.remove(loggerName); if (logger != null) { logger.setLevel(null); } }
Source:
<code>public void discover() { DomainControllerData data = readFromFile(MASTER); if (data != null) { String host = data.getHost(); int port = data.getPort(); <START> String protocol = Protocol.REMOTE.name(); <END> try { StaticDiscoveryResourceDefinition.HOST.getValidator() .validateParameter(StaticDiscoveryResourceDefinition.HOST.getName(), host == null? new ModelNode() : new ModelNode(host)); StaticDiscoveryResourceDefinition.PORT.getValidator() .validateParameter(StaticDiscoveryResourceDefinition.PORT.getName(), new ModelNode(port)); StaticDiscoveryResourceDefinition.PROTOCOL.getValidator() .validateParameter(StaticDiscoveryResourceDefinition.PROTOCOL.getName(), new ModelNode(protocol)); } catch (OperationFailedException e) { throw new IllegalStateException(e.getFailureDescription().asString()); } setRemoteDomainControllerHost(host); setRemoteDomainControllerPort(port); setRemoteDomainControllerProtocol(protocol); } else { throw HostControllerLogger.ROOT_LOGGER.failedMarshallingDomainControllerData(); } }</code><technical_language>This todo needs done</technical_language>

Target:
public void discover() { List<DomainControllerData> dataDc = readFromFile(MASTER); List<StaticDiscovery> options = new ArrayList<StaticDiscovery>(dataDc.size()); for (DomainControllerData data : dataDc) { if (data != null) { StaticDiscovery discovery = new StaticDiscovery(data.getProtocol(), data.getHost(), data.getPort()); String host = data.getHost(); try { StaticDiscoveryResourceDefinition.HOST.getValidator() .validateParameter(StaticDiscoveryResourceDefinition.HOST.getName(), host == null ? new ModelNode() : new ModelNode(host)); StaticDiscoveryResourceDefinition.PORT.getValidator() .validateParameter(StaticDiscoveryResourceDefinition.PORT.getName(), new ModelNode(discovery.getRemoteDomainControllerPort())); StaticDiscoveryResourceDefinition.PROTOCOL.getValidator() .validateParameter(StaticDiscoveryResourceDefinition.PROTOCOL.getName(), new ModelNode(discovery.getRemoteDomainControllerProtocol())); options.add(discovery); } catch (OperationFailedException e) { } } else { throw HostControllerLogger.ROOT_LOGGER.failedMarshallingDomainControllerData(); } } if (options.isEmpty()) { throw HostControllerLogger.ROOT_LOGGER.failedMarshallingDomainControllerData(); } DiscoveryHostStategy.DEFAULT_STRATEGY.organize(options); setRemoteDomainControllerHost(options.get(0).getRemoteDomainControllerHost()); setRemoteDomainControllerPort(options.get(0).getRemoteDomainControllerPort()); setRemoteDomainControllerProtocol(options.get(0).getRemoteDomainControllerProtocol()); }
Source:
<code>private void prepareStubFile(File file) { try { List<String> lines = FileUtils.readLines(file); List<String> parsedLines = new ArrayList<>(); boolean skipLine = false; for (String line : lines) { if (line.contains(beginSolution)) { skipLine = true; } else if (skipLine && line.contains(endSolution)) { skipLine = false; } else if (!skipLine && !line.contains(stubMarker)) { <START> parsedLines.add(line); <END> } else if (line.contains(stubMarker)) { String start = line.substring(0, line.indexOf(stubMarker) - 1); String end = line.substring(line.indexOf(stubMarker) + stubMarker.length()); parsedLines.add(start + end); } } FileUtils.writeLines(file, parsedLines); } catch (IOException ex) { System.out.println("Unexpected IOException, preparation of file {" + file.getAbsolutePath() + "} interrupted"); } }</code><technical_language>this case in if-else chain</technical_language>

Target:
private void prepareStubFile(File file) { try { List<String> lines = Files.readAllLines(file.toPath(), charset); List<String> filteredLines = new ArrayList<>(); boolean skipLine = false; for (String line : lines) { if (line.contains(beginSolution)) { skipLine = true; } else if (skipLine && line.contains(endSolution)) { skipLine = false; } else if (line.contains(stubMarker)) { String start = line.substring(0, line.indexOf(stubMarker) - 1); String end = line.substring(line.indexOf(stubMarker) + stubMarker.length()); filteredLines.add(start + end); } else if (!skipLine && !line.contains(stubMarker)) { filteredLines.add(line); } } Files.write(file.toPath(), filteredLines, charset); } catch (IOException ex) { throw new RuntimeException("Unexpected IOException, preparation of file {" + file.getAbsolutePath() + "} interrupted", ex); } }
Source:
<code>private void fillCache(){ <START> for ( int numAlleles = 1; numAlleles < staticCache.length; numAlleles++ ) { <END> for ( int ploidy = 1; ploidy < staticCache[numAlleles].length; ploidy++ ) { staticCache[numAlleles][ploidy] = GenotypeLikelihoods.calcNumLikelihoods(numAlleles, ploidy); } } }</code><technical_language>discussed, shift 1</technical_language>

Target:
private void fillCache(){ for ( int numAlleles = 0; numAlleles < staticCache.length; numAlleles++ ) { for ( int ploidy = 0; ploidy < staticCache[numAlleles].length; ploidy++ ) { staticCache[numAlleles][ploidy] = GenotypeLikelihoods.calcNumLikelihoods(numAlleles+1, ploidy+1); } } }
Source:
<code>void configExtractor() throws IngestModule.IngestModuleException { List<DomainCategorizer> foundProviders = Lookup.getDefault().lookupAll(DomainCategorizer.class).stream() .filter(provider -> provider != null) .sorted((a, b) -> a.getClass().getName().compareToIgnoreCase(b.getClass().getName())) .collect(Collectors.toList()); foundProviders.add(new DefaultDomainCategorizer()); for (DomainCategorizer provider : foundProviders) { try { provider.initialize(); } catch (DomainCategorizerException ex) { throw new IngestModule.IngestModuleException("There was an error instantiating the provider: " + provider.getClass().getSimpleName(), ex); } } <START> this.domainProviders = foundProviders == null <END> ? Collections.emptyList() : foundProviders; }</code><technical_language>foundProviders null? I so, if could, get NPE line 367</technical_language>

Target:
void configExtractor() throws IngestModule.IngestModuleException { Collection<? extends DomainCategorizer> lookupList = Lookup.getDefault().lookupAll(DomainCategorizer.class); if (lookupList == null) { lookupList = Collections.emptyList(); } List<DomainCategorizer> foundProviders = lookupList.stream() .filter(provider -> provider != null) .sorted((a, b) -> a.getClass().getName().compareToIgnoreCase(b.getClass().getName())) .collect(Collectors.toList()); foundProviders.add(new DefaultDomainCategorizer()); for (DomainCategorizer provider : foundProviders) { try { provider.initialize(); } catch (DomainCategorizerException ex) { throw new IngestModule.IngestModuleException("There was an error instantiating the provider: " + provider.getClass().getSimpleName(), ex); } } this.domainProviders = foundProviders; }
Source:
<code>public boolean terminateSolver(Object problemId) { Objects.requireNonNull(problemId); logger.debug("Terminating solver of problemId ({}).", problemId); synchronized (this) { if (!isProblemSubmitted(problemId)) { <START> throw new IllegalArgumentException("Problem (" + problemId + ") was not submitted or finished solving."); <END> } SolverTask<Solution_> solverTask = problemIdToSolverTaskMap.get(problemId); boolean willTerminate = solverTask.stopSolver(); if (!willTerminate) { logger.error("Cannot terminate solver of problemId ({}).", problemId); return false; } List<Future> problemEventHandlersFutures = problemIdToEventHandlerFuturesMap.get(problemId); problemEventHandlersFutures.forEach(future -> future.cancel(false)); return cleanupResources(problemId); } }</code><technical_language>submitted finished solving</technical_language>

Target:
public void terminateSolver(Object problemId) { Objects.requireNonNull(problemId); logger.info("Terminating solver of problemId ({}).", problemId); synchronized (this) { if (!isProblemSubmitted(problemId)) { throw new IllegalArgumentException("Problem (" + problemId + ") either was not submitted or finished solving."); } problemIdToSolverTaskMap.get(problemId).terminateEarly(); List<Future> problemEventHandlersFutures = problemIdToFuturesMap.get(problemId); problemEventHandlersFutures.forEach(future -> future.cancel(false)); cleanupResources(problemId); } }