auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void stop() { this.getLifeCycleLock().writeLock().lock(); try { if (!this.isRunning()) { return; } stopProcessing(); stompProxyDead(); for (AsyncEventListener listener : this.listeners) { listener.close(); } ((ConcurrentParallelGatewaySenderQueue) this.eventProcessor.getQueue()).cleanUp(); logger.info("Stopped {}", this); InternalDistributedSystem system = (InternalDistributedSystem) this.cache.getDistributedSystem(); system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_STOP, this); clearTempEventsAfterSenderStopped(); <START> stopTime = System.currentTimeMillis(); <END> } finally { this.getLifeCycleLock().writeLock().unlock(); } }</code><technical_language>stopTime set log.info()</technical_language>

Target:
public void stop() { this.getLifeCycleLock().writeLock().lock(); try { if (!this.isRunning()) { return; } stopProcessing(); stompProxyDead(); for (AsyncEventListener listener : this.listeners) { listener.close(); } ((ConcurrentParallelGatewaySenderQueue) this.eventProcessor.getQueue()).cleanUp(); stopTime = System.currentTimeMillis(); logger.info("Stopped {}", this); InternalDistributedSystem system = (InternalDistributedSystem) this.cache.getDistributedSystem(); system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_STOP, this); clearTempEventsAfterSenderStopped(); } finally { this.getLifeCycleLock().writeLock().unlock(); } }
Source:
<code>private void saveChangesAndDispose(IResource resource) { if (saving == true) { return; } saving = true; inlinedResource = resource; final String newName = textEditor.getText(); Runnable query = () -> { try { if (!newName.equals(inlinedResource.getName())) { IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace(); IStatus status = workspace.validateName(newName, inlinedResource.getType()); if (!status.isOK()) { displayError(status.getMessage()); } else { <START> if (!LTKLauncher.openRenameWizard(newName, getStructuredSelection())) { <END> IPath newPath = inlinedResource.getFullPath().removeLastSegments(1).append(newName); runWithNewPath(newPath, inlinedResource); } } } inlinedResource = null; disposeTextWidget(); if (navigatorTree != null && !navigatorTree.isDisposed()) { navigatorTree.setFocus(); } } finally { saving = false; } }; getTree().getShell().getDisplay().asyncExec(query); }</code><technical_language>is this check necessary if previously</technical_language>

Target:
private void saveChangesAndDispose(IResource resource) { if (saving == true) { return; } saving = true; inlinedResource = resource; final String newName = textEditor.getText(); Runnable query = () -> { try { if (!newName.equals(inlinedResource.getName())) { IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace(); IStatus status = workspace.validateName(newName, inlinedResource.getType()); if (!status.isOK()) { displayError(status.getMessage()); } else { if (!LTKLauncher.renameResource(newName, getStructuredSelection())) { IPath newPath = inlinedResource.getFullPath().removeLastSegments(1).append(newName); runWithNewPath(newPath, inlinedResource); } } } inlinedResource = null; disposeTextWidget(); if (navigatorTree != null && !navigatorTree.isDisposed()) { navigatorTree.setFocus(); } } finally { saving = false; } }; getTree().getShell().getDisplay().asyncExec(query); }
Source:
<code>protected int getQuarkAbsoluteAndAdd(String... path) { ITmfStateSystem ss = getStateSystem(); if (ss == null) { throw new IllegalStateException("The state system hasn't been initialized yet"); } <START> return Integer.max(ss.optQuarkAbsolute(path), IXmlStateSystemContainer.ERROR_QUARK); <END> }</code><technical_language>know, this is relying arbitrary values in a order, if I change ERROR_QUARK Integer.MIN_VALUE, a hard time. worse in opinion int result = ss.getQuar... ; if (result == INVALID_...) { return ERROR_QUARK; } return result; in opinion</technical_language>

Target:
protected int getQuarkAbsoluteAndAdd(String... path) { ITmfStateSystem ss = getStateSystem(); if (ss == null) { throw new IllegalStateException("The state system hasn't been initialized yet"); } int quark = ss.optQuarkAbsolute(path); return quark != ITmfStateSystem.INVALID_ATTRIBUTE ? quark : IXmlStateSystemContainer.ERROR_QUARK; }
Source:
<code>public void uploadLargeFile(String regionId) throws IOException, InterruptedException { List<Segment> list1 = new ArrayList<Segment>(); int partNumber = 1; int total_size = 0; while (partNumber < 3) { <START> String objName = objectName + "/dlo/" + String.valueOf(partNumber); <END> String data = "data".concat(String.valueOf(partNumber)); String etag = getApi().getDynamicLargeObjectApi(regionId, defaultContainerName).uploadLargeFile( defaultContainerName, objName, Payloads.newPayload(data), ImmutableMap.of("myfoo", "Bar"), ImmutableMap.of("myfoo", "Bar")); Segment s = new Segment(objName, etag, data.length()); assertNotNull(etag); list1.add(s); partNumber++; total_size = total_size + data.length(); } String etagOfEtags = getApi().getDynamicLargeObjectApi(regionId, defaultContainerName).replaceManifest( defaultContainerName, objectName, list1, ImmutableMap.of("MyFoo", "Bar"), ImmutableMap.of("MyFoo", "Bar")); SwiftObject bigObject = getApi().getObjectApi(regionId, defaultContainerName).get(objectName); assertEquals(bigObject.getETag(), etagOfEtags); assertEquals(bigObject.getPayload().getContentMetadata().getContentLength(), Long.valueOf(total_size)); assertEquals(bigObject.getMetadata(), ImmutableMap.of("myfoo", "Bar")); assertEquals(getApi().getContainerApi(regionId).get(defaultContainerName).getObjectCount(), Long.valueOf(3)); }</code><technical_language>Remove call String.valueOf</technical_language>

