auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Object bulkheadAroundAdvice(ProceedingJoinPoint proceedingJoinPoint, Bulkhead backendMonitored) throws Throwable { Method method = ((MethodSignature) proceedingJoinPoint.getSignature()).getMethod(); String methodName = method.getDeclaringClass().getName() + "#" + method.getName(); if (backendMonitored == null) { backendMonitored = getBackendMonitoredAnnotation(proceedingJoinPoint); } String backend = backendMonitored.name(); io.github.resilience4j.bulkhead.Bulkhead bulkhead = getOrCreateBulkhead(methodName, backend); Class<?> returnType = method.getReturnType(); if (bulkHeadAspectExts != null && !bulkHeadAspectExts.isEmpty()) { for (BulkHeadAspectExt bulkHeadAspectExt : bulkHeadAspectExts) { if (bulkHeadAspectExt.canHandleReturnType(returnType)) { return bulkHeadAspectExt.handle(proceedingJoinPoint, bulkhead, methodName); } } } else if (CompletionStage.class.isAssignableFrom(returnType)) { return handleJoinPointCompletableFuture(proceedingJoinPoint, bulkhead, methodName); } <START> return handleJoinPoint(proceedingJoinPoint, bulkhead, methodName); <END> }</code><technical_language>rename handleSyncJoinPoint</technical_language>

Target:
public Object bulkheadAroundAdvice(ProceedingJoinPoint proceedingJoinPoint, Bulkhead backendMonitored) throws Throwable { Method method = ((MethodSignature) proceedingJoinPoint.getSignature()).getMethod(); String methodName = method.getDeclaringClass().getName() + "#" + method.getName(); if (backendMonitored == null) { backendMonitored = getBackendMonitoredAnnotation(proceedingJoinPoint); } String backend = backendMonitored.name(); io.github.resilience4j.bulkhead.Bulkhead bulkhead = getOrCreateBulkhead(methodName, backend); Class<?> returnType = method.getReturnType(); if (bulkheadAspectExts != null && !bulkheadAspectExts.isEmpty()) { for (BulkheadAspectExt bulkHeadAspectExt : bulkheadAspectExts) { if (bulkHeadAspectExt.canHandleReturnType(returnType)) { return bulkHeadAspectExt.handle(proceedingJoinPoint, bulkhead, methodName); } } } else if (CompletionStage.class.isAssignableFrom(returnType)) { return handleJoinPointCompletableFuture(proceedingJoinPoint, bulkhead, methodName); } return handleJoinPoint(proceedingJoinPoint, bulkhead, methodName); }
Source:
<code>public int execute(List<String> script, String summaryForLogging) { if (failExecution) { throw new TestException("Simulated driver exception"); } <START> return super.execute(script, summaryForLogging); <END> }</code><technical_language>simply return 0 here, relying SSH. Arguably necessary restrict this Integration tests weeded-out SSH</technical_language>

Target:
public int execute(List<String> script, String summaryForLogging) { if (failExecution) { throw new TestException("Simulated driver exception"); } return 0; }
Source:
<code>private void printHelp(Console console) { console.warn("Invalid or Unknown ship ID."); <START> console.warn("Usage: \"changeship module:shipName\""); <END> }</code><technical_language>suggestion console.warn("Usage: \"changeShip module:shipName\"");</technical_language>

Target:
private void printHelp(Console console) { console.warn("Invalid or Unknown ship ID."); console.warn("Usage: \"changeShip module:shipName\""); }
Source:
<code>private void reportModulesNotFoundErrors(@NotNull DependencySetupErrors setupErrors) { reportModulesNotFoundIssues(MISSING_DEPENDENCIES_BETWEEN_MODULES, setupErrors.getMissingModules()); for (String dependent : setupErrors.getMissingNames()) { String msg = String.format("Module '%1$s' depends on modules that do not have a name.", dependent); add(new Message(FAILED_TO_SET_UP_DEPENDENCIES, Message.Type.ERROR, msg)); } for (String dependent : setupErrors.getDependentsOnLibrariesWithoutBinaryPath()) { String msg = String.format("Module '%1$s' depends on libraries that do not have a 'binary' path.", dependent); add(new Message(FAILED_TO_SET_UP_DEPENDENCIES, Message.Type.ERROR, msg)); } for (DependencySetupErrors.InvalidModuleDependency dependency : setupErrors.getInvalidModuleDependencies()) { String msg = <START> String.format("Dependency '%1$s' on module '%2$s' is ignored because: %3$s.", <END> dependency.targetModuleName, dependency.module.getName(), dependency.detail); VirtualFile buildFile = getBuildFile(dependency.module); assert buildFile != null; add(new Message(FAILED_TO_SET_UP_DEPENDENCIES, Message.Type.WARNING, new OpenFileDescriptor(dependency.module.getProject(), buildFile, 0), msg)); } reportModulesNotFoundIssues(FAILED_TO_SET_UP_DEPENDENCIES, setupErrors.getMissingModulesWithBackupLibraries()); }</code><technical_language>I trouble explaining dependencies in error messages get confusing easily :-) Suggestion: "Ignoring dependency of module '%1$s' module '%2$s'. %3$s"</technical_language>

Target:
private void reportModulesNotFoundErrors(@NotNull DependencySetupErrors setupErrors) { reportModulesNotFoundIssues(MISSING_DEPENDENCIES_BETWEEN_MODULES, setupErrors.getMissingModules()); for (String dependent : setupErrors.getMissingNames()) { String msg = String.format("Module '%1$s' depends on modules that do not have a name.", dependent); add(new Message(FAILED_TO_SET_UP_DEPENDENCIES, Message.Type.ERROR, msg)); } for (String dependent : setupErrors.getDependentsOnLibrariesWithoutBinaryPath()) { String msg = String.format("Module '%1$s' depends on libraries that do not have a 'binary' path.", dependent); add(new Message(FAILED_TO_SET_UP_DEPENDENCIES, Message.Type.ERROR, msg)); } for (DependencySetupErrors.InvalidModuleDependency dependency : setupErrors.getInvalidModuleDependencies()) { String msg = String.format("Ignoring dependency of module '%1$s' on module '%2$s'. %3$s", dependency.dependent, dependency.dependency.getName(), dependency.detail); VirtualFile buildFile = getBuildFile(dependency.dependency); assert buildFile != null; add(new Message(FAILED_TO_SET_UP_DEPENDENCIES, Message.Type.WARNING, new OpenFileDescriptor(dependency.dependency.getProject(), buildFile, 0), msg)); } reportModulesNotFoundIssues(FAILED_TO_SET_UP_DEPENDENCIES, setupErrors.getMissingModulesWithBackupLibraries()); }
Source:
<code>protected <T> List<T> doMap(final IMappingService mappingService, final org.eclipse.papyrus.model2doc.emf.documentstructuretemplate.TableOfFigures documentStructureElement, final EObject modelElement, Class<T> expectedReturnedClass) { final TableOfFigures <START> toc <END> = DocumentStructureFactory.eINSTANCE.createTableOfFigures(); toc.setTofTitle(documentStructureElement.getTofTitle()); return Collections.singletonList(expectedReturnedClass.cast(toc)); }</code><technical_language>this is ambiguous, I this variable rename in tof</technical_language>

