auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testAsyncBulkActionWithPP() throws IOException { Document root = (Document) session.newRequest(FetchDocument.ID).set("value", "/").execute(); Document folder = (Document) session.newRequest(CreateDocument.ID) .setInput(root) .set("type", "Folder") .set("name", "test") .execute(); Document file = (Document) session.newRequest(CreateDocument.ID) .setInput(folder) .set("type", "File") .set("name", "file") .execute(); <START> HashMap<String, Serializable> automationParams = new HashMap<>(); <END> automationParams.put("properties", "dc:title=foo"); HashMap<String, Serializable> actionParams = new HashMap<>(); actionParams.put(AutomationBulkAction.OPERATION_ID, "Document.Update"); actionParams.put(AutomationBulkAction.OPERATION_PARAMETERS, automationParams); Object r = async.newRequest(BulkRunAction.ID) .set("action", AutomationBulkAction.ACTION_NAME) .set("providerName", "PageProvider") .set("quickFilters", "FileOnly") .set("bucketSize", "10") .set("batchSize", "5") .set("parameters", (new ObjectMapper()).writeValueAsString(actionParams)) .execute(); assertNotNull(r); txFeature.nextTransaction(); folder = (Document) session.newRequest(FetchDocument.ID).set("value", "/test").execute(); file = (Document) session.newRequest(FetchDocument.ID).set("value", "/test/file").execute(); assertEquals("test", folder.getTitle()); assertEquals("foo", file.getTitle()); }</code><technical_language>nitpick: Map,</technical_language>

Target:
public void testAsyncBulkActionWithPP() throws IOException { Document root = (Document) session.newRequest(FetchDocument.ID).set("value", "/").execute(); Document folder = (Document) session.newRequest(CreateDocument.ID) .setInput(root) .set("type", "Folder") .set("name", "test") .execute(); Document file = (Document) session.newRequest(CreateDocument.ID) .setInput(folder) .set("type", "File") .set("name", "file") .execute(); Map<String, Serializable> automationParams = new HashMap<>(); automationParams.put("properties", "dc:title=foo"); Map<String, Serializable> actionParams = new HashMap<>(); actionParams.put(AutomationBulkAction.OPERATION_ID, "Document.Update"); actionParams.put(AutomationBulkAction.OPERATION_PARAMETERS, (Serializable) automationParams); Object r = async.newRequest(BulkRunAction.ID) .set("action", AutomationBulkAction.ACTION_NAME) .set("providerName", "PageProvider") .set("quickFilters", "FileOnly") .set("bucketSize", "10") .set("batchSize", "5") .set("parameters", (new ObjectMapper()).writeValueAsString(actionParams)) .execute(); assertNotNull(r); txFeature.nextTransaction(); folder = (Document) session.newRequest(FetchDocument.ID).set("value", "/test").execute(); file = (Document) session.newRequest(FetchDocument.ID).set("value", "/test/file").execute(); assertEquals("test", folder.getTitle()); assertEquals("foo", file.getTitle()); }
Source:
<code><START> public JSON getPedigree(String id) <END> { Family family = null; Patient patient = this.patientRepository.getPatientById(id); if (patient != null) { family = this.familyRepository.getFamilyForPatient(patient); } else { family = this.familyRepository.getFamilyById(id); } if (family != null) { Pedigree pedigree = family.getPedigree(); if (pedigree != null && !pedigree.isEmpty()) { return pedigree.getData(); } } return new JSONObject(true); }</code><technical_language>return a Pedigree object</technical_language>

Target:
public Pedigree getPedigree(String id) { Family family = null; Patient patient = this.patientRepository.getPatientById(id); if (patient != null) { if (!this.authorizationService.hasAccess(Right.VIEW, patient.getDocument())) { return null; } family = this.familyRepository.getFamilyForPatient(patient); } else { family = this.familyRepository.getFamilyById(id); } if (family != null) { if (!this.authorizationService.hasAccess(Right.VIEW, family.getDocumentReference())) { return null; } Pedigree pedigree = family.getPedigree(); if (pedigree != null && !pedigree.isEmpty()) { if (patient != null) { pedigree.highlightProband(patient); } return pedigree; } } return null; }
Source:
<code>public void actionPerformed(AnActionEvent anActionEvent) { final Project project = anActionEvent.getProject(); if (project == null) { return; } BuckModule buckModule = project.getComponent(BuckModule.class); DataContext dataContext = anActionEvent.getDataContext(); final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext); if (view == null) { return; } final PsiDirectory directory = view.getOrChooseDirectory(); if (directory == null) { return; } String directoryString = directory.getVirtualFile().getPath(); VirtualFile potentialBuckFile = BuckFileUtil.getBuckFile(directory.getVirtualFile()); if (potentialBuckFile != null) { directoryString = potentialBuckFile.getParent().getPath(); } String basepath = project.getBasePath(); if (basepath == null) { return; } String relative = directoryString.replace(basepath, ""); String target = "/" + relative + "/..."; BuckBuildCommandHandler handler = new BuckBuildCommandHandler(project, project.getBaseDir(), BuckCommand.PROJECT); handler.command().addParameter(target); handler.command().addParameter("--ide"); <START> handler.command().addParameter("INTELLIJ"); <END> BuckBuildManager buildManager = BuckBuildManager.getInstance(project); buildManager.setBuilding(project, true); buckModule.attach(target); buildManager.runBuckCommand(handler, "Running buck project on selected groups."); buildManager.setBuilding(project, false); }</code><technical_language>lot of common code this DRY'ed</technical_language>