Target:
public void uploadLargeFile(String regionId) throws IOException, InterruptedException { long total_size = 0; RegionScopedBlobStoreContext ctx = RegionScopedBlobStoreContext.class.cast(view); BlobStore blobStore = ctx.getBlobStore(); String defaultContainerName = getContainerName(); for (int partNumber = 0; partNumber < 3; partNumber++) { String objName = String.format("%s/%s/%s", objectName, "dlo", partNumber); String data = "data" + partNumber; ByteSource payload = ByteSource.wrap(data.getBytes(Charsets.UTF_8)); Blob blob = blobStore.blobBuilder(objName) .payload(payload) .build(); String etag = blobStore.putBlob(defaultContainerName, blob); assertNotNull(etag); total_size += data.length(); } getApi().getDynamicLargeObjectApi(regionId, defaultContainerName).putManifest(objectName, ImmutableMap.of("myfoo", "Bar")); SwiftObject bigObject = getApi().getObjectApi(regionId, defaultContainerName).get(objectName); assertThat(bigObject.getETag()).isEqualTo("54bc1337d7a51660c40db39759cc1944"); assertThat(bigObject.getPayload().getContentMetadata().getContentLength()).isEqualTo(total_size); assertThat(getApi().getContainerApi(regionId).get(defaultContainerName).getObjectCount()).isEqualTo(Long.valueOf(4)); }
Source:
<code>public BaseLuceneLock makeLock(Directory dir, String lockName) { if (!(dir instanceof DirectoryLuceneV5)) { <START> throw new UnsupportedOperationException("BaseLuceneLock can only be used with DirectoryLuceneV5, got: " + dir); <END> } DirectoryLuceneV5 infinispanDirectory = (DirectoryLuceneV5) dir; Cache distLockCache = infinispanDirectory.getDistLockCache(); String indexName = infinispanDirectory.getIndexName(); BaseLuceneLock lock = new BaseLuceneLock(distLockCache, indexName, lockName); if (log.isTraceEnabled()) { log.tracef("Lock prepared, not acquired: %s for index %s", lockName, indexName); } return lock; }</code><technical_language>provide some tool for upgrading index</technical_language>

Target:
public BaseLuceneLock makeLock(Directory dir, String lockName) { if (!(dir instanceof DirectoryLucene)) { throw new UnsupportedOperationException("BaseLuceneLock can only be used with DirectoryLucene, got: " + dir); } DirectoryLucene infinispanDirectory = (DirectoryLucene) dir; Cache distLockCache = infinispanDirectory.getDistLockCache(); String indexName = infinispanDirectory.getIndexName(); BaseLuceneLock lock = new BaseLuceneLock(distLockCache, indexName, lockName); if (log.isTraceEnabled()) { log.tracef("Lock prepared, not acquired: %s for index %s", lockName, indexName); } return lock; }
Source:
<code>private File extractFromResource(String resource) { File file = null; URL res = getClass().getResource(resource); if (res.toString().startsWith("jar:")) { try { InputStream input = getClass().getResourceAsStream(resource); file = File.createTempFile("tempfile", ".tmp"); OutputStream out = new FileOutputStream(file); int read; byte[] bytes = new byte[1024]; while ((read = input.read(bytes)) != -1) { out.write(bytes, 0, read); } file.deleteOnExit(); } catch (IOException ex) { Log.log(Log.ERROR, "TLP", ex.toString()); } } else { file = new File(res.getFile()); } if (file != null && !file.exists()) { <START> throw new RuntimeException("Error: File " + file + " not found!"); <END> } return file; }</code><technical_language>Exception crash app. If file is null fail also</technical_language>

Target:
private File extractFromResource(String resource) { File file = null; URL res = getClass().getResource(resource); if (res.toString().startsWith("jar:")) { try { InputStream input = getClass().getResourceAsStream(resource); file = File.createTempFile("tempfile", ".tmp"); OutputStream out = new FileOutputStream(file); int read; byte[] bytes = new byte[1024]; while ((read = input.read(bytes)) != -1) { out.write(bytes, 0, read); } file.deleteOnExit(); } catch (IOException ex) { Log.log(Log.ERROR, TAG, ex.toString()); } } else { file = new File(res.getFile()); } if (file == null || !file.exists()) { Log.log(Log.ERROR, TAG, "Error: File " + file + " not found!"); } return file; }
Source:
<code>public MetadataField getMetadataField(@PathParam("field_id") Integer fieldId, @QueryParam("expand") @DefaultValue("parentSchema") String expand, @QueryParam("userIP") String user_ip, @QueryParam("userAgent") String user_agent, @QueryParam("xforwarderfor") String xforwarderfor, @Context HttpHeaders headers, @Context HttpServletRequest request) throws WebApplicationException { log.info("Reading metadata field."); org.dspace.core.Context context = null; MetadataField metadataField = null; try { context = createContext(getUser(headers)); org.dspace.content.MetadataField field = metadataFieldService.find(context, fieldId); if (field == null) { log.error(String.format("Metadata Field %d not found", fieldId)); throw new WebApplicationException(Response.Status.NOT_FOUND); } org.dspace.content.MetadataSchema schema = field.getMetadataSchema(); if (schema == null) { log.error(String.format("Parent Schema not found for Metadata Field %d not found", fieldId)); throw new WebApplicationException(Response.Status.NOT_FOUND); } metadataField = new MetadataField(schema, field, expand, context); context.complete(); } catch (SQLException e) { processException("Could not read metadata field, SQLException. Message:" + e, context); <START> log.error(e.getMessage()); <END> throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR); } catch (ContextException e) { processException("Could not read metadata field, ContextException. Message:" + e.getMessage(), context); } finally { processFinally(context); } log.trace("Metadata field successfully read."); return metadataField; }</code><technical_language>Leave out this line, processException log it</technical_language>