Target:
protected <T> List<T> doMap(final IMappingService mappingService, final org.eclipse.papyrus.model2doc.emf.documentstructuretemplate.TableOfFigures documentStructureElement, final EObject modelElement, Class<T> expectedReturnedClass) { final TableOfFigures tof = DocumentStructureFactory.eINSTANCE.createTableOfFigures(); tof.setTofTitle(documentStructureElement.getTofTitle()); return Collections.singletonList(expectedReturnedClass.cast(tof)); }
Source:
<code>public Object getEntity() { abortIfClosed(); Object entity = super.getEntity(); if (entity != null) { return entity; } try { <START> InputStream inputStream = getEntityStream(); <END> if(inputStream.available() == 0){ throw new IllegalStateException(); } return inputStream; } catch (IOException e) { throw new IllegalStateException(e); } }</code><technical_language>call getEntityStream() is possibly a problem. Basically, need method is called while a ClientResponse object is garbage collected a consequence of finalize method aggressively called. far, bother this problem invoker protected method is synchronized (readFrom(...) ). In case, safe simply turn getEntityStream() a synchronized method</technical_language>

Target:
public synchronized Object getEntity() { abortIfClosed(); Object entity = super.getEntity(); if (entity != null) { return entity; } try { InputStream inputStream = getEntityStream(); if(inputStream.available() == 0){ throw new IllegalStateException(); } return inputStream; } catch (IOException e) { throw new IllegalStateException(e); } }
Source:
<code>private void addCentralRepositoryEntry(StringBuilder html, CorrelationAttributeInstance attributeInstance) { startTable(html); addRow(html, "Case:", attributeInstance.getCorrelationCase().getDisplayName()); addRow(html, "Type:", attributeInstance.getCorrelationType().getDisplayName()); addRow(html, "Comment:", convertLineBreaksToHtml(attributeInstance.getComment())); <START> addRow(html, "Path:", attributeInstance.getFilePath()); <END> endTable(html); }</code><technical_language>Text visible user labels section headings defined messages for localization purposes</technical_language>

Target:
private void addCentralRepositoryEntry(StringBuilder html, CorrelationAttributeInstance attributeInstance) { startTable(html); addRow(html, Bundle.AnnotationsContentViewer_centralRepositoryEntryDataLabel_case(), attributeInstance.getCorrelationCase().getDisplayName()); addRow(html, Bundle.AnnotationsContentViewer_centralRepositoryEntryDataLabel_type(), attributeInstance.getCorrelationType().getDisplayName()); addRow(html, Bundle.AnnotationsContentViewer_centralRepositoryEntryDataLabel_comment(), formatHtmlString(attributeInstance.getComment())); addRow(html, Bundle.AnnotationsContentViewer_centralRepositoryEntryDataLabel_path(), attributeInstance.getFilePath()); endTable(html); }
Source:
<code>public Set<Query> getQueries() throws ConfigException { Set<Query> queries = new HashSet<Query>(); SrampAtomApiClient client = SrampAtomApiClientFactory.createAtomApiClient(); StringBuilder queryBuilder = new StringBuilder(); queryBuilder.append(ARTIFACT_TYPE); SrampClientQuery query = client.buildQuery(queryBuilder.toString()); SrampClientQuery scq = query.startIndex(0); try { QueryResultSet resultSet = scq.query(); for (ArtifactSummary artifactSummary : resultSet) { BaseArtifactType artifact = client.getArtifactMetaData(artifactSummary.getUuid()); String srampQuery = ""; <START> artifactSummary.getCustomPropertyValue(PROPERTY_QUERY); <END> String workflowId = ""; artifactSummary.getCustomPropertyValue(PROPERTY_WORKLOW); Query q = new Query(srampQuery, workflowId); for (Property prop : artifact.getProperty()) { if (prop.getPropertyName().equals(PROPERTY_WORKLOW)) { workflowId = prop.getPropertyValue(); } else if (prop.getPropertyName().equals(PROPERTY_QUERY)) { srampQuery = prop.getPropertyValue(); } else if (prop.getPropertyName().startsWith(PROPERTY_PREFIX)) { String value = prop.getPropertyValue(); q.addParameter(prop.getPropertyName().substring(PROPERTY_PREFIX.length()), value); } } q.setWorkflowId(workflowId); q.setSrampQuery(srampQuery); queries.add(q); } } catch (SrampClientException e) { logger.error( Messages.i18n.format( "QueryExecutor.ExceptionFor", "Reading query from s-ramp", e.getMessage()), e); } catch (SrampAtomException e) { logger.error( Messages.i18n.format( "QueryExecutor.ExceptionFor", " Reading query from s-ramp", e.getMessage()), e); } return queries; }</code><technical_language>This line - removed. line initialized a call get PROPERTY_QUERY property "artifact"</technical_language>