Target:
public void actionPerformed(AnActionEvent anActionEvent) { final Project project = anActionEvent.getProject(); if (project == null) { return; } DataContext dataContext = anActionEvent.getDataContext(); final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext); if (view == null) { return; } final PsiDirectory directory = view.getOrChooseDirectory(); if (directory == null) { return; } String directoryString = directory.getVirtualFile().getPath(); VirtualFile potentialBuckFile = BuckFileUtil.getBuckFile(directory.getVirtualFile()); if (potentialBuckFile != null) { directoryString = potentialBuckFile.getParent().getPath(); } String basepath = project.getBasePath(); if (basepath == null) { return; } String relative = directoryString.replace(basepath, ""); String target = "/" + relative + "/..."; SelectProjectUtils.generateTargetForProject(target, project); }
Source:
<code>public void setUp() throws Exception { secretContentDAO = testDBRule.getDbi().onDemand(SecretContentDAO.class); testDBRule.jooqContext().delete(SECRETS).execute(); testDBRule.jooqContext().insertInto(SECRETS, SECRETS.ID, SECRETS.NAME) <START> .values((int) secretContent1.secretSeriesId(), "secretName") <END> .execute(); testDBRule.jooqContext().insertInto(SECRETS_CONTENT) .set(SECRETS_CONTENT.ID, (int) secretContent1.id()) .set(SECRETS_CONTENT.SECRETID, (int) secretContent1.secretSeriesId()) .set(SECRETS_CONTENT.ENCRYPTED_CONTENT, secretContent1.encryptedContent()) .set(SECRETS_CONTENT.VERSION, secretContent1.version().orElse(null)) .set(SECRETS_CONTENT.CREATEDAT, secretContent1.createdAt()) .set(SECRETS_CONTENT.CREATEDBY, secretContent1.createdBy()) .set(SECRETS_CONTENT.UPDATEDAT, secretContent1.updatedAt()) .set(SECRETS_CONTENT.UPDATEDBY, secretContent1.updatedBy()) .execute(); }</code><technical_language>add content table</technical_language>

Target:
public void setUp() throws Exception { secretContentDAO = testDBRule.getDbi().onDemand(SecretContentDAO.class); testDBRule.jooqContext().delete(SECRETS).execute(); testDBRule.jooqContext().insertInto(SECRETS, SECRETS.ID, SECRETS.NAME) .values((int) secretContent1.secretSeriesId(), "secretName") .execute(); testDBRule.jooqContext().insertInto(SECRETS_CONTENT) .set(SECRETS_CONTENT.ID, (int) secretContent1.id()) .set(SECRETS_CONTENT.SECRETID, (int) secretContent1.secretSeriesId()) .set(SECRETS_CONTENT.ENCRYPTED_CONTENT, secretContent1.encryptedContent()) .set(SECRETS_CONTENT.VERSION, secretContent1.version().orElse(null)) .set(SECRETS_CONTENT.CREATEDAT, secretContent1.createdAt()) .set(SECRETS_CONTENT.CREATEDBY, secretContent1.createdBy()) .set(SECRETS_CONTENT.UPDATEDAT, secretContent1.updatedAt()) .set(SECRETS_CONTENT.UPDATEDBY, secretContent1.updatedBy()) .set(SECRETS_CONTENT.METADATA, "{}") .execute(); }
Source:
<code>public int compare( RemoteRepository r1, RemoteRepository r2 ) { if ( r1 == null ) { return 1; } if ( r2 == null ) { return -1; } final int priorityCompareResult = r2.getPrefetchPriority() - r1.getPrefetchPriority(); if ( StringUtils.isBlank( r1.getPrefetchRescanTimestamp() ) && StringUtils.isBlank( r2.getPrefetchRescanTimestamp() ) ) { return priorityCompareResult; } if ( StringUtils.isBlank( r1.getPrefetchRescanTimestamp() ) && StringUtils.isNotBlank( r2.getPrefetchRescanTimestamp() ) ) { return -1; } else if ( StringUtils.isBlank( r2.getPrefetchRescanTimestamp() ) && StringUtils.isNotBlank( r1.getPrefetchRescanTimestamp() ) ) { return 1; } final ZonedDateTime rescanTime1 = <START> ZonedDateTime.parse( r1.getPrefetchRescanTimestamp(), DateTimeFormatter.ISO_ZONED_DATE_TIME ); <END> final ZonedDateTime rescanTime2 = ZonedDateTime.parse( r2.getPrefetchRescanTimestamp(), DateTimeFormatter.ISO_ZONED_DATE_TIME ); if ( rescanTime1.isBefore( rescanTime2 ) ) { return -1; } else if ( rescanTime1.isAfter( rescanTime2 ) ) { return 1; } else { return priorityCompareResult; } }</code><technical_language>sense store timestamps in UTC</technical_language>

Target:
public int compare( RemoteRepository r1, RemoteRepository r2 ) { if ( r1 == null ) { return 1; } if ( r2 == null ) { return -1; } final int priorityCompareResult = r2.getPrefetchPriority() - r1.getPrefetchPriority(); if ( StringUtils.isBlank( r1.getPrefetchRescanTimestamp() ) && StringUtils.isBlank( r2.getPrefetchRescanTimestamp() ) ) { return priorityCompareResult; } if ( StringUtils.isBlank( r1.getPrefetchRescanTimestamp() ) && StringUtils.isNotBlank( r2.getPrefetchRescanTimestamp() ) ) { return -1; } else if ( StringUtils.isBlank( r2.getPrefetchRescanTimestamp() ) && StringUtils.isNotBlank( r1.getPrefetchRescanTimestamp() ) ) { return 1; } final ZonedDateTime rescanTime1 = ZonedDateTime.parse( r1.getPrefetchRescanTimestamp(), RescanTimeUtils.UTC_TIME_FORMATTER ); final ZonedDateTime rescanTime2 = ZonedDateTime.parse( r2.getPrefetchRescanTimestamp(), RescanTimeUtils.UTC_TIME_FORMATTER ); if ( rescanTime1.isBefore( rescanTime2 ) ) { return -1; } else if ( rescanTime1.isAfter( rescanTime2 ) ) { return 1; } else { return priorityCompareResult; } }
Source:
<code>public void afterWalk( final WalkerContext context ) throws Exception { for ( Map.Entry<Gav, Map<Version, List<StorageFileItem>>> gavListEntry : gas.entrySet() ) { Map<Version, List<StorageFileItem>> versions = gavListEntry.getValue(); if ( versions.size() > request.getNumberOfVersionsToKeep() ) { getLogger().debug( "{} will delete versions of artifact with g={} a ={}", ReleaseRemovalTaskDescriptor.ID, versions.size() - request.getNumberOfVersionsToKeep(), <START> gavListEntry.getKey().getGroupId(), gavListEntry.getKey().getArtifactId() ); <END> List<Version> sortedVersions = Lists.newArrayList( versions.keySet() ); Collections.sort( sortedVersions ); List<Version> toDelete = sortedVersions.subList( 0, versions.size() - request.getNumberOfVersionsToKeep() ); getLogger().debug( "Will delete these specific versions: {}", toDelete ); for ( Version version : toDelete ) { for ( StorageFileItem storageFileItem : versions.get( version ) ) { repository.deleteItem( createResourceStoreRequest( storageFileItem, context ) ); deletedFiles++; } } if ( context.getContext().containsKey( POSSIBLY_EMPTY_COLLECTIONS ) ) { for ( StorageCollectionItem coll : (List<StorageCollectionItem>) context.getContext().get( POSSIBLY_EMPTY_COLLECTIONS ) ) { removeDirectoryIfEmpty( repository, coll ); } } } } result.setDeletedFileCount( deletedFiles ); result.setSuccessful( true ); }</code><technical_language>'a ={}' -> 'a={}'</technical_language>