Target:
public MetadataField getMetadataField(@PathParam("field_id") Integer fieldId, @QueryParam("expand") @DefaultValue("parentSchema") String expand, @QueryParam("userIP") String user_ip, @QueryParam("userAgent") String user_agent, @QueryParam("xforwarderfor") String xforwarderfor, @Context HttpHeaders headers, @Context HttpServletRequest request) throws WebApplicationException { log.info("Reading metadata field."); org.dspace.core.Context context = null; MetadataField metadataField = null; try { context = createContext(getUser(headers)); org.dspace.content.MetadataField field = metadataFieldService.find(context, fieldId); if (field == null) { log.error(String.format("Metadata Field %d not found", fieldId)); throw new WebApplicationException(Response.Status.NOT_FOUND); } org.dspace.content.MetadataSchema schema = field.getMetadataSchema(); if (schema == null) { log.error(String.format("Parent Schema not found for Metadata Field %d not found", fieldId)); throw new WebApplicationException(Response.Status.NOT_FOUND); } metadataField = new MetadataField(schema, field, expand, context); context.complete(); } catch (SQLException e) { processException("Could not read metadata field, SQLException. Message:" + e, context); } catch (ContextException e) { processException("Could not read metadata field, ContextException. Message:" + e.getMessage(), context); } finally { processFinally(context); } log.trace("Metadata field successfully read."); return metadataField; }
Source:
<code>public void pause(final String user) throws IllegalStateException { synchronized (this.mainSyncObj) { <START> this.logger.info("Flow paused by " + user); <END> if (!this.isKilled() && !this.flowFinished) { this.logger.info("Execution " + this.execId + " has been paused."); this.flowPaused = true; this.flow.setStatus(Status.PAUSED); updateFlow(); } else { final String errorMessage = "Execution " + this.execId + " with status " + this.flow.getStatus() + " cannot be paused."; this.logger.warn(errorMessage); throw new IllegalStateException(errorMessage); } } interrupt(); }</code><technical_language>Nit: "flow pause requested user"? paused this point, right</technical_language>

Target:
public void pause(final String user) throws IllegalStateException { synchronized (this.mainSyncObj) { this.logger.info("Execution pause requested by " + user); if (!this.isKilled() && !this.flowFinished) { this.flowPaused = true; this.flow.setStatus(Status.PAUSED); updateFlow(); this.logger.info("Execution " + this.execId + " has been paused."); } else { final String errorMessage = "Execution " + this.execId + " with status " + this.flow.getStatus() + " cannot be paused."; this.logger.warn(errorMessage); throw new IllegalStateException(errorMessage); } } interrupt(); }
Source:
<code><START> public void testDestroyCommands() throws Exception { <END> final ClientSession clientSession = mock(ClientSession.class); final CanvasHandler canvasHandler = mock(CanvasHandler.class); final Diagram diagram = mock(Diagram.class); final Metadata metadata = mock(Metadata.class); final String definitionSetId = "definitionSetId"; when(clientSession.getCanvasHandler()).thenReturn(canvasHandler); when(canvasHandler.getDiagram()).thenReturn(diagram); when(diagram.getMetadata()).thenReturn(metadata); when(metadata.getDefinitionSetId()).thenReturn(definitionSetId); final Annotation qualifier = mock(Annotation.class); when(definitionUtils.getQualifier(eq(definitionSetId))).thenReturn(qualifier); final ManagedInstance managedInstance = mock(ManagedInstance.class); final ClientSessionCommand clientSessionCommand = mock(ClientSessionCommand.class); when(sessionCommands.select(eq(MockClientSessionCommand.class), eq(qualifier))).thenReturn(managedInstance); when(managedInstance.get()).thenReturn(clientSessionCommand); tested.register(MockClientSessionCommand.class); tested.bind(clientSession); tested.clearCommands(); verify(clientSessionCommand, times(1)).destroy(); verify(sessionCommands, times(1)).destroy(eq(clientSessionCommand)); }</code><technical_language>Exception is thrown</technical_language>

Target:
public void testDestroyCommands() { final ClientSession clientSession = mock(ClientSession.class); final CanvasHandler canvasHandler = mock(CanvasHandler.class); final Diagram diagram = mock(Diagram.class); final Metadata metadata = mock(Metadata.class); final String definitionSetId = "definitionSetId"; when(clientSession.getCanvasHandler()).thenReturn(canvasHandler); when(canvasHandler.getDiagram()).thenReturn(diagram); when(diagram.getMetadata()).thenReturn(metadata); when(metadata.getDefinitionSetId()).thenReturn(definitionSetId); final Annotation qualifier = mock(Annotation.class); when(definitionUtils.getQualifier(eq(definitionSetId))).thenReturn(qualifier); final ManagedInstance managedInstance = mock(ManagedInstance.class); final ClientSessionCommand clientSessionCommand = mock(ClientSessionCommand.class); when(sessionCommands.select(eq(MockClientSessionCommand.class), eq(qualifier))).thenReturn(managedInstance); when(managedInstance.get()).thenReturn(clientSessionCommand); tested.register(MockClientSessionCommand.class); tested.bind(clientSession); tested.clearCommands(); verify(clientSessionCommand, times(1)).destroy(); verify(sessionCommands, times(1)).destroy(eq(clientSessionCommand)); }
Source:
<code>public static String readString(JSONResourceRef resource) throws IOException { <START> InputStream istream = resource.getResourceClass().getResourceAsStream(resource.getFileName()); <END> if (istream == null) { throw new IOException("Cannot retrieve resource " + resource.getFileName()); } return IOUtils.toString(istream, "UTF-8"); }</code><technical_language>wrap try-with-resources</technical_language>

Target:
public static String readString(JSONResourceRef resource) throws IOException { try (InputStream istream = resource.getResourceClass().getResourceAsStream(resource.getFileName())) { if (istream == null) { throw new IOException("Cannot retrieve resource " + resource.getFileName()); } return IOUtils.toString(istream, "UTF-8"); } }
Source:
<code>public void transformOffset(){ final ITmfTimestampTransform offset = TimestampTransformFactory.create(100); final ITmfTimestampTransform compositeTransform = offset.composeWith(TimestampTransformFactory.create(new TmfNanoTimestamp(-100))); assertEquals(tn100, offset.transform(t0)); assertEquals(tn100, offset.transform(tn0)); assertEquals(tn0, compositeTransform.transform(t0)); <START> assertEquals(t0, compositeTransform.transform(t0)); <END> }</code><technical_language>testing thing, proving 0 s = 0 ns is scope of this test file. meant do transform(tn0) for one</technical_language>

Target:
public void transformOffset() { final ITmfTimestampTransform offset = offset1; final ITmfTimestampTransform compositeTransform = offset.composeWith(TimestampTransformFactory.create(new TmfNanoTimestamp(-100))); assertEquals(tn100, offset.transform(t0)); assertEquals(tn100, offset.transform(tn0)); assertEquals(tn0, compositeTransform.transform(tn0)); assertEquals(t0, compositeTransform.transform(t0)); assertEquals(200, offset1.transform(100)); assertEquals(200, offset2.transform(100)); assertEquals(200, offset3.transform(100)); assertEquals(200, offset4.transform(100)); }
Source:
<code>public List<String> listSchemaNames() { try { ImmutableList.Builder<String> schemaNamesListBuilder = ImmutableList.builder(); <START> for (String table : pinotPrestoConnection.getTableNames()) { <END> schemaNamesListBuilder.add(table.toLowerCase(ENGLISH)); } return schemaNamesListBuilder.build(); } catch (Exception e) { return ImmutableList.of(); } }</code><technical_language>stream + foreach</technical_language>