Target:
public Set<Query> getQueries() throws ConfigException { Set<Query> queries = new HashSet<Query>(); SrampAtomApiClient client = SrampAtomApiClientFactory.createAtomApiClient(); StringBuilder queryBuilder = new StringBuilder(); queryBuilder.append(ARTIFACT_TYPE); SrampClientQuery query = client.buildQuery(queryBuilder.toString()); SrampClientQuery scq = query.startIndex(0); try { QueryResultSet resultSet = scq.query(); for (ArtifactSummary artifactSummary : resultSet) { BaseArtifactType artifact = client.getArtifactMetaData(artifactSummary.getUuid()); Query q = new Query(SrampModelUtils.getCustomProperty(artifact, PROPERTY_QUERY), SrampModelUtils.getCustomProperty(artifact, PROPERTY_WORKLOW)); q.setParameters(SrampModelUtils.getCustomPropertiesByPrefix(artifact, PROPERTY_PREFIX)); queries.add(q); } } catch (SrampClientException e) { logger.error( Messages.i18n.format( "QueryExecutor.ExceptionFor", "Reading query from s-ramp", e.getMessage()), e); } catch (SrampAtomException e) { logger.error( Messages.i18n.format( "QueryExecutor.ExceptionFor", " Reading query from s-ramp", e.getMessage()), e); } return queries; }
Source:
<code>public void testInnerThreadMetaData() { Bugsnag.addThreadMetaData("outerthread", "some key", "value should not be in report"); Thread thread = new Thread(new Runnable() { @Override public void run() { Bugsnag.addThreadMetaData("innerthread", "some key", "value should be in report"); bugsnag.notify(new RuntimeException("test")); } }); thread.start(); try { <START> Thread.sleep(2000); <END> } catch (InterruptedException ex) { } Notification notification = delivery.getNotifications().get(0); Report report = notification.getEvents().get(0); assertTrue(report.getMetaData().containsKey("innerthread")); assertEquals("value should be in report", getMetaDataMap(notification, "innerthread").get("some key")); assertFalse(report.getMetaData().containsKey("outerthread")); }</code><technical_language>tests in this file currently 6 seconds run due of Thread.sleep. rework tests proper synchronisation mechanisms - for example, a CountDownLatch</technical_language>

Target:
public void testInnerThreadMetaData() { Bugsnag.addThreadMetaData("outerthread", "some key", "value should not be in report"); Thread thread = new Thread(new Runnable() { @Override public void run() { Bugsnag.addThreadMetaData("innerthread", "some key", "value should be in report"); bugsnag.notify(new RuntimeException("test")); } }); thread.start(); try { thread.join(); } catch (InterruptedException ex) { } Notification notification = delivery.getNotifications().get(0); Report report = notification.getEvents().get(0); assertTrue(report.getMetaData().containsKey("innerthread")); assertEquals("value should be in report", getMetaDataMap(notification, "innerthread").get("some key")); assertFalse(report.getMetaData().containsKey("outerthread")); }
Source:
<code>public void assumeShallow(Collection<? extends ObjectId> ids) throws IOException { if (!shallowCommitsInitialized) <START> initializeShallowCommits(); <END> for (ObjectId id : ids) lookupCommit(id).parents = RevCommit.NO_PARENTS; }</code><technical_language>I handling fetches a server shallow commits more work (see v1.9-rc0~3^2~17, "upload-pack: deepening preserves shallow roots", 2013-12-05). lines needed here</technical_language>

Target:
public void assumeShallow(Collection<? extends ObjectId> ids) { for (ObjectId id : ids) lookupCommit(id).parents = RevCommit.NO_PARENTS; }
Source:
<code>public void validate(Object obj, Errors errors) { Order order = (Order) obj; if (order == null) { errors.rejectValue("order", "error.general"); } else { <START> if (order.getEncounter() != null && order.getPatient() != null && order.getOrderer() != null) { <END> if (!order.getEncounter().getPatient().equals(order.getPatient())) errors.rejectValue("encounter", "Order.error.encounterPatientMismatch"); } ValidationUtils.rejectIfEmpty(errors, "voided", "error.null"); ValidationUtils.rejectIfEmpty(errors, "concept", "Concept.noConceptSelected"); ValidationUtils.rejectIfEmpty(errors, "patient", "error.null"); ValidationUtils.rejectIfEmpty(errors, "orderer", "error.null"); Date startDate = order.getStartDate(); if (startDate != null) { Date dateStopped = order.getDateStopped(); if (dateStopped != null && startDate.after(dateStopped)) { errors.rejectValue("startDate", "Order.error.startDateAfterDiscontinuedDate"); errors.rejectValue("dateStopped", "Order.error.startDateAfterDiscontinuedDate"); } Date autoExpireDate = order.getAutoExpireDate(); if (autoExpireDate != null && startDate.after(autoExpireDate)) { errors.rejectValue("startDate", "Order.error.startDateAfterAutoExpireDate"); errors.rejectValue("autoExpireDate", "Order.error.startDateAfterAutoExpireDate"); } } } }</code><technical_language>This is incorrect, add this if clause</technical_language>

Target:
public void validate(Object obj, Errors errors) { Order order = (Order) obj; if (order == null) { errors.rejectValue("order", "error.general"); } else { if (order.getEncounter() != null && order.getPatient() != null) { if (!order.getEncounter().getPatient().equals(order.getPatient())) errors.rejectValue("encounter", "Order.error.encounterPatientMismatch"); } ValidationUtils.rejectIfEmpty(errors, "voided", "error.null"); ValidationUtils.rejectIfEmpty(errors, "concept", "Concept.noConceptSelected"); ValidationUtils.rejectIfEmpty(errors, "patient", "error.null"); ValidationUtils.rejectIfEmpty(errors, "orderer", "error.null"); Date startDate = order.getStartDate(); if (startDate != null) { Date dateStopped = order.getDateStopped(); if (dateStopped != null && startDate.after(dateStopped)) { errors.rejectValue("startDate", "Order.error.startDateAfterDiscontinuedDate"); errors.rejectValue("dateStopped", "Order.error.startDateAfterDiscontinuedDate"); } Date autoExpireDate = order.getAutoExpireDate(); if (autoExpireDate != null && startDate.after(autoExpireDate)) { errors.rejectValue("startDate", "Order.error.startDateAfterAutoExpireDate"); errors.rejectValue("autoExpireDate", "Order.error.startDateAfterAutoExpireDate"); } } } }
Source:
<code>protected void updateSensorProperties() { Map<String, String> properties = editProperties(); Bridge bridge = getBridge(); if (bridge == null) { <START> logger.info("updating thing properties failed, no bridge available"); <END> scheduler.schedule(() -> { updateSensorProperties(); }, 5000, TimeUnit.MILLISECONDS); return; } OwBaseBridgeHandler bridgeHandler = (OwBaseBridgeHandler) bridge.getHandler(); try { if (bridgeHandler == null) { throw new OwException("no bridge handler available"); } OwPageBuffer pages = bridgeHandler.readPages(sensorIds.get(0)); prodDate = String.format("%d/%d", pages.getByte(5, 0), 256 * pages.getByte(5, 1) + pages.getByte(5, 2)); hwRevision = pages.getByte(5, 3); properties.put(PROPERTY_PROD_DATE, prodDate); properties.put(PROPERTY_HW_REVISION, String.valueOf(hwRevision)); logger.trace("set production date {}, revision {}", prodDate, hwRevision); } catch (OwException e) { logger.info("updating thing properties failed: {}", e.getMessage()); scheduler.schedule(() -> { updateSensorProperties(); }, 5000, TimeUnit.MILLISECONDS); return; } updateProperties(properties); }</code><technical_language>This happen handler is disposed already, in a case log anything. reduce debug</technical_language>