Target:
public void afterWalk( final WalkerContext context ) throws Exception { for ( Map.Entry<Gav, Map<Version, List<StorageFileItem>>> gavListEntry : groupArtifactToVersions.entrySet() ) { Map<Version, List<StorageFileItem>> versions = gavListEntry.getValue(); if ( versions.size() > request.getNumberOfVersionsToKeep() ) { getLogger().debug( "{} will delete versions of artifact with g={} a={}", ReleaseRemovalTaskDescriptor.ID, versions.size() - request.getNumberOfVersionsToKeep(), gavListEntry.getKey().getGroupId(), gavListEntry.getKey().getArtifactId() ); List<Version> sortedVersions = Lists.newArrayList( versions.keySet() ); Collections.sort( sortedVersions ); List<Version> toDelete = sortedVersions.subList( 0, versions.size() - request.getNumberOfVersionsToKeep() ); getLogger().debug( "Will delete these specific versions: {}", toDelete ); for ( Version version : toDelete ) { for ( StorageFileItem storageFileItem : versions.get( version ) ) { repository.deleteItem( createResourceStoreRequest( storageFileItem, context ) ); deletedFiles++; } } if ( context.getContext().containsKey( POSSIBLY_EMPTY_COLLECTIONS ) ) { for ( StorageCollectionItem coll : (List<StorageCollectionItem>) context.getContext().get( POSSIBLY_EMPTY_COLLECTIONS ) ) { removeDirectoryIfEmpty( repository, coll ); } } } } result.setDeletedFileCount( deletedFiles ); result.setSuccessful( true ); }
Source:
<code>public void getPatientNotFoundChecksForMultipleRecords() throws ComponentLookupException, QueryException, XWikiRestException { Query query = mock(DefaultQuery.class); when(this.repository.getPatientByExternalId(this.eid)).thenReturn(null); when(this.qm.createQuery(Matchers.anyString(), Matchers.anyString())).thenReturn(query); <START> when(query.execute()).thenReturn(new ArrayList<Object>()); <END> Response response = this.component.getPatient(this.eid); verify(this.logger).debug("No patient record with external ID exists yet", this.eid); assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus()); }</code><technical_language>Try testing for condition query returns a list of size > 1</technical_language>

Target:
public void getPatientNotFoundChecksForMultipleRecords() throws ComponentLookupException, QueryException { Query query = mock(DefaultQuery.class); when(this.repository.getPatientByExternalId(this.eid)).thenReturn(null); when(this.qm.createQuery(Matchers.anyString(), Matchers.anyString())).thenReturn(query); when(query.execute()).thenReturn(new ArrayList<Object>()); Response response = this.component.getPatient(this.eid); verify(this.logger).debug("No patient record with external ID exists yet", this.eid); assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus()); }
Source:
<code>public TaskContext addTaskContext(TaskStateMachine taskStateMachine, Session session, boolean verboseStats, boolean cpuTimerEnabled) { MemoryTrackingContext taskMemoryContext; synchronized (this) { <START> taskMemoryContext = queryMemoryContext.newMemoryTrackingContext(); <END> } TaskContext taskContext = TaskContext.createTaskContext( this, taskStateMachine, notificationExecutor, yieldExecutor, session, taskMemoryContext, verboseStats, cpuTimerEnabled); taskContexts.put(taskStateMachine.getTaskId(), taskContext); return taskContext; }</code><technical_language>queryMemoryContext is final @ThreadSafe. is this synchronization for</technical_language>

Target:
public TaskContext addTaskContext(TaskStateMachine taskStateMachine, Session session, boolean verboseStats, boolean cpuTimerEnabled) { TaskContext taskContext = TaskContext.createTaskContext( this, taskStateMachine, notificationExecutor, yieldExecutor, session, queryMemoryContext.newMemoryTrackingContext(), verboseStats, cpuTimerEnabled); taskContexts.put(taskStateMachine.getTaskId(), taskContext); return taskContext; }
Source:
<code>private void deleteAssignmentsFromPersistence(List<Assignment> assignments) { preparePersistenceAccess(); EKBCommit commit = getEKBCommit(); for (Assignment assignment : assignments) { <START> List<Role> result = queryService.queryByString(Role.class, "uuid:\"" + assignment.getUuid() + "\""); <END> if (result.size() == 0) { LOGGER.warn("User {1} does not exist.", assignment.getUuid()); } else { commit.addDelete(assignment); } } persistService.commit(commit); revokePersistenceAccess(); }</code><technical_language>query(QueryRequest) method</technical_language>

Target:
private void deleteAssignmentsFromPersistence(List<Assignment> assignments) { preparePersistenceAccess(); EKBCommit commit = getEKBCommit(); for (Assignment assignment : assignments) { List<Role> result = queryService.query(Role.class, QueryRequest.query("uuid", assignment.getUuid())); if (result.size() == 0) { LOGGER.warn("User {1} does not exist.", assignment.getUuid()); } else { commit.addDelete(assignment); } } persistService.commit(commit); revokePersistenceAccess(); }
Source:
<code>public static CommentService getInstance() { if (Objects.equals(instance, null)) { <START> synchronized (TaskService.class) { <END> if (Objects.equals(instance, null)) { instance = new CommentService(); } } } return instance; }</code><technical_language>Wrong class (TaskService?)</technical_language>