Target:
public List<String> listSchemaNames() { try { ImmutableList.Builder<String> schemaNamesListBuilder = ImmutableList.builder(); pinotPrestoConnection.getTableNames().forEach(table -> schemaNamesListBuilder.add(table.toLowerCase(ENGLISH))); return schemaNamesListBuilder.build(); } catch (Exception e) { throw new PrestoException( PINOT_FAILURE_GETTING_SCHEMA, "Failed to list schema names.", e); } }
Source:
<code>public static BoBExtension from(Message message) { <START> return (BoBExtension) message.getExtension(ELEMENT, NAMESPACE); <END> }</code><technical_language>I cast is necessary</technical_language>

Target:
public static BoBExtension from(Message message) { return message.getExtension(ELEMENT, NAMESPACE); }
Source:
<code>static Migrator createVersionOneToVersionTwoMigrator(Context context, File databasePath, Migrator.Callback migrationCallback) { if (!databasePath.exists()) { return Migrator.NO_OP; } <START> if (INSTANCE == null) { <END> SQLiteDatabase sqLiteDatabase = SQLiteDatabase.openDatabase(databasePath.getAbsolutePath(), null, 0); SqlDatabaseWrapper database = new SqlDatabaseWrapper(sqLiteDatabase); MigrationExtractor migrationExtractor = new MigrationExtractor(database); RoomDownloadsPersistence downloadsPersistence = RoomDownloadsPersistence.newInstance(context); InternalFilePersistence internalFilePersistence = new InternalFilePersistence(); internalFilePersistence.initialiseWith(context); INSTANCE = new VersionOneToVersionTwoMigrator(migrationExtractor, downloadsPersistence, internalFilePersistence, database, migrationCallback); } return INSTANCE; }</code><technical_language>if (INSTANCE != null) { return INSTANCE; } (...)</technical_language>

Target:
static Migrator createVersionOneToVersionTwoMigrator(Context context, File databasePath, Migrator.Callback migrationCallback) { if (!databasePath.exists()) { return Migrator.NO_OP; } SQLiteDatabase sqLiteDatabase = SQLiteDatabase.openDatabase(databasePath.getAbsolutePath(), null, 0); SqlDatabaseWrapper database = new SqlDatabaseWrapper(sqLiteDatabase); MigrationExtractor migrationExtractor = new MigrationExtractor(database); RoomDownloadsPersistence downloadsPersistence = RoomDownloadsPersistence.newInstance(context); InternalFilePersistence internalFilePersistence = new InternalFilePersistence(); internalFilePersistence.initialiseWith(context); return new VersionOneToVersionTwoMigrator(migrationExtractor, downloadsPersistence, internalFilePersistence, database, migrationCallback); }
Source:
<code>public void equalsTest() { ArrayDeclaration a = new ArrayDeclaration(1, IntegerDeclaration.INT_32B_DECL); ArrayDeclaration b = new ArrayDeclaration(2, IntegerDeclaration.INT_32B_DECL); ArrayDeclaration c = new ArrayDeclaration(1, new StringDeclaration()); ArrayDeclaration d = new ArrayDeclaration(1, IntegerDeclaration.INT_32B_DECL); assertNotEquals(a, null); assertNotEquals(a, new Object()); assertNotEquals(a, b); assertNotEquals(a, c); assertEquals(a, d); assertEquals(a, a); assertFalse(a.isBinaryEquivalent(b)); assertFalse(a.isBinaryEquivalent(c)); <START> assertTrue(a.isBinaryEquivalent(d)); <END> assertTrue(a.isBinaryEquivalent(a)); }</code><technical_language>assertTrue(d.isBinaryEquivalent(a));</technical_language>

Target:
public void equalsTest() { ArrayDeclaration a = new ArrayDeclaration(1, IntegerDeclaration.INT_32B_DECL); ArrayDeclaration b = new ArrayDeclaration(2, IntegerDeclaration.INT_32B_DECL); ArrayDeclaration c = new ArrayDeclaration(1, new StringDeclaration()); ArrayDeclaration d = new ArrayDeclaration(1, IntegerDeclaration.INT_32B_DECL); assertNotEquals(a, null); assertNotEquals(a, new Object()); assertNotEquals(a, b); assertNotEquals(a, c); assertEquals(a, d); assertEquals(a, a); assertNotEquals(b, a); assertNotEquals(c, a); assertEquals(d, a); assertEquals(a, a); assertFalse(a.isBinaryEquivalent(b)); assertFalse(b.isBinaryEquivalent(a)); assertFalse(a.isBinaryEquivalent(c)); assertFalse(c.isBinaryEquivalent(a)); assertTrue(a.isBinaryEquivalent(d)); assertTrue(d.isBinaryEquivalent(a)); assertTrue(a.isBinaryEquivalent(a)); }
Source:
<code>public LocalSshDaoImpl(LocalStorageFactory storageFactory) throws IOException { pairs = new ArrayList<>(); <START> sshStorage = storageFactory.create("ssh.json"); <END> }</code><technical_language>I this attribute configured</technical_language>

Target:
public LocalSshDaoImpl(LocalStorageFactory storageFactory) throws IOException { pairs = ArrayListMultimap.create(); lock = new ReentrantReadWriteLock(); sshStorage = storageFactory.create("ssh.json"); }
Source:
<code>private QueryResponse getResponse(Query parameter, long totalHits, List<String> ids, String scrollId) { if (ids.isEmpty()) { return QueryResponse .builder() .documents(Collections.emptyList()) .totalHits(0) <START> .scrollResponse(true) <END> .build(); } return QueryResponse .builder() .documents(getQueryStore() .getAll(parameter.getTable(), ids, true)) .totalHits(totalHits) .scrollId(scrollId) .scrollResponse(true) .build(); }</code><technical_language>sense is remove this variable create called moreDataAvailable. Set false in this case, true in other</technical_language>