Target:
protected void updateSensorProperties() { Map<String, String> properties = editProperties(); Bridge bridge = getBridge(); if (bridge == null) { logger.debug("updating thing properties failed, no bridge available"); scheduler.schedule(() -> { updateSensorProperties(); }, 5000, TimeUnit.MILLISECONDS); return; } OwBaseBridgeHandler bridgeHandler = (OwBaseBridgeHandler) bridge.getHandler(); try { if (bridgeHandler == null) { throw new OwException("no bridge handler available"); } OwPageBuffer pages = bridgeHandler.readPages(sensorIds.get(0)); prodDate = String.format("%d/%d", pages.getByte(5, 0), 256 * pages.getByte(5, 1) + pages.getByte(5, 2)); hwRevision = pages.getByte(5, 3); properties.put(PROPERTY_PROD_DATE, prodDate); properties.put(PROPERTY_HW_REVISION, String.valueOf(hwRevision)); logger.trace("set production date {}, revision {}", prodDate, hwRevision); } catch (OwException e) { logger.info("updating thing properties failed: {}", e.getMessage()); scheduler.schedule(() -> { updateSensorProperties(); }, 5000, TimeUnit.MILLISECONDS); return; } updateProperties(properties); }
Source:
<code>private void rewriteConfigMapNames(PodData pod, Map<String, String> configMapNameTranslation) { for (Container container : pod.getSpec().getContainers()) { if (container.getEnv() != null) { container .getEnv() .stream() .filter( env -> env.getValueFrom() != null && env.getValueFrom().getConfigMapKeyRef() != null) .forEach( env -> { ConfigMapKeySelector configMap = env.getValueFrom().getConfigMapKeyRef(); String originalName = configMap.getName(); <START> configMap.setName(configMapNameTranslation.get(originalName)); <END> }); } if (container.getEnvFrom() != null) { container .getEnvFrom() .stream() .filter(envFrom -> envFrom.getConfigMapRef() != null) .forEach( envFrom -> { ConfigMapEnvSource configMapRef = envFrom.getConfigMapRef(); String originalName = configMapRef.getName(); configMapRef.setName(configMapNameTranslation.get(originalName)); }); } } List<Volume> volumes = pod.getSpec().getVolumes(); if (pod.getSpec().getVolumes() != null) { volumes .stream() .filter(vol -> vol.getConfigMap() != null) .forEach( volume -> { ConfigMapVolumeSource configMapVolume = volume.getConfigMap(); String originalName = configMapVolume.getName(); configMapVolume.setName(configMapNameTranslation.get(originalName)); }); } }</code><technical_language>validation input recipe is consistent pods reference missing config maps. In this case, this line set null for ConfigMapKeySelector. for user understand issue caused a provided recipe. Please consider leaving original for ConfigMapKeySelector if map</technical_language>

Target:
private void rewriteConfigMapNames(PodData pod, Map<String, String> configMapNameTranslation) { for (Container container : pod.getSpec().getContainers()) { if (container.getEnv() != null) { container .getEnv() .stream() .filter( env -> env.getValueFrom() != null && env.getValueFrom().getConfigMapKeyRef() != null) .forEach( env -> { ConfigMapKeySelector configMap = env.getValueFrom().getConfigMapKeyRef(); String originalName = configMap.getName(); if (configMapNameTranslation.containsKey(originalName)) { configMap.setName(configMapNameTranslation.get(originalName)); } }); } if (container.getEnvFrom() != null) { container .getEnvFrom() .stream() .filter(envFrom -> envFrom.getConfigMapRef() != null) .forEach( envFrom -> { ConfigMapEnvSource configMapRef = envFrom.getConfigMapRef(); String originalName = configMapRef.getName(); if (configMapNameTranslation.containsKey(originalName)) { configMapRef.setName(configMapNameTranslation.get(originalName)); } }); } } List<Volume> volumes = pod.getSpec().getVolumes(); if (pod.getSpec().getVolumes() != null) { volumes .stream() .filter(vol -> vol.getConfigMap() != null) .forEach( volume -> { ConfigMapVolumeSource configMapVolume = volume.getConfigMap(); String originalName = configMapVolume.getName(); if (configMapNameTranslation.containsKey(originalName)) { configMapVolume.setName(configMapNameTranslation.get(originalName)); } }); } }
Source:
<code><START> public void bookmarkFromIterable() <END> { Bookmark bookmark = Bookmark.from( asList( "neo4j:bookmark:v1:tx42", "neo4j:bookmark:v1:tx10", "neo4j:bookmark:v1:tx12" ) ); assertEquals( "neo4j:bookmark:v1:tx42", bookmark.asString() ); verifyParameters( bookmark, "neo4j:bookmark:v1:tx42", "neo4j:bookmark:v1:tx42", "neo4j:bookmark:v1:tx10", "neo4j:bookmark:v1:tx12" ); }</code><technical_language>a test for Bookmark bookmark = Bookmark.from( asList( null, "neo4j:bookmark:v1:tx10", "neo4j:bookmark:v1:tx12" ) );</technical_language>