Target:
public static CommentService getInstance() { if (Objects.equals(instance, null)) { synchronized (CommentService.class) { if (Objects.equals(instance, null)) { instance = new CommentService(); } } } return instance; }
Source:
<code>public void testDeployableFeature() throws Exception { Verifier v01 = getVerifier("TYCHO0439repositoryCategories"); v01.executeGoal("install"); v01.verifyErrorFreeLog(); File site = new File(v01.getBasedir(), "target/site"); Assert.assertTrue(site.isDirectory()); File content = new File(site, "content.jar"); Assert.assertTrue(content.isFile()); boolean found = false; XMLParser parser = new XMLParser(); Document document = null; ZipUnArchiver contentJar = new ZipUnArchiver(content); <START> TemporaryFolder tempFolder = new TemporaryFolder(); <END> tempFolder.create(); try { contentJar.extract("content.xml", tempFolder.getRoot()); document = parser.parse(new XMLIOSource(new File(tempFolder.getRoot(), "content.xml"))); } finally { tempFolder.delete(); } Element repository = document.getRootElement(); all_units: for (Element unit : repository.getChild("units").getChildren("unit")) { for (Element property : unit.getChild("properties").getChildren("property")) { if ("org.eclipse.equinox.p2.type.category".equals(property.getAttributeValue("name")) && Boolean.parseBoolean(property.getAttributeValue("value"))) { found = true; break all_units; } } } Assert.assertTrue("Custom category", found); }</code><technical_language>simply a field @Rule, temp folder deleted automatically teardown</technical_language>

Target:
public void testDeployableFeature() throws Exception { Verifier v01 = getVerifier("TYCHO0439repositoryCategories"); v01.executeGoal("install"); v01.verifyErrorFreeLog(); File site = new File(v01.getBasedir(), "target/site"); Assert.assertTrue(site.isDirectory()); File content = new File(site, "content.jar"); Assert.assertTrue(content.isFile()); boolean found = false; XMLParser parser = new XMLParser(); Document document = null; ZipFile contentJar = new ZipFile(content); try { ZipEntry entry = contentJar.getEntry("content.xml"); document = parser.parse(new XMLIOSource(contentJar.getInputStream(entry))); } finally { contentJar.close(); } Element repository = document.getRootElement(); all_units: for (Element unit : repository.getChild("units").getChildren("unit")) { for (Element property : unit.getChild("properties").getChildren("property")) { if ("org.eclipse.equinox.p2.type.category".equals(property.getAttributeValue("name")) && Boolean.parseBoolean(property.getAttributeValue("value"))) { found = true; break all_units; } } } Assert.assertTrue("Custom category", found); }
Source:
<code>static TabData getTabData(ClientGinjector ginjector) { <START> return new ModelBoundTabData(ginjector.getApplicationConstants().hostBiosSubTabLabel(), 5, <END> ginjector.getSubTabHostBiosModelProvider()); }</code><technical_language>SubTabHostEventPresenter -> getTabData() priority pushed 6 (it is currently 5)</technical_language>

Target:
static TabData getTabData(ClientGinjector ginjector) { return new ModelBoundTabData(ginjector.getApplicationConstants().hostBiosSubTabLabel(), 6, ginjector.getSubTabHostBiosModelProvider()); }
Source:
<code>public void guestbookResponseValidator(FacesContext context, UIComponent toValidate, Object value) { String response = (String) value; if (response != null && response.length() > 255) { <START> ((EditableValueHolder) toValidate).setValid(false); <END> FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, JH.localize("dataset.guestbookResponse.guestbook.responseTooLong"), null); context.addMessage(toValidate.getClientId(context), message); } }</code><technical_language>explain this change</technical_language>

Target:
public void guestbookResponseValidator(FacesContext context, UIComponent toValidate, Object value) { String response = (String) value; if (response != null && response.length() > 255) { ((UIInput) toValidate).setValid(false); FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, JH.localize("dataset.guestbookResponse.guestbook.responseTooLong"), null); context.addMessage(toValidate.getClientId(context), message); } }
Source:
<code>private void checkRequiredHeadings(CSVRecord headingRecord) throws ValidationException { List<String> missingRequiredHeadings = Headings.getRequiredHeadings().stream() .filter(heading -> !uploadUtil.hasHeading(heading, headingRecord)) .map(headingVal -> headingVal.getNamesAsString()) .collect(Collectors.toList()); <START> if (missingRequiredHeadings != null && missingRequiredHeadings.size() > 0) { <END> throw new ValidationException(msgUtil.getMessage("listing.upload.missingRequiredHeadings", String.join("; ", missingRequiredHeadings))); } }</code><technical_language>I Collecters.toList() return NULL, null check is necessary. big deal</technical_language>

Target:
private void checkRequiredHeadings(CSVRecord headingRecord) throws ValidationException { List<String> missingRequiredHeadings = Headings.getRequiredHeadings().stream() .filter(heading -> !uploadUtil.hasHeading(heading, headingRecord)) .map(headingVal -> headingVal.getNamesAsString()) .collect(Collectors.toList()); if (missingRequiredHeadings.size() > 0) { throw new ValidationException(msgUtil.getMessage("listing.upload.missingRequiredHeadings", String.join("; ", missingRequiredHeadings))); } }
Source:
<code>private WorkingSetDescriptor getSelectedWorkingSet() { IStructuredSelection selection = typesListViewer.getStructuredSelection(); <START> boolean hasSelection = !selection.isEmpty(); <END> WorkingSetDescriptor descriptor = null; if (hasSelection) { descriptor = (WorkingSetDescriptor) selection .getFirstElement(); } return descriptor; }</code><technical_language>remove local variable</technical_language>

Target:
private WorkingSetDescriptor getSelectedWorkingSet() { IStructuredSelection selection = typesListViewer.getStructuredSelection(); WorkingSetDescriptor descriptor = null; if (!selection.isEmpty()) { descriptor = (WorkingSetDescriptor) selection.getFirstElement(); } return descriptor; }
Source:
<code>public IMetadataRepository createRepository(URI location, String name, String type, Map<String, String> properties) throws ProvisionException, OperationCanceledException { <START> return delegate.createRepository(location, name, type, properties); <END> }</code><technical_language>this a difference right (because memory: URIs translated) this return delegate.createRepository(translate(location), name, type, properties); for consistency</technical_language>