Target:
private QueryResponse getResponse(Query parameter, long totalHits, List<String> ids, String scrollId) { if (ids.isEmpty()) { return QueryResponse .builder() .documents(Collections.emptyList()) .totalHits(0) .moreDataAvailable(false) .build(); } return QueryResponse .builder() .documents(getQueryStore() .getAll(parameter.getTable(), ids, true)) .totalHits(totalHits) .scrollId(scrollId) .moreDataAvailable(StringUtils.isNotEmpty(scrollId) ? true : false) .build(); }
Source:
<code>Repository getRepository(URL url) throws NotFoundException; Patch getPatch(URL url) throws NotFoundException; List<Patch> getPatchesAssociatedWith(Issue issue) throws NotFoundException; List<Patch> getPatchesByStatus(Repository repository, PatchStatus status) throws NotFoundException; <START> List<Label> getLabelsfromRepository(Patch patch) throws NotFoundException; <END> List<Label> getLabelsfromPatch(Patch patch) throws NotFoundException; void addLabelstoPatch(Patch patch, List<Label> labels) throws NotFoundException; void removeLabel(Patch patch, String name) throws NotFoundException; void addCommentToPatch(Patch patch, String comment) throws NotFoundException; void addLabelToPatch(Patch patch, String labelName) throws NotFoundException; List<Patch> findPatchesRelatedTo(Patch patch) throws NotFoundException; default void destroy() { }</code><technical_language>wrong argument. repository. getLabelsByRepository(Repository...)</technical_language>

Target:
Repository getRepository(URL url) throws NotFoundException; Patch getPatch(URL url) throws NotFoundException; List<Patch> getPatchesAssociatedWith(Issue issue) throws NotFoundException; List<Patch> getPatchesByStatus(Repository repository, PatchStatus status) throws NotFoundException; List<Label> getLabelsFromRepository(Repository repository) throws NotFoundException; List<Label> getLabelsFromPatch(Patch patch) throws NotFoundException; void setLabelsToPatch(Patch patch, List<Label> labels) throws NotFoundException, AphroditeException ; void removeLabelFromPatch(Patch patch, String name) throws NotFoundException; void addCommentToPatch(Patch patch, String comment) throws NotFoundException; void addLabelToPatch(Patch patch, String labelName) throws NotFoundException; List<Patch> findPatchesRelatedTo(Patch patch) throws NotFoundException; default void destroy() { }
Source:
<code>public LdapProviderType autoDetectLdapProviderType(String domain) throws NamingException { log.infoFormat("Trying to auto-detect the LDAP provider type for domain {0}", domain); LdapProviderType retVal = LdapProviderType.general; Attributes attributes = getDomainAttributes(LdapProviderType.general, domain); if (attributes != null) { if (attributes.get(ADRootDSEAttributes.domainControllerFunctionality.name()) != null) { retVal = LdapProviderType.activeDirectory; } else if (attributes.get(RHDSRootDSEAttributes.vendorName.name()) != null) { String vendorName = (String) attributes.get(RHDSRootDSEAttributes.vendorName.name()).get(0); if (vendorName.equals(LdapVendorNameEnum.IPAVendorName.getName())) { retVal = LdapProviderType.ipa; } else if (vendorName.equals(LdapVendorNameEnum.RHDSVendorName.getName())) { retVal = LdapProviderType.rhds; <START> } else if (vendorName.equals(LdapVendorNameEnum.IBMVendorName.getName())) { <END> retVal = LdapProviderType.ibm; } } } log.infoFormat("Provider type is {0}", retVal.name()); updateProviderTypeInConfig(domain, retVal.name()); return retVal; }</code><technical_language>Sharad , a question - is Tivoli DS directory service product IBM has? TivoliDSVendorName more appropriate? see, RHDS IPA product names (maybe VendorName is misleading, a note myself)</technical_language>

Target:
public LdapProviderType autoDetectLdapProviderType(String domain) throws NamingException { log.infoFormat("Trying to auto-detect the LDAP provider type for domain {0}", domain); LdapProviderType retVal = LdapProviderType.general; Attributes attributes = getDomainAttributes(LdapProviderType.general, domain); if (attributes != null) { if (attributes.get(ADRootDSEAttributes.domainControllerFunctionality.name()) != null) { retVal = LdapProviderType.activeDirectory; } else if (attributes.get(RHDSRootDSEAttributes.vendorName.name()) != null) { String vendorName = (String) attributes.get(RHDSRootDSEAttributes.vendorName.name()).get(0); if (vendorName.equals(LdapVendorNameEnum.IPAVendorName.getName())) { retVal = LdapProviderType.ipa; } else if (vendorName.equals(LdapVendorNameEnum.RHDSVendorName.getName())) { retVal = LdapProviderType.rhds; } else if (vendorName.equals(LdapVendorNameEnum.ITDSVendorName.getName())) { retVal = LdapProviderType.itds; } } } log.infoFormat("Provider type is {0}", retVal.name()); updateProviderTypeInConfig(domain, retVal.name()); return retVal; }
Source:
<code>public ActualMeterReadsGas(final Date logTime, final long consumption, final Date captureTime, final ScalerUnit scalerUnit) { super(logTime, consumption, captureTime); <START> this.scalerUnit = scalerUnit; <END> }</code><technical_language>immutable making a copy</technical_language>

Target:
public ActualMeterReadsGas(final Date logTime, final long consumption, final Date captureTime, final ScalerUnit scalerUnit) { super(logTime, consumption, captureTime); this.scalerUnit = new ScalerUnit(scalerUnit.getDlmsUnit(), scalerUnit.getScaler()); }
Source:
<code>private Class<?> resolveClassFromName(String className) { try { <START> ClassLoader classLoader = getApplicationContext() == null ? getClass().getClassLoader() <END> : getApplicationContext().getClassLoader(); return ClassUtils.forName(className, classLoader); } catch (ClassNotFoundException e) { throw new IllegalStateException("Cannot load class for channel mapping.", e); } }</code><technical_language>I prefer do fallback getClass().getClassLoader(). Assert.state() in this method great compromise</technical_language>