Target:
public void bookmarkFromIterable() { Bookmark bookmark = Bookmark.from( asList( "neo4j:bookmark:v1:tx42", "neo4j:bookmark:v1:tx10", "neo4j:bookmark:v1:tx12" ) ); assertEquals( "neo4j:bookmark:v1:tx42", bookmark.maxBookmarkAsString() ); verifyParameters( bookmark, "neo4j:bookmark:v1:tx42", "neo4j:bookmark:v1:tx42", "neo4j:bookmark:v1:tx10", "neo4j:bookmark:v1:tx12" ); }
Source:
<code>public Collection<Dataset> listDatasets(Project project) { <START> final HashSet<Dataset> datasets = listDatasetLinks(project).stream().map(link -> new Dataset(link.getIdentifier(), link.getUri(), link.getTitle())).collect(Collectors.toCollection(HashSet::new)); <END> return datasets; }</code><technical_language>consider inline datasets</technical_language>

Target:
public Collection<Dataset> listDatasets(Project project) { return listDatasetLinks(project).stream().map(link -> new Dataset(link.getIdentifier(), link.getUri(), link.getTitle())).collect(Collectors.toCollection(HashSet::new)); }
Source:
<code>private boolean canAdd(IFeatureModel candidate) { ISiteFeature[] features = fModel.getSite().getFeatures(); IFeature cfeature = candidate.getFeature(); String id = cfeature.getId(); String version = cfeature.getVersion(); for (ISiteFeature bfeature : features) { boolean idEquals = Objects.equals(bfeature.getId(), id); <START> if (idEquals && (version == null || version.equals(bfeature.getVersion()))) { <END> return false; } } return true; }</code><technical_language>version == null bfeature.getVersion() == null --> candidate feature a version, site feature version-less</technical_language>

Target:
private boolean canAdd(IFeatureModel candidate) { ISiteFeature[] features = fModel.getSite().getFeatures(); IFeature cfeature = candidate.getFeature(); String id = cfeature.getId(); String version = cfeature.getVersion(); for (ISiteFeature bfeature : features) { boolean idEquals = Objects.equals(bfeature.getId(), id); if (idEquals && (bfeature.getVersion() == null || Objects.equals(bfeature.getVersion(), version))) { return false; } } return true; }
Source:
<code>private void appendBuild(StringBuffer buf, final TaskListener listener, final Run<?, ?> currentRun) throws MacroEvaluationException { final ChangesSinceLastBuildContent changes = new ChangesSinceLastBuildContent(changesFormat, pathFormat, showPaths); changes.showDependencies = showDependencies; changes.dateFormat = dateFormat; changes.regex = regex; changes.replace = replace; changes.def = def; Util.printf(buf, format, new Util.PrintfSpec() { public boolean printSpec(StringBuffer buf, char formatChar) { switch (formatChar) { case 'c': try { <START> buf.append(changes.evaluate((AbstractBuild)currentRun, listener, ChangesSinceLastBuildContent.MACRO_NAME)); <END> } catch(Exception e) { } return true; case 'n': buf.append(currentRun.getNumber()); return true; default: return false; } } }); }</code><technical_language>Unsafe cast</technical_language>

Target:
private void appendBuild(StringBuffer buf, final TaskListener listener, final Run<?, ?> currentRun) throws MacroEvaluationException { final ChangesSinceLastBuildContent changes = new ChangesSinceLastBuildContent(changesFormat, pathFormat, showPaths); changes.showDependencies = showDependencies; changes.dateFormat = dateFormat; changes.regex = regex; changes.replace = replace; changes.def = def; Util.printf(buf, format, new Util.PrintfSpec() { public boolean printSpec(StringBuffer buf, char formatChar) { switch (formatChar) { case 'c': try { if(currentRun instanceof AbstractBuild) { buf.append(changes.evaluate((AbstractBuild) currentRun, listener, ChangesSinceLastBuildContent.MACRO_NAME)); } } catch(Exception e) { } return true; case 'n': buf.append(currentRun.getNumber()); return true; default: return false; } } }); }
Source:
<code>public SmudgeFilter(Repository db, InputStream in, OutputStream out) throws IOException { super(in, out); lfsUtil = new <START> LfsUtil(db.getDirectory().toPath().resolve("lfs")); <END> LfsPointer res = LfsPointer.parseLfsPointer(in); if (res != null) { Path mediaFile = lfsUtil.getMediaFile(res.getOid()); if (Files.exists(mediaFile)) { this.in = Files.newInputStream(mediaFile); } } }</code><technical_language>define a constant for this folder name</technical_language>

Target:
public SmudgeFilter(Repository db, InputStream in, OutputStream out) throws IOException { super(in, out); lfs = new Lfs(db.getDirectory().toPath().resolve(Constants.LFS)); LfsPointer res = LfsPointer.parseLfsPointer(in); if (res != null) { Path mediaFile = lfs.getMediaFile(res.getOid()); if (Files.exists(mediaFile)) { this.in = Files.newInputStream(mediaFile); } } }
Source:
<code>public void preDestroy() { <START> if(formGroup != null) { <END> FormsElementWrapperWidgetUtil.clear(this); } partsWidgets.values().forEach(part -> part.asWidget().removeFromParent()); partsWidgets.clear(); formGroupsInstance.destroyAll(); fieldChangeListeners.clear(); formField = null; formGroup = null; field = null; }</code><technical_language>suggestion if (formGroup != null) {</technical_language>

Target:
public void preDestroy() { wrapperWidgetUtil.clear(this); partsWidgets.values().forEach(part -> part.asWidget().removeFromParent()); partsWidgets.clear(); formGroupsInstance.destroyAll(); fieldChangeListeners.clear(); formField = null; formGroup = null; field = null; }
Source:
<code>public void doPolling(Guid cmdId, List<Guid> childCmdIds) { RebootVmCommand<P> command = getCommand(cmdId); boolean anyFailed = false; for (Guid childCmdId : childCmdIds) { CommandEntity entity = CommandCoordinatorUtil.getCommandEntity(childCmdId); switch (entity.getCommandStatus()) { case FAILED: case FAILED_RESTARTED: case UNKNOWN: anyFailed = true; break; default: break; } <START> if (entity.isExecuted() && !entity.getReturnValue().getSucceeded()) { <END> anyFailed = true; } } if (anyFailed) { command.setCommandStatus(CommandStatus.FAILED); } else { VM vm = DbFacade.getInstance().getVmDao().get(command.getParameters().getVmId()); if (vm.getStatus() == VMStatus.Down && !DbFacade.getInstance().getSnapshotDao().exists(vm.getId(), Snapshot.SnapshotStatus.LOCKED)) { command.proceedWithColdRun(); } } }</code><technical_language>This is needed. CommandBase#1256 sets CommandEntity.commandStatus FAILED in this case</technical_language>

Target:
public void doPolling(Guid cmdId, List<Guid> childCmdIds) { RebootVmCommand<P> command = getCommand(cmdId); boolean anyFailed = false; for (Guid childCmdId : childCmdIds) { CommandEntity entity = CommandCoordinatorUtil.getCommandEntity(childCmdId); switch (entity.getCommandStatus()) { case FAILED: case FAILED_RESTARTED: case UNKNOWN: anyFailed = true; break; default: break; } } if (anyFailed) { command.setCommandStatus(CommandStatus.FAILED); } else { VM vm = DbFacade.getInstance().getVmDao().get(command.getParameters().getVmId()); if (isVmDownForColdReboot(vm)) { command.proceedWithColdRun(); } } }
Source:
<code>default boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) { <START> return false; <END> }</code><technical_language>New actPrimary default post API break, this throw</technical_language>