Target:
public IMetadataRepository createRepository(URI location, String name, String type, Map<String, String> properties) throws ProvisionException, OperationCanceledException { return delegate.createRepository(translate(location), name, type, properties); }
Source:
<code>public <T> T instantiateInFramework(Class<? extends T> clazz) { try { clazz.getConstructor(); } catch (NoSuchMethodException e) { Exceptions.duck(e); } Bundle b = bundle().addResourceWithCopy(clazz) .start(); try { @SuppressWarnings("unchecked") Class<? extends T> insideClass = (Class<? extends T>) b.loadClass(clazz.getName()); <START> return insideClass.newInstance(); <END> } catch (Exception e) { throw Exceptions.duck(e); } }</code><technical_language>This return insideClass.getConstructor().newInstance();</technical_language>

Target:
public <T> T instantiateInFramework(Class<? extends T> clazz) { try { clazz.getConstructor(); } catch (NoSuchMethodException e) { Exceptions.duck(e); } Bundle b = bundle().addResourceWithCopy(clazz) .start(); try { @SuppressWarnings("unchecked") Class<? extends T> insideClass = (Class<? extends T>) b.loadClass(clazz.getName()); return insideClass.getConstructor() .newInstance(); } catch (Exception e) { throw Exceptions.duck(e); } }
Source:
<code>public LinuxSecretServiceAccess() { <START> try { <END> gnomeLoginKeyring = new SimpleCollection(); } catch (Exception e) { } }</code><technical_language>java SimpleCollection keyring = null; try { keyring = new SimpleCollection(); } catch (Exception e) { // Accessing secret-service DBus API failed } finally { gnomeLoginKeyring = Optional.ofNullable(keyring); }</technical_language>

Target:
public LinuxSecretServiceAccess() { SimpleCollection keyring = null; try { keyring = new SimpleCollection(); } catch (Exception e) { } finally { gnomeLoginKeyring = Optional.ofNullable(keyring); } }
Source:
<code>void verifyMessage(Message message) { if (!message.getMsgType().toString().equalsIgnoreCase(MessageType.TASK_REPLY.name())) { String errorMsg = "Unexpected msg type for message " + message.getMsgId() + " type:" + message.getMsgType() + " Expected : " + MessageType.TASK_REPLY; _logger.error(errorMsg); throw new HelixException(errorMsg); } String correlationId = message.getCorrelationId(); if (correlationId == null) { String errorMsg = "Message " + message.getMsgId() + " does not have correlation id"; _logger.error(errorMsg); throw new HelixException(errorMsg); } <START> <END> _logger.info("Verified reply message " + message.getMsgId() + " correlation:" + correlationId); }</code><technical_language>Alternatively, if exception is graceful, return null createHandler() is triggered. This is returning a handler (but consume system resources). Of course, callers of createHandler() need improved tolerate null return value</technical_language>

Target:
void verifyMessage(Message message) { if (!message.getMsgType().toString().equalsIgnoreCase(MessageType.TASK_REPLY.name())) { String errorMsg = "Unexpected msg type for message " + message.getMsgId() + " type:" + message.getMsgType() + " Expected : " + MessageType.TASK_REPLY; _logger.error(errorMsg); throw new HelixException(errorMsg); } String correlationId = message.getCorrelationId(); if (correlationId == null) { String errorMsg = "Message " + message.getMsgId() + " does not have correlation id"; _logger.error(errorMsg); throw new HelixException(errorMsg); } if (!_callbackMap.containsKey(correlationId)) { String errorMsg = "Message " + message.getMsgId() + " does not have correponding callback. Probably timed out already. Correlation id: " + correlationId; _logger.error(errorMsg); throw new HelixException(errorMsg, false); } _logger.info("Verified reply message " + message.getMsgId() + " correlation:" + correlationId); }
Source:
<code>public LicensedVideoSwapPageObject(WebDriver driver) { super(driver); <START> PageFactory.initElements(driver, this); <END> }</code><technical_language>remove this</technical_language>

Target:
public LicensedVideoSwapPageObject(WebDriver driver) { super(driver); }
Source:
<code>public Response add(Cluster cluster) { <START> validateParameters(cluster, "name", "dataCenter.name|id"); <END> validateEnums(Cluster.class, cluster); storage_pool pool = getStoragePool(cluster, this); VDSGroup entity = map(cluster, map(pool)); return performCreate(VdcActionType.AddVdsGroup, new VdsGroupOperationParameters(entity), new QueryIdResolver<Guid>(VdcQueryType.GetVdsGroupById, GetVdsGroupByIdParameters.class)); }</code><technical_language>do need/force "dataCenter.name|id" parameter? in context of DC</technical_language>

Target:
public Response add(Cluster cluster) { validateParameters(cluster, "name"); validateEnums(Cluster.class, cluster); DataCenter dataCenter = new DataCenter(); dataCenter.setId(dataCenterId.toString()); cluster.setDataCenter(dataCenter); storage_pool pool = getStoragePool(cluster, this); VDSGroup entity = map(cluster, map(pool)); return performCreate(VdcActionType.AddVdsGroup, new VdsGroupOperationParameters(entity), new QueryIdResolver<Guid>(VdcQueryType.GetVdsGroupById, GetVdsGroupByIdParameters.class)); }
Source:
<code>public Block mapFromEntries( @TypeParameter("row(K,V)") RowType rowType, @SqlType("map(K,V)") Block block) { verify(rowType.getTypeParameters().size() == 2); Type keyType = rowType.getTypeParameters().get(0); Type valueType = rowType.getTypeParameters().get(1); ArrayType arrayType = new ArrayType(rowType); if (pageBuilder.isFull()) { pageBuilder.reset(); } verify((block.getPositionCount() & 1) == 0); int entryCount = block.getPositionCount() / 2; BlockBuilder arrayBlockBuilder = pageBuilder.getBlockBuilder(0); <START> BlockBuilder resultBuilder = arrayBlockBuilder.beginBlockEntry(); <END> for (int i = 0; i < entryCount; i++) { BlockBuilder rowBuilder = resultBuilder.beginBlockEntry(); keyType.appendTo(block, 2 * i, rowBuilder); valueType.appendTo(block, 2 * i + 1, rowBuilder); resultBuilder.closeEntry(); } arrayBlockBuilder.closeEntry(); pageBuilder.declarePosition(); return arrayType.getObject(arrayBlockBuilder, arrayBlockBuilder.getPositionCount() - 1); }</code><technical_language>I call entryBuilder :)</technical_language>