Target:
private Class<?> resolveClassFromName(String className) { try { Assert.state(getApplicationContext() != null, "An ApplicationContext is required"); return ClassUtils.forName(className, getApplicationContext().getClassLoader()); } catch (ClassNotFoundException e) { throw new IllegalStateException("Cannot load class for channel mapping.", e); } }
Source:
<code>private void updateStoragePoolFormatType() { storage_pool storagePool = getStoragePool(); Guid spId = storagePool.getId(); VDSBrokerFrontend resourceManager = Backend.getInstance() .getResourceManager(); Version spVersion = storagePool.getcompatibility_version(); Version oldSpVersion = _oldStoragePool.getcompatibility_version(); if (Version.OpEquality(spVersion, oldSpVersion)) { return; } StorageType spType = storagePool.getstorage_pool_type(); if (spType != StorageType.ISCSI && spType != StorageType.FCP) { return; } StorageFormatType targetFormat = StorageFormatType.V1; Version v2FormatChangeBar = new Version("3.0"); if (spVersion.compareTo(v2FormatChangeBar) >= 0) { <START> targetFormat = StorageFormatType.V2; <END> } storagePool.setStoragePoolFormatType(targetFormat); getStoragePoolDAO().update(storagePool); updateMemberDomainsFormat(targetFormat); if (storagePool.getstatus() != StoragePoolStatus.Up) { return; } UpgradeStoragePoolVDSCommandParameters parameters = new UpgradeStoragePoolVDSCommandParameters(spId, targetFormat); resourceManager.RunVdsCommand( VDSCommandType.UpgradeStoragePool, parameters); }</code><technical_language>support for upgrade v2 v3? v1 v3</technical_language>

Target:
private void updateStoragePoolFormatType() { storage_pool storagePool = getStoragePool(); Guid spId = storagePool.getId(); VDSBrokerFrontend resourceManager = Backend.getInstance() .getResourceManager(); Version spVersion = storagePool.getcompatibility_version(); Version oldSpVersion = _oldStoragePool.getcompatibility_version(); if (Version.OpEquality(spVersion, oldSpVersion)) { return; } StorageType spType = storagePool.getstorage_pool_type(); if (spType != StorageType.ISCSI && spType != StorageType.FCP) { return; } StorageFormatType targetFormat = StorageFormatType.V1; Version v2FormatChangeBar = new Version("3.0"); Version v3FormatChangeBar = new Version("3.1"); if (spVersion.compareTo(v3FormatChangeBar) >= 0) { targetFormat = StorageFormatType.V3; } else if (spVersion.compareTo(v2FormatChangeBar) >= 0) { targetFormat = StorageFormatType.V2; } storagePool.setStoragePoolFormatType(targetFormat); getStoragePoolDAO().update(storagePool); updateMemberDomainsFormat(targetFormat); if (storagePool.getstatus() != StoragePoolStatus.Up) { return; } UpgradeStoragePoolVDSCommandParameters parameters = new UpgradeStoragePoolVDSCommandParameters(spId, targetFormat); resourceManager.RunVdsCommand( VDSCommandType.UpgradeStoragePool, parameters); }
Source:
<code>public void validateAddingNonExistingNetwork() { List<VdsNetworkInterface> vdsNics = new ArrayList<VdsNetworkInterface>(); VdsNetworkInterface nic1 = new VdsNetworkInterface(); nic1.setNetworkName("vmnet"); nic1.setName("nic1"); vdsNics.add(nic1); VdsNetworkInterface nic2 = new VdsNetworkInterface(); nic2.setNetworkName("mgmtnet"); nic2.setName("nic2"); vdsNics.add(nic2); List<network> clusterNetworks = new ArrayList<network>(); network net1 = new network(); net1.setname("vmnet"); network net2 = new network(); net2.setname("mgmtnet"); clusterNetworks.add(net1); clusterNetworks.add(net2); List<VdsNetworkInterface> nics = new ArrayList<VdsNetworkInterface>(); VdsNetworkInterface nicWithUknownNetowrk = new VdsNetworkInterface(); nicWithUknownNetowrk.setNetworkName("nonExisitigNetworkName"); <START> nicWithUknownNetowrk.setName("nic3"); <END> nics.add(nicWithUknownNetowrk); initMocks(vdsNics, clusterNetworks); SetupNetworksParameters params = new SetupNetworksParameters(); params.setInterfaces(nics); SetupNetworksHelper validator = createHelper(params); assertTrue(validator.validate().contains(NETWORK_NOT_EXISTS_IN_CURRENT_CLUSTER)); }</code><technical_language>typo x 2: nicWithUknownNetowrk --> nicWithUnknownNetwork</technical_language>

Target:
public void validateAddingNonExistingNetwork() { List<VdsNetworkInterface> vdsNics = new ArrayList<VdsNetworkInterface>(); VdsNetworkInterface nic1 = new VdsNetworkInterface(); nic1.setNetworkName("vmnet"); nic1.setName("nic1"); vdsNics.add(nic1); VdsNetworkInterface nic2 = new VdsNetworkInterface(); nic2.setNetworkName("mgmtnet"); nic2.setName("nic2"); vdsNics.add(nic2); List<network> clusterNetworks = new ArrayList<network>(); network net1 = new network(); net1.setname("vmnet"); network net2 = new network(); net2.setname("mgmtnet"); clusterNetworks.add(net1); clusterNetworks.add(net2); List<VdsNetworkInterface> nics = new ArrayList<VdsNetworkInterface>(); VdsNetworkInterface nicWithUnknownNetwork = new VdsNetworkInterface(); nicWithUnknownNetwork.setNetworkName("nonExisitigNetworkName"); nicWithUnknownNetwork.setName("nic3"); nics.add(nicWithUnknownNetwork); initMocks(vdsNics, clusterNetworks); SetupNetworksParameters params = new SetupNetworksParameters(); params.setInterfaces(nics); SetupNetworksHelper validator = createHelper(params); assertTrue(validator.validate().contains(NETWORK_NOT_EXISTS_IN_CURRENT_CLUSTER)); }
Source:
<code><START> public static GameMode build(@Nullable final String mode, @Nullable final Locale locale) { <END> try { return MAPS_CACHE.get(localeFromNullable(locale)).nameToMode(mode); } catch (ExecutionException e) { throw new RuntimeException(e); } }</code><technical_language>support English in addition locale? in, if found, try English some people English names</technical_language>