Target:
default boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) { throw new AssertionError("actPrimary must be overridden"); }
Source:
<code>public void testIOExplain() { assertUpdate("CREATE TABLE test_orders (LIKE orders INCLUDING PROPERTIES)"); String query = "INSERT INTO test_orders SELECT * FROM orders where orderkey > 5"; <START> MaterializedResult result = computeActual("EXPLAIN (TYPE IO) " + query); <END> TableColumnInfo input = new TableColumnInfo( new QualifiedTablePrefix("hive", "tpch", "orders"), ImmutableList.of( new ColumnConstraint( "orderkey", BIGINT, new FormattedDomain( false, ImmutableList.of( new FormattedRange( new FormattedMarker(Optional.of("5"), ABOVE), new FormattedMarker(Optional.empty(), BELOW)))) ) ) ); assertEquals( getOnlyElement(result.getOnlyColumnAsSet()), jsonCodec(IOPlan.class).toJson(new IOPlan( ImmutableList.of(input), Optional.of(new QualifiedTablePrefix("hive", "tpch", "test_orders"))))); assertUpdate("DROP TABLE test_orders"); }</code><technical_language>inline query variable</technical_language>

Target:
public void testIOExplain() { computeActual("CREATE TABLE test_orders WITH (partitioned_by = ARRAY['orderkey']) AS select custkey, orderkey FROM orders where orderkey < 10"); MaterializedResult result = computeActual("EXPLAIN (TYPE IO, FORMAT JSON) INSERT INTO test_orders SELECT custkey, orderkey FROM orders where orderkey > 5 AND custkey <= 10"); TableColumnInfo input = new TableColumnInfo( new CatalogSchemaTableName("hive", "tpch", "orders"), ImmutableSet.of( new ColumnConstraint( "custkey", BIGINT.getTypeSignature(), new FormattedDomain( false, ImmutableSet.of( new FormattedRange( new FormattedMarker(Optional.empty(), ABOVE), new FormattedMarker(Optional.of("10"), EXACTLY))))), new ColumnConstraint( "orderkey", BIGINT.getTypeSignature(), new FormattedDomain( false, ImmutableSet.of( new FormattedRange( new FormattedMarker(Optional.of("5"), ABOVE), new FormattedMarker(Optional.empty(), BELOW))))))); assertEquals( jsonCodec(IOPlan.class).fromJson((String) getOnlyElement(result.getOnlyColumnAsSet())), new IOPlan( ImmutableSet.of(input), Optional.of(new CatalogSchemaTableName("hive", "tpch", "test_orders")))); assertUpdate("DROP TABLE test_orders"); }
Source:
<code><START> public static int compareOffsets(String offset1, String offset2) { <END> return Long.valueOf(offset1).compareTo(Long.valueOf(offset2)); }</code><technical_language>this need public</technical_language>

Target:
private static int compareOffsets(String offset1, String offset2) { return Long.valueOf(offset1).compareTo(Long.valueOf(offset2)); }
Source:
<code>private void cleanupWorkspaces(TopLevelItem item) { Jenkins j = Jenkins.getInstance(); List<Node> nodes = new ArrayList<>(); nodes.add(j); nodes.addAll(j.getNodes()); Logger log = Logger.getLogger(Job.class.getName()); for (Node node : nodes) { <START> FilePath ws = node.getWorkspaceFor(item); <END> if (ws != null) { try { ws.deleteRecursive(); } catch (IOException e) { log.log(Level.FINE, "Unable to clean out workspace for deleted job", e); } catch (InterruptedException e) { log.log(Level.FINE, "Unable to clean out workspace for deleted job", e); } } } }</code><technical_language>main area of concern this is scales a large number of nodes. this block web UI thread - slaves slow disks (aka spinning rust lots of small files) amount of time. kick workspace cleanup thread instead handle this asynchronously</technical_language>

Target:
private void cleanupWorkspaces(TopLevelItem item) { Jenkins j = Jenkins.getInstance(); List<Node> nodes = new ArrayList<>(); nodes.add(j); nodes.addAll(j.getNodes()); for (Node node : nodes) { FilePath ws = node.getWorkspaceFor(item); if (ws != null) { try { ws.deleteRecursive(); WorkspaceList.tempDir(ws).deleteRecursive(); } catch (IOException e) { logger.log(Level.FINE, "Unable to clean out workspace for deleted job", e); } catch (InterruptedException e) { logger.log(Level.FINE, "Unable to clean out workspace for deleted job", e); } } } }
Source:
<code><START> public static <T> T parse(String itemResponseBodyAsString, Class<T> itemClassType) { <END> try { return getSimpleObjectMapper().readValue(itemResponseBodyAsString, itemClassType); } catch (IOException e) { throw new IllegalStateException("Failed to get POJO.", e); } }</code><technical_language>I looked 4 places Utils.getsimpleObjectMapper().readValue() APIs. great if consolidate this logic place</technical_language>