Target:
public Block mapFromEntries( @TypeParameter("row(K,V)") RowType rowType, @SqlType("map(K,V)") Block block) { verify(rowType.getTypeParameters().size() == 2); verify(block.getPositionCount() % 2 == 0); Type keyType = rowType.getTypeParameters().get(0); Type valueType = rowType.getTypeParameters().get(1); ArrayType arrayType = new ArrayType(rowType); if (pageBuilder.isFull()) { pageBuilder.reset(); } int entryCount = block.getPositionCount() / 2; BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(0); BlockBuilder entryBuilder = blockBuilder.beginBlockEntry(); for (int i = 0; i < entryCount; i++) { BlockBuilder rowBuilder = entryBuilder.beginBlockEntry(); keyType.appendTo(block, 2 * i, rowBuilder); valueType.appendTo(block, 2 * i + 1, rowBuilder); entryBuilder.closeEntry(); } blockBuilder.closeEntry(); pageBuilder.declarePosition(); return arrayType.getObject(blockBuilder, blockBuilder.getPositionCount() - 1); }
Source:
<code>public DialectEditorCloserFilter(DRepresentationDescriptor dRepresentationDescriptor) { <START> this.dRepDescriptor = dRepresentationDescriptor; <END> }</code><technical_language>add assertNotNull detet soon potential problems</technical_language>

Target:
public DialectEditorCloserFilter(DRepresentationDescriptor dRepresentationDescriptor) { Assert.isNotNull(dRepresentationDescriptor); this.dRepDescriptor = dRepresentationDescriptor; }
Source:
<code>private void validateVolumeCount(VolumeTemplate value, VmType vmType, VolumeParameterType volumeParameterType, ValidationResult.ValidationResultBuilder validationBuilder, InstanceGroup instanceGroup) { if (vmType != null && needToCheckVolume(volumeParameterType, value.getVolumeCount())) { VolumeParameterConfig config = vmType.getVolumeParameterbyVolumeParameterType(volumeParameterType); <START> if (config != null) { <END> if (value.getVolumeCount() > config.maximumNumber()) { validationBuilder.error(String.format("Max allowed volume count for '%s': %s", vmType.value(), config.maximumNumber())); } else if (isIDBrokerInstanceGroup(instanceGroup)) { if (value.getVolumeCount() != 0) { validationBuilder.error(String.format("IDBroker volume count: %s is not zero", value.getVolumeCount())); } } else if (value.getVolumeCount() < config.minimumNumber()) { validationBuilder.error(String.format("Min allowed volume count for '%s': %s", vmType.value(), config.minimumNumber())); } } else { validationBuilder.error(String.format("The '%s' instance type does not support 'Ephemeral' volume type", vmType.value())); } } }</code><technical_language>Update error message state IDBroker data volume expecting zero</technical_language>

Target:
private void validateVolumeCount(VolumeTemplate value, VmType vmType, VolumeParameterType volumeParameterType, ValidationResult.ValidationResultBuilder validationBuilder, InstanceGroup instanceGroup) { if (vmType != null && needToCheckVolume(volumeParameterType, value.getVolumeCount())) { VolumeParameterConfig config = vmType.getVolumeParameterbyVolumeParameterType(volumeParameterType); if (config != null) { if (value.getVolumeCount() > config.maximumNumber()) { validationBuilder.error(String.format("Max allowed volume count for '%s': %s", vmType.value(), config.maximumNumber())); } else if (!isIDBrokerInstanceGroup(instanceGroup) && value.getVolumeCount() < config.minimumNumber()) { validationBuilder.error(String.format("Min allowed volume count for '%s': %s", vmType.value(), config.minimumNumber())); } } else { validationBuilder.error(String.format("The '%s' instance type does not support 'Ephemeral' volume type", vmType.value())); } } }
Source:
<code>public String toString() { <START> return MoreObjects.toStringHelper(this) <END> .add("name", name) .add("columnName", columnName) .add("expression", expressionStr) .toString(); }</code><technical_language>here, pls string concat instead</technical_language>

Target:
public String toString() { return "CheckConstraint{" + "name='" + name + '\'' + ", columnName='" + columnName + '\'' + ", expression=" + expression + '}'; }
Source:
<code>@Nullable @Override protected MetadataMarshalled reduce0(List<ComputeJobResult> results) { <START> if (results.get(0).getException() != null) <END> throw results.get(0).getException(); else return results.get(0).getData(); }</code><technical_language>result size is checked here</technical_language>

Target:
@Nullable @Override protected MetadataMarshalled reduce0(List<ComputeJobResult> results) { if (results.size() != 1) throw new IgniteException("Invalid job results. Expected exactly 1 result, but was: " + results); if (results.get(0).getException() != null) throw results.get(0).getException(); else return results.get(0).getData(); }
Source:
<code>public void shutdown() { <START> if (acceptTasks.getAndSet(false)) { <END> queue.submit(new Runnable() { @Override public void run() { db.close(); } }); queue.shutdown(); try { queue.awaitTermination(5, TimeUnit.MINUTES); } catch (InterruptedException e) { logger.log(Level.SEVERE, "Interrupted while waiting for queue to terminate", e); } } }</code><technical_language>Do a warning if shutdown is called more once? discussed harmless a warning spot bad patterns in client code</technical_language>

Target:
public void shutdown() { if (acceptTasks.getAndSet(false)) { queue.submit(new Runnable() { @Override public void run() { db.close(); } }); queue.shutdown(); try { queue.awaitTermination(5, TimeUnit.MINUTES); } catch (InterruptedException e) { logger.log(Level.SEVERE, "Interrupted while waiting for queue to terminate", e); } } else { logger.log(Level.WARNING, "Database is already closed."); } }
Source:
<code>private static List<IFile> getWorkspaceFiles(final IResource[] resources) throws CoreException { final List<IFile> files = new ArrayList<IFile>(); for (int i = 0; i < resources.length; i++) { final IResource resource = resources[i]; <START> if (resource.isAccessible()) { <END> if (resource instanceof IFile) { IFile file = (IFile) resource; file.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor()); if (resource.exists()) { files.add(file); } } else if (resource instanceof IContainer) { files.addAll(getWorkspaceFiles(((IContainer) resource).members())); } } } return files; }</code><technical_language>IsAccessible is equivalent of isExist refresh done</technical_language>