Target:
public static GameMode build(@Nullable final String mode, @Nullable final Locale locale) { try { Locale targetLocale = localeFromNullable(locale); GameMode out = MAPS_CACHE.get(targetLocale).nameToMode(mode); if (out == null && !ALSO_ACCEPT_LOCALE.equals(targetLocale)) { out = MAPS_CACHE.get(ALSO_ACCEPT_LOCALE).nameToMode(mode); } return out; } catch (ExecutionException e) { throw new RuntimeException(e); } }
Source:
<code><START> public static String getMetricName(String metricName, Map<String, String> tags) { <END> Preconditions.checkState(tags.size() < MAX_ALLOWED_TAGS, "Too many tags set on the metric %s. " + "Maximum allowed number of tags is %d, found %s", metricName, MAX_ALLOWED_TAGS, tags.size()); return tags.entrySet().stream() .map(e -> e.getKey() + EQUALS + e.getValue()) .collect(Collectors.joining(DELIMITER, metricName + DELIMITER, "")); }</code><technical_language>want validate metricName DELIMITER, mess parsing out tags</technical_language>

Target:
public static String getMetricName(String metricName, Map<String, String> tags) { Preconditions.checkArgument(tags.size() <= MAX_ALLOWED_TAGS, "Too many tags set on the metric %s. " + "Maximum allowed number of tags is %s, found %s.", metricName, MAX_ALLOWED_TAGS, tags.size()); validateMetricComponentName(metricName, "metric"); validateMetricTagNames(tags); return tags.entrySet().stream() .map(e -> e.getKey() + EQUALS + e.getValue()) .collect(Collectors.joining(DELIMITER, metricName + DELIMITER, "")); }
Source:
<code>private void requestKeyTransfer(Set<Integer> segments) { <START> boolean isTransferingKeys = false; <END> synchronized (transferMapsLock) { List<Address> members = new ArrayList<>(cacheTopology.getActualMembers()); Collections.shuffle(members); for (Address source : members) { if (rpcManager.getAddress().equals(source)) { continue; } isTransferingKeys = true; InboundTransferTask inboundTransfer = new InboundTransferTask(segments, source, cacheTopology.getTopologyId(), rpcManager, commandsFactory, configuration.clustering().stateTransfer().timeout(), cacheName); addTransfer(inboundTransfer, segments); stateRequestExecutor.executeAsync(() -> { log.tracef("Requesting keys for segments %s from %s", inboundTransfer.getSegments(), inboundTransfer.getSource()); return inboundTransfer.requestKeys().whenComplete((nil, e) -> onTaskCompletion(inboundTransfer)); }); } } if (!isTransferingKeys) { log.trace("No keys in transfer, finishing segments " + segments); for (int segment : segments) { svm.notifyKeyTransferFinished(segment, false); } notifyEndOfStateTransferIfNeeded(cacheTopology.getTopologyId(), cacheTopology.getRebalanceId()); } }</code><technical_language>typo: transfering => transferring</technical_language>

Target:
private void requestKeyTransfer(Set<Integer> segments) { boolean isTransferringKeys = false; synchronized (transferMapsLock) { List<Address> members = new ArrayList<>(cacheTopology.getActualMembers()); Collections.shuffle(members); for (Address source : members) { if (rpcManager.getAddress().equals(source)) { continue; } isTransferringKeys = true; InboundTransferTask inboundTransfer = new InboundTransferTask(segments, source, cacheTopology.getTopologyId(), rpcManager, commandsFactory, configuration.clustering().stateTransfer().timeout(), cacheName, true); addTransfer(inboundTransfer, segments); stateRequestExecutor.executeAsync(() -> { log.tracef("Requesting keys for segments %s from %s", inboundTransfer.getSegments(), inboundTransfer.getSource()); return inboundTransfer.requestKeys().whenComplete((nil, e) -> onTaskCompletion(inboundTransfer)); }); } } if (!isTransferringKeys) { log.trace("No keys in transfer, finishing segments " + segments); for (int segment : segments) { svm.notifyKeyTransferFinished(segment, false); } notifyEndOfStateTransferIfNeeded(cacheTopology.getTopologyId(), cacheTopology.getRebalanceId()); } }
Source:
<code>public void setUp() throws Exception { MockitoAnnotations.initMocks(this); <START> instance = new ReplayService(new ClientProperties(), preferencesService, replayFileReader, notificationService, gameService, <END> taskService, i18n, reportingService, applicationContext, platformService, fafService, modService, mapService, eventBus, executorService); when(preferencesService.getReplaysDirectory()).thenReturn(replayDirectory.getRoot().toPath()); when(preferencesService.getCorruptedReplaysDirectory()).thenReturn(replayDirectory.getRoot().toPath().resolve("corrupt")); when(preferencesService.getCacheDirectory()).thenReturn(cacheDirectory.getRoot().toPath()); doAnswer(invocation -> invocation.getArgument(0)).when(taskService).submitTask(any()); }</code><technical_language>I rename instance... For example replayService</technical_language>

Target:
public void setUp() throws Exception { MockitoAnnotations.initMocks(this); instance = new ReplayService(new ClientProperties(), preferencesService, replayFileReader, notificationService, gameService, taskService, i18n, reportingService, applicationContext, platformService, fafService, modService, mapService, publisher, executorService); when(preferencesService.getReplaysDirectory()).thenReturn(replayDirectory.getRoot().toPath()); when(preferencesService.getCorruptedReplaysDirectory()).thenReturn(replayDirectory.getRoot().toPath().resolve("corrupt")); when(preferencesService.getCacheDirectory()).thenReturn(cacheDirectory.getRoot().toPath()); doAnswer(invocation -> invocation.getArgument(0)).when(taskService).submitTask(any()); }
Source:
<code>public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException { ResourceResolver resourceResolver = null; try { resourceResolver = workflowHelper.getResourceResolver(workflowSession); final String originalPayload = (String) workItem.getWorkflowData().getPayload(); final List<String> payloads = workflowPackageManager.getPaths(resourceResolver, originalPayload); final ProcessArgs processArgs = new ProcessArgs(metaDataMap); <START> final AtomicInteger count = new AtomicInteger(0); <END> final ResourceRunnable replicatorRunnable = new ResourceRunnable() { @Override public void run(final Resource resource) throws Exception { throttledTaskRunner.waitForLowCpuAndLowMemory(); replicator.replicate(resource.getResourceResolver().adaptTo(Session.class), processArgs.getReplicationActionType(), resource.getPath(), processArgs.getReplicationOptions()); } }; final ContentVisitor visitor = new ContentVisitor(replicatorRunnable); for (final String payload : payloads) { final Resource resource = resourceResolver.getResource(payload); if (processArgs.isTraverseTree()) { visitor.accept(resource); } else { replicatorRunnable.run(resource); } } log.info("Synthetic Workflow Wrapper processed [ ] total payloads", count.get()); } catch (Exception e) { throw new WorkflowException(e); } }</code><technical_language>This is created/instantiated, consumed</technical_language>