Target:
public static <T> T parse(String itemResponseBodyAsString, Class<T> itemClassType) { if (StringUtils.isEmpty(itemResponseBodyAsString)) { return null; } try { return getSimpleObjectMapper().readValue(itemResponseBodyAsString, itemClassType); } catch (IOException e) { throw new IllegalStateException("Failed to get POJO.", e); } }
Source:
<code>public void setAutoChar(final char currentChar) { char nextChar = currentChar; if (nextChar < 'A') { nextChar = 'A'; } else if (nextChar > 'Z') { nextChar = 'Z'; } <START> switch (getType()) { <END> case INPUT_VAL: buttonData.autoChar = nextChar; break; case AUTO_CHAR: buttonData.autoChar = nextChar++; break; case CUSTOM: buttonData.autoChar = nextChar; if ('A' <= buttonData.customChar && buttonData.customChar <= 'Z') { nextChar = buttonData.customChar; nextChar++; } break; default: } updateButtonText(); if (nextButton != null) { nextButton.setAutoChar(nextChar); } }</code><technical_language>here. I get a bit alerted, if I enum if switch statements</technical_language>

Target:
private void setAutoChar(final char currentChar) { char nextChar = currentChar; if (nextChar < 'A') { nextChar = 'A'; } else if (nextChar > 'Z') { nextChar = 'Z'; } nextChar = getType().setAutoChar(getData(), nextChar); updateButtonText(); if (nextButton != null) { nextButton.setAutoChar(nextChar); } }
Source:
<code>public InputStream openFile(String path) { <START> Preconditions.notBlank(path, "File [" + path + "] must not be null or blank"); <END> try { return Files.newInputStream(Paths.get(path)); } catch (IOException e) { throw new UncheckedIOException("File [" + path + "] could not be read", e); } }</code><technical_language>suggestion Preconditions.notBlank(path, () -> "File [" + path + "] null blank");</technical_language>

Target:
public InputStream openFile(String path) { Preconditions.notBlank(path, () -> "File [" + path + "] must not be null or blank"); try { return Files.newInputStream(Paths.get(path)); } catch (IOException e) { throw new JUnitException("File [" + path + "] could not be read", e); } }
Source:
<code>public QueryIterTopN(QueryIterator qIter, Comparator<Binding> comparator, long numItems, boolean distinct, ExecutionContext context) { super(null, context) ; this.embeddedIterator = qIter ; this.distinct = distinct ; limit = numItems ; if ( limit == Query.NOLIMIT ) limit = Long.MAX_VALUE ; if ( limit < 0 ) throw new QueryExecException("Negative LIMIT: " + limit) ; if ( limit == 0 ) { Iterator<Binding> iter0 = Iter.nullIterator() ; setIterator(iter0) ; qIter.close() ; return ; } <START> this.heap = new PriorityQueue<>((int)numItems, new ReverseComparator<>(comparator)) ; <END> this.setIterator(sortTopN(qIter, comparator)) ; }</code><technical_language>Deprecation of ReverseComparator -- Comparator#reversed</technical_language>

Target:
public QueryIterTopN(QueryIterator qIter, Comparator<Binding> comparator, long numItems, boolean distinct, ExecutionContext context) { super(null, context) ; this.embeddedIterator = qIter ; this.distinct = distinct ; limit = numItems ; if ( limit == Query.NOLIMIT ) limit = Long.MAX_VALUE ; if ( limit < 0 ) throw new QueryExecException("Negative LIMIT: " + limit) ; if ( limit == 0 ) { Iterator<Binding> iter0 = Iter.nullIterator() ; setIterator(iter0) ; qIter.close() ; return ; } this.heap = new PriorityQueue<>((int)numItems, comparator.reversed()) ; this.setIterator(sortTopN(qIter, comparator)) ; }
Source:
<code>public void testUnderlyingReaders() throws IOException, FormatException { FakeReader reader = new FakeReader(); FileStitcher fs = new FileStitcher(reader); assertNotNull(fs.getUnderlyingReaders()); fs.setId("test_z<0-2>.fake"); assertNotNull(fs.getUnderlyingReaders()); <START> } <END></code><technical_language>Missing fs.close()</technical_language>

Target:
public void testUnderlyingReaders() throws IOException, FormatException { FakeReader reader = new FakeReader(); FileStitcher fs = new FileStitcher(reader); assertNotNull(fs.getUnderlyingReaders()); fs.setId("test_z<0-2>.fake"); assertNotNull(fs.getUnderlyingReaders()); fs.close(); }
Source:
<code>public BouncyCastleAesBytesEncryptor(String password, CharSequence salt) { <START> this(password, salt, null); <END> }</code><technical_language>a null IV this is safe. need create IV for AES/CBC</technical_language>

Target:
BouncyCastleAesBytesEncryptor(String password, CharSequence salt) { this(password, salt, KeyGenerators.secureRandom(16)); }
Source:
<code><START> public LogInHandler(Logger logger, Authenticator authenticator, UserSessionDao loginCookieDao) { <END> super(LogInAction.class); this.logger = logger; this.authenticator = authenticator; this.loginCookieDao = loginCookieDao; }</code><technical_language>rm public</technical_language>

Target:
LogInHandler(Logger logger, Authenticator authenticator, UserSessionDao loginCookieDao) { super(LogInAction.class); this.logger = logger; this.authenticator = authenticator; this.loginCookieDao = loginCookieDao; }
Source:
<code>public void onFailed(Guid cmdId, List<Guid> childCmdIds) { super.onFailed(cmdId, childCmdIds); if ((!getDisk().getParentId().equals(Guid.Empty)) && (!getDisk().getParentId().equals(getDisk().getImageTemplateId()))) { DiskImage previousSnapshot = getDiskImageDAO().getSnapshotById(getDisk().getParentId()); previousSnapshot.setActive(true); getImageDao().update(previousSnapshot.getImage()); } <START> onFinish(cmdId); <END> }</code><technical_language>check if need add: " getCommand().getParameters().setTaskGroupSuccess(false); "</technical_language>