Target:
private static List<IFile> getWorkspaceFiles(final IResource[] resources) throws CoreException { final List<IFile> files = new ArrayList<IFile>(); for (int i = 0; i < resources.length; i++) { final IResource resource = resources[i]; resource.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor()); if (resource.isAccessible()) { if (resource instanceof IFile) { IFile file = (IFile) resource; files.add(file); } else if (resource instanceof IContainer) { files.addAll(getWorkspaceFiles(((IContainer) resource).members())); } } } return files; }
Source:
<code>protected List<OrganizationType> getAllOrganizations() { List<OrganizationType> organizations = null; try { <START> organizations = WebServiceProxyHelper.getAllOrganizationsByMerge(); <END> } catch (ExchangeManagerException ex) { LOG.error("Exception while retrieving Exchange-Organization: {}", ex.getLocalizedMessage(), ex); } return organizations; }</code><technical_language>need merge internalExchangeInfo exchangeInfo. Remove merge WebserviceProxy, ExchangeManagerHelper related code</technical_language>

Target:
protected List<OrganizationType> getAllOrganizations() { List<OrganizationType> organizations = null; try { organizations = WebServiceProxyHelper.getGatewayAllOrganizations(); } catch (ExchangeManagerException ex) { LOG.error("Exception while retrieving Exchange-Organization: {}", ex.getLocalizedMessage(), ex); } return organizations; }
Source:
<code>public void persist(final OCFLPersistentStorageSession session, final ResourceOperation operation) throws PersistentStorageException { final var mapping = getMapping(operation.getResourceId()); final var fedoraResourceRoot = mapping.getRootObjectIdentifier(); final var resourceId = operation.getResourceId(); final var objectSession = session.findOrCreateSession(mapping.getOcflObjectId()); log.debug("Deleting from {}", resourceId, mapping.getOcflObjectId()); if (fedoraResourceRoot.equals(resourceId)) { try { objectSession.listHeadSubpaths().filter(p -> !isSidecarSubpath(p)).forEach( p -> deletePathWrapped(p, objectSession)); } catch (final PersistentStorageRuntimeException exc) { <START> throw new PersistentStorageException(exc.getCause().getMessage()); <END> } } else { final var relativeSubPath = relativizeSubpath(fedoraResourceRoot, operation.getResourceId()); final var ocflSubPath = resolveOCFLSubpath(fedoraResourceRoot, relativeSubPath); final var headers = (ResourceHeadersImpl) readHeaders(objectSession, ocflSubPath); final boolean isRdf = !Objects.equals(NON_RDF_SOURCE.toString(), headers.getInteractionModel()); final var filePath = resolveExtensions(ocflSubPath, isRdf); deletePath(filePath, objectSession, headers); if (!isRdf) { final var descPath = resolveExtensions(ocflSubPath + "-description", true); deletePath(descPath, objectSession); } } }</code><technical_language>rethrowing exception message stacktrace? debugging harder</technical_language>

Target:
public void persist(final OCFLPersistentStorageSession session, final ResourceOperation operation) throws PersistentStorageException { final var mapping = getMapping(operation.getResourceId()); final var fedoraResourceRoot = mapping.getRootObjectIdentifier(); final var resourceId = operation.getResourceId(); final var objectSession = session.findOrCreateSession(mapping.getOcflObjectId()); final var user = operation.getUserPrincipal(); final var deleteTime = Instant.now(); log.debug("Deleting from {}", resourceId, mapping.getOcflObjectId()); if (fedoraResourceRoot.equals(resourceId)) { try { objectSession.listHeadSubpaths().filter(p -> !isSidecarSubpath(p)).forEach( p -> deletePathWrapped(p, objectSession, user, deleteTime)); } catch (final PersistentStorageRuntimeException exc) { throw new PersistentStorageException(exc); } } else { final var relativeSubPath = relativizeSubpath(fedoraResourceRoot, operation.getResourceId()); final var ocflSubPath = resolveOCFLSubpath(fedoraResourceRoot, relativeSubPath); final var headers = (ResourceHeadersImpl) readHeaders(objectSession, ocflSubPath); final boolean isRdf = !Objects.equals(NON_RDF_SOURCE.toString(), headers.getInteractionModel()); final var filePath = resolveExtensions(ocflSubPath, isRdf); deletePath(filePath, objectSession, headers, user, deleteTime); if (!isRdf) { final var descPath = resolveExtensions(ocflSubPath + "-description", true); deletePath(descPath, objectSession, user, deleteTime); } } }
Source:
<code>public void onMovieSelected(MovieListFragment.ViewHolder vh) { selectedMovieTitle = vh.movieTitle; selectedMovieId = vh.movieId; if (Utils.isLollipopOrLater()) { MovieDetailsFragment movieDetailsFragment = MovieDetailsFragment.newInstance(vh); FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction(); movieDetailsFragment.setEnterTransition(TransitionInflater .from(this) .inflateTransition(R.transition.media_details)); movieDetailsFragment.setSharedElementReturnTransition(TransitionInflater.from( this).inflateTransition(R.transition.change_image)); movieDetailsFragment.setSharedElementEnterTransition(TransitionInflater.from( <START> this).inflateTransition(R.transition.change_image)); <END> fragTrans.replace(R.id.fragment_container, movieDetailsFragment) .addToBackStack(null) .addSharedElement(vh.artView, vh.artView.getTransitionName()) .commit(); } else { MovieDetailsFragment movieDetailsFragment = MovieDetailsFragment.newInstance(vh); FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction(); fragTrans.setCustomAnimations(R.anim.fragment_details_enter, 0, R.anim.fragment_list_popenter, 0); fragTrans.replace(R.id.fragment_container, movieDetailsFragment) .addToBackStack(null) .commit(); } setupActionBar(selectedMovieTitle); }</code><technical_language>Simple refactor 2 instructions: Transition changeImageTransition = TransitionInflater.from(this).inflateTransition(R.transition.change_image); movieDetailsFragment.setSharedElementReturnTransition(changeImageTransition); movieDetailsFragment.setSharedElementEnterTransition(changeImageTransition);</technical_language>