Target:
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException { ResourceResolver resourceResolver = null; try { resourceResolver = workflowHelper.getResourceResolver(workflowSession); final String originalPayload = (String) workItem.getWorkflowData().getPayload(); final List<String> payloads = workflowPackageManager.getPaths(resourceResolver, originalPayload); final ProcessArgs processArgs = new ProcessArgs(metaDataMap); final AtomicInteger count = new AtomicInteger(0); final ResourceRunnable replicatorRunnable = new ResourceRunnable() { @Override public void run(final Resource resource) throws Exception { if (processArgs.isThrottle()) { throttledTaskRunner.waitForLowCpuAndLowMemory(); } replicator.replicate(resource.getResourceResolver().adaptTo(Session.class), processArgs.getReplicationActionType(), resource.getPath(), processArgs.getReplicationOptions()); count.incrementAndGet(); } }; final ContentVisitor visitor = new ContentVisitor(replicatorRunnable); for (final String payload : payloads) { final Resource resource = resourceResolver.getResource(payload); if (processArgs.isTraverseTree()) { visitor.accept(resource); } else { replicatorRunnable.run(resource); } } log.info("Synthetic Workflow Wrapper processed [ ] total payloads", count.get()); } catch (Exception e) { throw new WorkflowException(e); } }
Source:
<code>private void setDictionaryBlockData(byte[] dictionaryData, int[] dictionaryOffsets, int positionCount) { verify(positionCount > 0); if (currentDictionaryData != dictionaryData) { boolean[] isNullVector = new boolean[positionCount]; isNullVector[positionCount - 1] = true; dictionaryOffsets[positionCount] = dictionaryOffsets[positionCount - 1]; dictionaryBlock = new VariableWidthBlock(positionCount, wrappedBuffer(dictionaryData), dictionaryOffsets, Optional.of(isNullVector)); if (filter != null && filter.isDeterministic()) { if (filterResults == null || filterResults.length < positionCount) { filterResults = new byte[positionCount]; } <START> Arrays.fill(filterResults, (byte) 0); <END> } currentDictionaryData = dictionaryData; } }</code><technical_language>need fill a newly created array. do a out following? if (filterResults == null || filterResults.length < positionCount) { filterResults = new byte[positionCount] } else { Arrays.fill(filterResults, (byte) 0); }</technical_language>

Target:
private void setDictionaryBlockData(byte[] dictionaryData, int[] dictionaryOffsets, int positionCount) { verify(positionCount > 0); if (currentDictionaryData != dictionaryData) { boolean[] isNullVector = new boolean[positionCount]; isNullVector[positionCount - 1] = true; dictionaryOffsets[positionCount] = dictionaryOffsets[positionCount - 1]; dictionaryBlock = new VariableWidthBlock(positionCount, wrappedBuffer(dictionaryData), dictionaryOffsets, Optional.of(isNullVector)); if (deterministicFilter) { if (filterResults == null || filterResults.length < positionCount) { filterResults = new byte[positionCount]; } else { Arrays.fill(filterResults, FILTER_NOT_EVALUATED); } } currentDictionaryData = dictionaryData; } }
Source:
<code><START> public ZNRecord getRecord() { <END> return _record; }</code><technical_language>change this</technical_language>

Target:
public final ZNRecord getRecord() { return _record; }
Source:
<code>private boolean isKfsSystemUserDvInitiator(CuDisbursementVoucherDocument dv) { String dvDocInitatorPrincipalId = dv.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId(); Person kfsSystemUser = getPersonService().getPersonByPrincipalName(KFSConstants.SYSTEM_USER); <START> String kfsSystemUserPrincipalId = kfsSystemUser.getPrincipalId(); <END> if ( (dvDocInitatorPrincipalId != null) && (kfsSystemUserPrincipalId != null) && (!StringUtils.isBlank(dvDocInitatorPrincipalId)) && (!StringUtils.isBlank(kfsSystemUserPrincipalId)) && (StringUtils.equals(dvDocInitatorPrincipalId, kfsSystemUserPrincipalId)) ) return true; else return false; }</code><technical_language>If kfsSystemUserPrincipalId is null want throw error, means wrong, user exist? approving a DV this is null right of action</technical_language>

Target:
private boolean isKfsSystemUserDvInitiator(CuDisbursementVoucherDocument dv) { String dvDocInitatorPrincipalId = dv.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId(); if ( StringUtils.equals(dvDocInitatorPrincipalId, getKfsSystemUserPrincipalId()) ) { return true; } else { return false; } }
Source:
<code>protected final void handleMessageInternal(Message<?> message) { Object result; if (this.advisedRequestHandler == null) { result = this.handleRequestMessage(message); } else { result = doInvokeAdvisedRequestHandler(message); } if (result != null) { <START> this.sendOutputs(result, message); <END> } else if (this.requiresReply) { throw new ReplyRequiredException(message, "No reply produced by handler '" + this.getComponentName() + "', and its 'requiresReply' property is set to true."); } else if (logger.isDebugEnabled()) { logger.debug("handler '" + this + "' produced no reply for request Message: " + message); } }</code><technical_language>~~this.~~</technical_language>

Target:
protected final void handleMessageInternal(Message<?> message) { Object result; if (this.advisedRequestHandler == null) { result = handleRequestMessage(message); } else { result = doInvokeAdvisedRequestHandler(message); } if (result != null) { sendOutputs(result, message); } else if (this.requiresReply) { throw new ReplyRequiredException(message, "No reply produced by handler '" + getComponentName() + "', and its 'requiresReply' property is set to true."); } else if (logger.isDebugEnabled()) { logger.debug("handler '" + this + "' produced no reply for request Message: " + message); } }