Target:
public void onFailed(Guid cmdId, List<Guid> childCmdIds) { super.onFailed(cmdId, childCmdIds); if ((!getDisk().getParentId().equals(Guid.Empty)) && (!getDisk().getParentId().equals(getDisk().getImageTemplateId()))) { DiskImage previousSnapshot = getDiskImageDAO().getSnapshotById(getDisk().getParentId()); previousSnapshot.setActive(true); getImageDao().update(previousSnapshot.getImage()); } getCommand().getParameters().setTaskGroupSuccess(false); onFinish(cmdId); }
Source:
<code>public Response install(Action action) { VDS vds = getEntity(); UpdateVdsActionParameters params = new UpdateVdsActionParameters(vds.getStaticData(), action.getRootPassword(), true); <START> if (action.getSsh().isSetUser()) { <END> params.setPassword(action.getSsh().getUser().getPassword()); params.getvds().setSshUsername(action.getSsh().getUser().getUserName()); } params.getvds().setSshPort(action.getSsh().getPort()); params.getvds().setSshKeyFingerprint(action.getSsh().getFingerprint()); if (vds.getVdsType()==VDSType.oVirtNode) { params.setIsReinstallOrUpgrade(true); if (action.isSetImage()) { params.setoVirtIsoFile(action.getImage()); } } else { validateParameters(action, "rootPassword"); } return doAction(VdcActionType.UpdateVds, params, action); }</code><technical_language>potential NPE, please check action.isSetSsh() invoke methods</technical_language>

Target:
public Response install(Action action) { VDS vds = getEntity(); UpdateVdsActionParameters params = new UpdateVdsActionParameters(vds.getStaticData(), action.getRootPassword(), true); if (action.isSetSsh()) { if (action.getSsh().isSetUser()) { if (action.getSsh().getUser().isSetPassword()) { params.setPassword(action.getSsh().getUser().getPassword()); } } if (action.getSsh().isSetPort()) { params.getvds().setSshPort(action.getSsh().getPort().intValue()); } if (action.getSsh().isSetFingerprint()) { params.getvds().setSshKeyFingerprint(action.getSsh().getFingerprint()); } } if (vds.getVdsType()==VDSType.oVirtNode) { params.setIsReinstallOrUpgrade(true); if (action.isSetImage()) { params.setoVirtIsoFile(action.getImage()); } } else { validateParameters(action, "rootPassword"); } return doAction(VdcActionType.UpdateVds, params, action); }
Source:
<code>public void destroy() throws CrafterException { boolean locked; try { logger.debug("Getting write lock for context {}", this); <START> locked = writeLock.tryLock(shutdownTimeout, TimeUnit.MINUTES); <END> if (!locked) { logger.debug("Time out reached, proceeding to destroy context {}", this); } else { logger.debug("All threads released, proceeding to destroy context {}", this); } state = State.DESTROYED; publishEvent(new SiteContextDestroyedEvent(this)); maintenanceTaskExecutor.shutdownNow(); storeService.destroyContext(context); if (scheduler != null) { try { scheduler.shutdown(); } catch (SchedulerException e) { throw new CrafterException("Unable to shutdown scheduler", e); } } if (applicationContext != null) { try { applicationContext.close(); } catch (Exception e) { throw new CrafterException("Unable to close application context", e); } } if (classLoader != null) { try { classLoader.close(); } catch (Exception e) { throw new CrafterException("Unable to close class loader", e); } } } catch (InterruptedException e) { throw new CrafterException("Unable to destroy context", e); } finally { logger.debug("Releasing write lock for context {}", this); writeLock.unlock(); } }</code><technical_language>This try. lock.lock() put try</technical_language>

Target:
public void destroy() throws CrafterException { boolean locked; try { logger.debug("Getting shutdown lock for context {}", this); locked = shutdownLock.tryLock(shutdownTimeout, TimeUnit.MINUTES); try { if (!locked) { logger.debug("Time out reached, proceeding to destroy context {}", this); } else { logger.debug("All threads released, proceeding to destroy context {}", this); } state = State.DESTROYED; publishEvent(new SiteContextDestroyedEvent(this)); maintenanceTaskExecutor.shutdownNow(); storeService.destroyContext(context); if (scheduler != null) { try { scheduler.shutdown(); } catch (SchedulerException e) { throw new CrafterException("Unable to shutdown scheduler", e); } } if (applicationContext != null) { try { applicationContext.close(); } catch (Exception e) { throw new CrafterException("Unable to close application context", e); } } if (classLoader != null) { try { classLoader.close(); } catch (Exception e) { throw new CrafterException("Unable to close class loader", e); } } } catch (Exception e) { logger.error("Error destroying context {}", this, e); } finally { if (locked) { logger.debug("Releasing shutdown lock for context {}", this); shutdownLock.unlock(); } } } catch (InterruptedException e) { throw new CrafterException("Unable to destroy context", e); } }
Source:
<code>private Consumer<String> publish(final MqttMessage message) { return topic -> { try { mqttClient.publish(topic, message).waitForCompletion(); } catch (MqttException e) { <START> e.printStackTrace(); <END> } }; }</code><technical_language>rethrow in a runtime exception</technical_language>

Target:
private Consumer<String> publish(final MqttMessage message) { return topic -> { try { mqttClient.publish(topic, message).waitForCompletion(); } catch (MqttException e) { throw new IllegalStateException(e); } }; }
Source:
<code>public int compareTo(GradleDeployDetails that) { if (this.publishArtifact == null) { return -1; } if (that.publishArtifact == null) { return 1; } <START> if (this.deployDetails.compareTo(that.deployDetails) == 0) { <END> return 0; } String thisExtension = this.publishArtifact.getExtension(); String thatExtension = that.publishArtifact.getExtension(); if (thisExtension == null) { return -1; } if (thatExtension == null) { return 1; } thisExtension = thisExtension.toLowerCase(); if ("xml".equals(thisExtension) || "pom".equals(thisExtension)) { return 1; } thatExtension = thatExtension.toLowerCase(); if ("xml".equals(thatExtension) || "pom".equals(thatExtension)) { return -1; } return this.deployDetails.compareTo(that.deployDetails); }</code><technical_language>compareTo triggers a big string comparison. please save result in a variable reuse in line of function</technical_language>

Target:
public int compareTo(GradleDeployDetails that) { if (this.publishArtifact == null) { return -1; } if (that.publishArtifact == null) { return 1; } int compareDeployDetails = this.deployDetails.compareTo(that.deployDetails); if (compareDeployDetails == 0) { return 0; } String thisExtension = this.publishArtifact.getExtension(); String thatExtension = that.publishArtifact.getExtension(); if (thisExtension == null) { return -1; } if (thatExtension == null) { return 1; } thisExtension = thisExtension.toLowerCase(); if ("xml".equals(thisExtension) || "pom".equals(thisExtension)) { return 1; } thatExtension = thatExtension.toLowerCase(); if ("xml".equals(thatExtension) || "pom".equals(thatExtension)) { return -1; } return compareDeployDetails; }