Target:
public void onMovieSelected(MovieListFragment.ViewHolder vh) { selectedMovieTitle = vh.movieTitle; selectedMovieId = vh.movieId; if (Utils.isLollipopOrLater()) { MovieDetailsFragment movieDetailsFragment = MovieDetailsFragment.newInstance(vh); FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction(); movieDetailsFragment.setEnterTransition(TransitionInflater .from(this) .inflateTransition(R.transition.media_details)); movieDetailsFragment.setReturnTransition(null); Transition changeImageTransition = TransitionInflater.from( this).inflateTransition(R.transition.change_image); movieDetailsFragment.setSharedElementReturnTransition(changeImageTransition); movieDetailsFragment.setSharedElementEnterTransition(changeImageTransition); fragTrans.replace(R.id.fragment_container, movieDetailsFragment) .addToBackStack(null) .addSharedElement(vh.artView, vh.artView.getTransitionName()) .commit(); } else { MovieDetailsFragment movieDetailsFragment = MovieDetailsFragment.newInstance(vh); FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction(); fragTrans.setCustomAnimations(R.anim.fragment_details_enter, 0, R.anim.fragment_list_popenter, 0); fragTrans.replace(R.id.fragment_container, movieDetailsFragment) .addToBackStack(null) .commit(); } setupActionBar(selectedMovieTitle); }
Source:
<code>public void saveOrUpdateShouldBeUnsuccessfulWhenCandidateIdNotExists() throws Exception { given(this.messageKeyResolver.resolveMessageOrDefault(COMMON_INVALID_INPUT_MESSAGE_KEY)).willReturn(COMMON_INVALID_INPUT_MESSAGE); given(this.messageKeyResolver.resolveMessageOrDefault(CANDIDATE_NOT_FOUND_ERROR_MESSAGE_KEY)).willReturn(CANDIDATE_NOT_FOUND_ERROR_MESSAGE); <START> <END> this.mockMvc.perform(post(REQUEST_URL_POST) .param("candidateId", STRING_VALUE_TWO) .param("position.id", STRING_VALUE_ONE).param("position.name", POSITION_NAME_DEVELOPER) .param("channel.id", STRING_VALUE_ONE).param("channel.name", CHANNEL_NAME_FACEBOOK) .param("description", DESCRIPTION)) .andExpect(status().is3xxRedirection()) .andExpect(flash().attribute("candidateIdErrorMessage", CANDIDATE_NOT_FOUND_ERROR_MESSAGE)) .andExpect(redirectedUrl(REDIRECT_URL_FOR_CANDIDATE_WITH_WRONG_ID)); verifyZeroInteractions(applicationsService); then(this.candidateService).should().getCandidate(2L); then(this.positionService).should().getPositionDtoById(1L); then(this.channelService).should().getChannelDtoById(1L); }</code><technical_language>is initialization for candidateService, positionService channelService</technical_language>

Target:
public void saveOrUpdateShouldBeUnsuccessfulWhenCandidateIdNotExists() throws Exception { given(this.candidateService.getCandidate(2L)).willReturn(null); given(this.positionService.getPositionDtoById(1L)).willReturn(positionDTO); given(this.channelService.getChannelDtoById(1L)).willReturn(channelDTO); given(this.messageKeyResolver.resolveMessageOrDefault(COMMON_INVALID_INPUT_MESSAGE_KEY)).willReturn(COMMON_INVALID_INPUT_MESSAGE); given(this.messageKeyResolver.resolveMessageOrDefault(CANDIDATE_NOT_FOUND_ERROR_MESSAGE_KEY)).willReturn(CANDIDATE_NOT_FOUND_ERROR_MESSAGE); this.mockMvc.perform(post(REQUEST_URL_POST) .param("candidateId", STRING_VALUE_TWO) .param("position.id", STRING_VALUE_ONE).param("position.name", POSITION_NAME_DEVELOPER) .param("channel.id", STRING_VALUE_ONE).param("channel.name", CHANNEL_NAME_FACEBOOK) .param("description", DESCRIPTION)) .andExpect(status().is3xxRedirection()) .andExpect(redirectedUrl(REDIRECT_URL_FOR_CANDIDATE_WITH_WRONG_ID)) .andExpect(flash().attributeCount(1)) .andExpect(flash().attribute("candidateIdErrorMessage", CANDIDATE_NOT_FOUND_ERROR_MESSAGE)); verifyZeroInteractions(applicationsService); then(this.candidateService).should().getCandidate(2L); then(this.positionService).should().getPositionDtoById(1L); then(this.channelService).should().getChannelDtoById(1L); }
Source:
<code>public void taskSchedulerRegistered() { Object taskScheduler = context.getBean(IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME); assertEquals(ThreadPoolTaskScheduler.class, taskScheduler.getClass()); Object errorHandler = new DirectFieldAccessor(taskScheduler).getPropertyValue("errorHandler"); assertEquals(MessagePublishingErrorHandler.class, errorHandler.getClass()); <START> } <END></code><technical_language>deleting assertions in tests, I do java MessagePublishingErrorHandler errorHandler = TestUtils.getPropertyValue(taskScheduler, "errorHandler", MessagePublishingErrorHandler.class); errorHandler.handleError(new Throwable()); assertEquals(context.getBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME), TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel"));</technical_language>

Target:
public void taskSchedulerRegistered() { Object taskScheduler = context.getBean(IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME); assertEquals(ThreadPoolTaskScheduler.class, taskScheduler.getClass()); ErrorHandler errorHandler = TestUtils.getPropertyValue(taskScheduler, "errorHandler", ErrorHandler.class); assertEquals(MessagePublishingErrorHandler.class, errorHandler.getClass()); MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); assertNull(defaultErrorChannel); errorHandler.handleError(new Throwable()); defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); assertNotNull(defaultErrorChannel); assertEquals(context.getBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME), defaultErrorChannel); }
Source:
<code>protected String getAndDeleteNodeURL(String nodeName, int rank) { try { File f = new File(getNodeURLFilename(nodeName, rank)); if (f.exists()) { try (BufferedReader in = new BufferedReader(new FileReader(f))) { <START> String read = in.readLine(); <END> return read; } finally { FileUtils.deleteQuietly(f); } } } catch (IOException e) { e.printStackTrace(); } return null; }</code><technical_language>![MINOR](<LINK_1> 'Severity: MINOR') Immediately return this expression instead of assigning temporary variable "read". [![rule](<LINK_0>](<LINK_2></technical_language>

Target:
protected String getAndDeleteNodeURL(String nodeName, int rank) { try { File f = new File(getNodeURLFilename(nodeName, rank)); if (f.exists()) { try (BufferedReader in = new BufferedReader(new FileReader(f))) { return in.readLine(); } finally { FileUtils.deleteQuietly(f); } } } catch (IOException e) { e.printStackTrace(); } return null; }