auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void simple() throws Exception { <START> Path tmpDir = Files.createTempDirectory("bookie"); <END> String path = tmpDir.toAbsolutePath().toString(); try { PersistentEntryLogMetadataMap entryMetadataMap = new PersistentEntryLogMetadataMap(path, configuration); List<EntryLogMetadata> metadatas = Lists.newArrayList(); int totalMetadata = 1000; for (int i = 1; i <= totalMetadata; i++) { EntryLogMetadata entryLogMeta = createEntryLogMetadata(i, i); metadatas.add(entryLogMeta); entryMetadataMap.put(i, entryLogMeta); } for (int i = 1; i <= totalMetadata; i++) { assertTrue(entryMetadataMap.containsKey(i)); } assertEquals(entryMetadataMap.size(), totalMetadata); entryMetadataMap.forEach((logId, metadata) -> { assertEquals(metadatas.get(logId.intValue() - 1).getTotalSize(), metadata.getTotalSize()); for (int i = 0; i < logId.intValue(); i++) { assertTrue(metadata.containsLedger(i)); } }); for (int i = 1; i <= totalMetadata; i++) { entryMetadataMap.remove(i); } for (int i = 1; i <= totalMetadata; i++) { assertFalse(entryMetadataMap.containsKey(i)); } assertEquals(entryMetadataMap.size(), 0); entryMetadataMap.close(); } finally { FileUtils.deleteDirectory(new File(tmpDir.toAbsolutePath().toString())); } }</code><technical_language>junit TemporaryFolder rule</technical_language>

Target:
public void simple() throws Exception { File tmpDir = tempFolder.newFolder(); String path = tmpDir.getAbsolutePath().toString(); PersistentEntryLogMetadataMap entryMetadataMap = new PersistentEntryLogMetadataMap(path, configuration); List<EntryLogMetadata> metadatas = Lists.newArrayList(); int totalMetadata = 1000; for (int i = 1; i <= totalMetadata; i++) { EntryLogMetadata entryLogMeta = createEntryLogMetadata(i, i); metadatas.add(entryLogMeta); entryMetadataMap.put(i, entryLogMeta); } for (int i = 1; i <= totalMetadata; i++) { assertTrue(entryMetadataMap.containsKey(i)); } assertEquals(entryMetadataMap.size(), totalMetadata); entryMetadataMap.forEach((logId, metadata) -> { assertEquals(metadatas.get(logId.intValue() - 1).getTotalSize(), metadata.getTotalSize()); for (int i = 0; i < logId.intValue(); i++) { assertTrue(metadata.containsLedger(i)); } }); for (int i = 1; i <= totalMetadata; i++) { entryMetadataMap.remove(i); } for (int i = 1; i <= totalMetadata; i++) { assertFalse(entryMetadataMap.containsKey(i)); } assertEquals(entryMetadataMap.size(), 0); entryMetadataMap.close(); }
Source:
<code>private JMethod findImplementation(@Nonnull JMethodIdWide methodId, @Nonnull JType returnType, @Nonnull JDefinedClassOrInterface receiverType) { JMethod foundMethod = findMethod(methodId, receiverType, returnType); if (foundMethod != null) { return foundMethod; } JClass currentType = receiverType.getSuperClass(); while (currentType instanceof JDefinedClass) { foundMethod = findMethod(methodId, currentType, returnType); if (foundMethod != null) { return foundMethod; } currentType = ((JDefinedClass) currentType).getSuperClass(); } <START> findImplementationInInterfaces(methodId, returnType, receiverType); <END> return null; }</code><technical_language>JMethod is</technical_language>

Target:
private JMethod findImplementation(@Nonnull JMethodIdWide methodId, @Nonnull JType returnType, @Nonnull JDefinedClassOrInterface receiverType) { JMethod foundMethod = findMethod(methodId, receiverType, returnType); if (foundMethod != null) { return foundMethod; } JClass currentType = receiverType.getSuperClass(); while (currentType instanceof JDefinedClass) { foundMethod = findMethod(methodId, currentType, returnType); if (foundMethod != null) { return foundMethod; } currentType = ((JDefinedClass) currentType).getSuperClass(); } foundMethod = findImplementationInInterfaces(methodId, returnType, receiverType); return foundMethod; }
Source:
<code><START> public CcAES(final Codec codec, final String key){ <END> this.origin = codec; this.key = key; }</code><technical_language>@sebing space { missing</technical_language>

Target:
public CcAES(final Codec codec, final String key) { this(codec, key.getBytes(Charset.defaultCharset())); }
Source:
<code>public void testClassesMatch() throws SQLException { Statement stmt = conn.createStatement(); stmt.executeUpdate( "INSERT INTO alltypes (bool, i2, i4, i8, num, re, fl, ch, vc, tx, d, t, tz, ts, tsz, bt) VALUES ('t', 2, 4, 8, 3.1, 3.14, 3.141, 'c', 'vc', 'tx', '2004-04-09', '09:01:00', '11:11:00-01','2004-04-09 09:01:00','1999-09-19 14:23:12-09', '\\\\123')"); ResultSet rs = stmt.executeQuery("SELECT * FROM alltypes"); ResultSetMetaData rsmd = rs.getMetaData(); assertTrue(rs.next()); for (int i = 0; i < rsmd.getColumnCount(); i++) { <START> assertEquals("types mismatched on column " + i, rs.getObject(i + 1).getClass().getName(), rsmd.getColumnClassName(i + 1)); <END> } }</code><technical_language>please, add column name</technical_language>

Target:
public void testClassesMatch() throws SQLException { Statement stmt = conn.createStatement(); stmt.executeUpdate( "INSERT INTO alltypes (bool, i2, i4, i8, num, re, fl, ch, vc, tx, d, t, tz, ts, tsz, bt) VALUES ('t', 2, 4, 8, 3.1, 3.14, 3.141, 'c', 'vc', 'tx', '2004-04-09', '09:01:00', '11:11:00-01','2004-04-09 09:01:00','1999-09-19 14:23:12-09', '\\\\123')"); ResultSet rs = stmt.executeQuery("SELECT * FROM alltypes"); ResultSetMetaData rsmd = rs.getMetaData(); assertTrue(rs.next()); for (int i = 0; i < rsmd.getColumnCount(); i++) { assertEquals("types mismatched on column " + i + 1 + " " + rsmd.getColumnName(i + 1), rs.getObject(i + 1).getClass().getName(), rsmd.getColumnClassName(i + 1)); } }
Source:
<code>public DeletedAccount delete(RequestOptions options) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException { <START> return request(RequestMethod.DELETE, instanceURL(Account.class, this.id), null, DeletedAccount.class, options); <END> }</code><technical_language>IMO call other methods. request path a call request</technical_language>

Target:
public DeletedAccount delete(RequestOptions options) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException { return delete(null, (RequestOptions) null); }
Source:
<code><START> public void testBug() throws Exception { <END> if (!canCreateSymLinks()) return; String fileName = "file.txt"; IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IProject project = root.getProject(getUniqueString()); IFile file = project.getFile(fileName); try { project.create(getMonitor()); project.open(getMonitor()); } catch (CoreException e) { fail("1.0", e); } IFileStore tempFileStore = getTempStore().getChild(fileName); createFileInFileSystem(tempFileStore); IPath fileInTempDirPath = URIUtil.toPath(tempFileStore.toURI()); symLinkAndRefresh(project, fileName, fileInTempDirPath); IFile[] files = root.findFilesForLocation(file.getLocation()); assertEquals("7.0", 1, files.length); assertEquals("7.1", file, files[0]); }</code><technical_language>throws clause is needed here</technical_language>

Target:
public void testBug() { if (!canCreateSymLinks()) return; String fileName = "file.txt"; IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IProject project = root.getProject(getUniqueString()); IFile file = project.getFile(fileName); try { project.create(getMonitor()); project.open(getMonitor()); } catch (CoreException e) { fail("1.0", e); } IFileStore tempFileStore = getTempStore().getChild(fileName); createFileInFileSystem(tempFileStore); IPath fileInTempDirPath = URIUtil.toPath(tempFileStore.toURI()); symLinkAndRefresh(project, fileName, fileInTempDirPath); IFile[] files = root.findFilesForLocation(file.getLocation()); assertEquals("7.0", 1, files.length); assertEquals("7.1", file, files[0]); }
Source:
<code>public Map<TopicPartition, String> partitionDirs() { <END> <START> Map<TopicPartition, String> result = new HashMap<>(); for (AlterReplicaLogDirsRequestData.AlterReplicaLogDir alter : data.dirs()) { alter.topics().stream().flatMap(t -> { Stream<TopicPartition> objectStream = t.partitions().stream().map( p -> new TopicPartition(t.name(), p.intValue())); return objectStream; }).forEach(tp -> result.put(tp, alter.path())); } return result; }</code><technical_language>flatMap wasteful here. nested forEachs add TopicPartition path HashMap</technical_language>

Target:
public Map<TopicPartition, String> partitionDirs() { Map<TopicPartition, String> result = new HashMap<>(); data.dirs().forEach(alterDir -> alterDir.topics().forEach(topic -> topic.partitions().forEach(partition -> result.put(new TopicPartition(topic.name(), partition.intValue()), alterDir.path()))) ); return result; }
Source:
<code>public static FloatColumnSelector getFloatColumnSelector( ColumnSelectorFactory metricFactory, String fieldName, String fieldExpression ) { <START> if (fieldName != null) { <END> return metricFactory.makeFloatColumnSelector(fieldName); } final NumericColumnSelector numeric = metricFactory.makeMathExpressionSelector(fieldExpression); return new FloatColumnSelector() { @Override public float get() { return numeric.get().floatValue(); } }; }</code><technical_language>nice verify of fieldName / fieldExpression is set, both</technical_language>

Target:
public static FloatColumnSelector getFloatColumnSelector( ColumnSelectorFactory metricFactory, String fieldName, String fieldExpression ) { if (fieldName != null && fieldExpression == null) { return metricFactory.makeFloatColumnSelector(fieldName); } if (fieldName == null && fieldExpression != null) { final NumericColumnSelector numeric = metricFactory.makeMathExpressionSelector(fieldExpression); return new FloatColumnSelector() { @Override public float get() { return numeric.get().floatValue(); } }; } throw new IllegalArgumentException("Must have a valid, non-null fieldName or expression"); }
Source:
<code>public static Resource getResource(final String filePath) { return new WritableResource() { @Override public File getFile() { final String filename = getFilename(); if (filename != null) { return new File(filename); } <START> return null; <END> } @Override public InputStream getInputStream() throws IOException { return getInputStreamFromName(filePath); } @Override public String getFilename() { String filename = null; final String prefix = extractPrefix(filePath); if (prefix == null) { filename = filePath; } else if (prefix.equals(RESOURCE_PREFIX) || prefix.equals(CLASSPATH_PREFIX)) { final String path = filePath.substring(prefix.length() + 1); final URL url; if (prefix.equals(RESOURCE_PREFIX)) { url = CommonHelper.class.getResource(startWithSlash(path)); } else { url = Thread.currentThread().getContextClassLoader().getResource(path); } if (url == null) { throw new TechnicalException("Do not use the resource: or classpath: prefix for non-existing files. Use a direct path (relative or absolute, no prefix)"); } filename = url.toString().substring(5); } logger.debug("filepath: -> filename: {}", filePath, filename); return filename; } @Override public boolean exists() { final File f = getFile(); if (f != null) { return f.exists(); } return true; } @Override public OutputStream getOutputStream() throws IOException { final String filename = getFilename(); if (filename != null) { return new FileOutputStream(filePath); } return null; } }; }</code><technical_language>Log this condition</technical_language>

Target:
public static Resource getResource(final String filePath) { return new WritableResource() { @Override public File getFile() { final String filename = getFilename(); if (filename != null) { return new File(filename); } logger.warn("This filePath: is not a file. Returning null in the getFile() method", filePath); return null; } @Override public InputStream getInputStream() throws IOException { return getInputStreamFromName(filePath); } @Override public String getFilename() { String filename = null; final String prefix = extractPrefix(filePath); if (prefix == null) { filename = filePath; } else if (prefix.equals(RESOURCE_PREFIX) || prefix.equals(CLASSPATH_PREFIX)) { final String path = filePath.substring(prefix.length() + 1); final URL url; if (prefix.equals(RESOURCE_PREFIX)) { url = CommonHelper.class.getResource(startWithSlash(path)); } else { url = Thread.currentThread().getContextClassLoader().getResource(path); } if (url == null) { throw new TechnicalException("Do not use the resource: or classpath: prefix for non-existing files. Use a direct path (relative or absolute, no prefix)"); } filename = url.toString().substring(5); } logger.debug("filepath: -> filename: {}", filePath, filename); return filename; } @Override public boolean exists() { final File f = getFile(); if (f != null) { return f.exists(); } return true; } @Override public OutputStream getOutputStream() throws IOException { final String filename = getFilename(); if (filename != null) { return new FileOutputStream(filePath); } return null; } }; }
Source:
<code>public static void refreshReloadableConfigsInVdcOptionCache() { List<VdcOption> list = getVdcOptionDAO().getAll(); for (VdcOption option : list) { try { if (isReloadable(option.getoption_name())) { updateOption(option); } } catch (NoSuchFieldException e) { <START> log.errorFormat("Not refreshing field {0}: does not exist in class ConfigValues.", option.getoption_name()); <END> } } }</code><technical_language>minor: ConfigValues.class.getSimpleName() instead of hard-coded class name</technical_language>

Target:
public static void refreshReloadableConfigsInVdcOptionCache() { List<VdcOption> list = getVdcOptionDAO().getAll(); for (VdcOption option : list) { try { if (isReloadable(option.getoption_name())) { updateOption(option); } } catch (NoSuchFieldException e) { log.errorFormat("Not refreshing field {0}: does not exist in class {1}.", option.getoption_name(), ConfigValues.class.getSimpleName()); } } }
Source:
<code>private Collection<? extends IClasspathEntry> junitLauncher(IJavaProject javaProject, String version) throws JavaModelException { File projectDir = CorePlugin.getInstance().getStateLocation().append("junit5").toFile(); if (!projectDir.exists()) { if (!projectDir.mkdirs()) { throw new RuntimeException("Cannot create directory " + projectDir.getAbsolutePath()); } } File buildFile = new File(projectDir, "build.gradle"); String buildScript = "" + "plugins {\n" + " id 'java-library'\n" + "}\n" + "\n" + "repositories {\n" + " jcenter()\n" + "}\n" + "\n" + "dependencies {\n" <START> + " testmplementation 'org.junit.platform:junit-platform-launcher:" + version + "'\n" <END> + "}\n"; try { buildFile.createNewFile(); Files.write(buildFile.toPath(), buildScript.getBytes(), StandardOpenOption.WRITE); } catch (IOException e) { throw new UncheckedIOException(e); } GradleConnector connector = GradleConnector.newConnector(); try (ProjectConnection connection = connector.forProjectDirectory(projectDir).connect()) { EclipseProject eclipseProject = connection.getModel(EclipseProject.class); return collectExternalDependencies(this.projectContext, javaProject, eclipseProject.getClasspath()); } }</code><technical_language>a typo in testImplementation</technical_language>

Target:
private Collection<? extends IClasspathEntry> junitLauncher(IJavaProject javaProject, String version) throws JavaModelException { File projectDir = CorePlugin.getInstance().getStateLocation().append("junit5").toFile(); if (!projectDir.exists()) { if (!projectDir.mkdirs()) { throw new RuntimeException("Cannot create directory " + projectDir.getAbsolutePath()); } } File buildFile = new File(projectDir, "build.gradle"); String buildScript = "" + "plugins {\n" + " id 'java-library'\n" + "}\n" + "\n" + "repositories {\n" + " jcenter()\n" + "}\n" + "\n" + "dependencies {\n" + " testImplementation 'org.junit.platform:junit-platform-launcher:" + version + "'\n" + "}\n"; try { buildFile.createNewFile(); Files.write(buildFile.toPath(), buildScript.getBytes(), StandardOpenOption.WRITE); } catch (IOException e) { throw new UncheckedIOException(e); } GradleConnector connector = GradleConnector.newConnector(); try (ProjectConnection connection = connector.forProjectDirectory(projectDir).connect()) { EclipseProject eclipseProject = connection.getModel(EclipseProject.class); return collectExternalDependencies(this.projectContext, javaProject, eclipseProject.getClasspath()); } }
Source:
<code>public void testListMembers() { List<Member> members = api().list(); assertNotNull(members); assertTrue(members.size() > 0); for (Member member : members) { if (!member.id().equals(selfID)) { this.nonSelfMember = member; return; } } <START> throw new RuntimeException("Could not find another member in cluster with different id"); <END> }</code><technical_language>Assert.fail</technical_language>

Target:
public void testListMembers() { List<Member> members = api().list(); assertNotNull(members); assertTrue(members.size() > 0); for (Member member : members) { if (!member.id().equals(selfID)) { this.nonSelfMember = member; return; } } fail("Could not find another member in cluster with different id"); }
Source:
<code>private static int execute(CommandSource sender, Collection<? extends Entity> entities, DimensionType dim, BlockPos pos) throws CommandSyntaxException { entities.removeIf(e -> !canEntityTeleport(e)); if (entities.isEmpty()) throw NO_ENTITIES.create(); entities.stream().filter(e -> e.dimension == dim).forEach(e -> sender.sendFeedback(new TranslationTextComponent("commands.forge.setdim.invalid.nochange", e.getDisplayName().getFormattedText(), dim), true)); <START> entities.stream().filter(e -> e.dimension != dim).forEach(e -> e.changeDimension(dim, new PortallessTeleporter())); <END> return 0; }</code><technical_language>need recreate this invocation. least, a lambda</technical_language>

Target:
private static int execute(CommandSource sender, Collection<? extends Entity> entities, DimensionType dim, BlockPos pos) throws CommandSyntaxException { entities.removeIf(e -> !canEntityTeleport(e)); if (entities.isEmpty()) throw NO_ENTITIES.create(); entities.stream().filter(e -> e.dimension == dim).forEach(e -> sender.sendFeedback(new TranslationTextComponent("commands.forge.setdim.invalid.nochange", e.getDisplayName().getFormattedText(), dim), true)); entities.stream().filter(e -> e.dimension != dim).forEach(e -> e.changeDimension(dim, PORTALLESS)); return 0; }
Source:
<code>public void createObjects(long reps) { for (long i = 0; i < reps; i++) { <START> realm.where(AllTypes.class).findFirst(); <END> } }</code><technical_language>this test measure overhead of querying is orders of magnitude slower creating a object. rewrite is creating query + findAll() in calling first()</technical_language>

Target:
public void createObjects(long reps) { RealmResults<AllTypes> results = realm.where(AllTypes.class).findAll(); for (long i = 0; i < reps; i++) { results.first(); } }
Source:
<code>protected List<String> getTokens() { List<String> allAliases = new ArrayList(); try { allAliases = aliasService.getAliasesForCluster(AliasService.NO_CLUSTER_NAME); <START> allAliases.stream().filter(a -> a.contains("TOKEN_MAX_LIFETIME_POSTFIX")).map(a -> a.substring(0, a.indexOf("TOKEN_MAX_LIFETIME_POSTFIX"))) <END> .collect(Collectors.toList()); } catch (AliasServiceException e) { log.errorAccessingTokenState(e); } return allAliases; }</code><technical_language>This a string - variable reference</technical_language>

Target:
protected List<String> getTokens() { List<String> allAliases = new ArrayList(); try { allAliases = aliasService.getAliasesForCluster(AliasService.NO_CLUSTER_NAME); allAliases = allAliases.stream().filter(a -> a.contains(TOKEN_MAX_LIFETIME_POSTFIX)).map(a -> a.substring(0, a.indexOf(TOKEN_MAX_LIFETIME_POSTFIX))) .collect(Collectors.toList()); } catch (AliasServiceException e) { log.errorEvictingTokens(e); } return allAliases; }
Source:
<code>public int compareTo(Version o) { Integer majorInteger = new Integer(major); Integer minorInteger = new Integer(minor); Integer maintenanceInteger = new Integer(maintenance); Integer oMajorInteger = new Integer(o.major); Integer oMinorInteger = new Integer(o.minor); <START> Integer oMaintenanceInteger = new Integer(o.maintenance); <END> if (majorInteger.compareTo(oMajorInteger) == 0 && minorInteger.compareTo(oMinorInteger) == 0 && maintenanceInteger.compareTo(oMaintenanceInteger) == 0) { return 0; } else if (majorInteger.compareTo(oMajorInteger) == 0 && minorInteger.compareTo(oMinorInteger) == 0) { return maintenanceInteger.compareTo(oMaintenanceInteger); } else if (majorInteger.compareTo(oMajorInteger) == 0) { return minorInteger.compareTo(oMinorInteger); } return majorInteger.compareTo(oMajorInteger); }</code><technical_language>slightly inefficient package in Integers call. compareTo called a lot (> thousands times for a package). change private fields Integer ints here. I a fix ints quicker. above</technical_language>

Target:
public int compareTo(Version o) { if (major == o.major && minor == o.minor && maintenance == o.maintenance) { return 0; } else if (major == o.major && minor == o.minor) { return compareInts(maintenance, o.maintenance); } else if (major == o.major) { return compareInts(minor, o.minor); } return compareInts(major, o.major); }
Source:
<code>private static void persistTopology(VDS vds, Map<String, VdsNetworkInterface> nicsByName) { InterfaceDao interfaceDAO = DbFacade.getInstance().getInterfaceDao(); List<VdsNetworkInterface> dbIfaces = interfaceDAO.getAllInterfacesForVds(vds.getId()); List<String> updatedIfaces = new ArrayList<String>(); List<VdsNetworkInterface> dbIfacesToBatch = new ArrayList<>(); Map<String, VdsNetworkInterface> hostNicsByNames = Entities.entitiesByName(vds.getInterfaces()); for (VdsNetworkInterface dbIface : dbIfaces) { if (hostNicsByNames.containsKey(dbIface.getName())) { VdsNetworkInterface vdsIface = hostNicsByNames.get(dbIface.getName()); <START> vdsIface.setId(dbIface.getId()); <END> vdsIface.setLabels(dbIface.getLabels()); dbIfacesToBatch.add(vdsIface); updatedIfaces.add(vdsIface.getName()); } else { interfaceDAO.removeInterfaceFromVds(dbIface.getId()); interfaceDAO.removeStatisticsForVds(dbIface.getId()); } } if (nicsByName != null) { updateInterfacesWithUserConfiguration(dbIfacesToBatch, nicsByName); updateInterfacesWithUserConfiguration(vds.getInterfaces(), nicsByName); } if (!dbIfacesToBatch.isEmpty()) { interfaceDAO.massUpdateInterfacesForVds(dbIfacesToBatch); } for (VdsNetworkInterface vdsIface : vds.getInterfaces()) { if (!updatedIfaces.contains(vdsIface.getName())) { interfaceDAO.saveInterfaceForVds(vdsIface); interfaceDAO.saveStatisticsForVds(vdsIface.getStatistics()); } } }</code><technical_language>preserving QoS information DB entity, refreshCapabilities result in nullifying qos data</technical_language>

Target:
private static void persistTopology(VDS vds, Map<String, VdsNetworkInterface> nicsByName) { InterfaceDao interfaceDAO = DbFacade.getInstance().getInterfaceDao(); List<VdsNetworkInterface> dbIfaces = interfaceDAO.getAllInterfacesForVds(vds.getId()); List<String> updatedIfaces = new ArrayList<String>(); List<VdsNetworkInterface> dbIfacesToBatch = new ArrayList<>(); Map<String, VdsNetworkInterface> hostNicsByNames = Entities.entitiesByName(vds.getInterfaces()); for (VdsNetworkInterface dbIface : dbIfaces) { if (hostNicsByNames.containsKey(dbIface.getName())) { VdsNetworkInterface vdsIface = hostNicsByNames.get(dbIface.getName()); vdsIface.setId(dbIface.getId()); vdsIface.setLabels(dbIface.getLabels()); vdsIface.setQosOverridden(dbIface.isQosOverridden()); dbIfacesToBatch.add(vdsIface); updatedIfaces.add(vdsIface.getName()); } else { interfaceDAO.removeInterfaceFromVds(dbIface.getId()); interfaceDAO.removeStatisticsForVds(dbIface.getId()); } } if (nicsByName != null) { updateInterfacesWithUserConfiguration(dbIfacesToBatch, nicsByName); updateInterfacesWithUserConfiguration(vds.getInterfaces(), nicsByName); } if (!dbIfacesToBatch.isEmpty()) { interfaceDAO.massUpdateInterfacesForVds(dbIfacesToBatch); } for (VdsNetworkInterface vdsIface : vds.getInterfaces()) { if (!updatedIfaces.contains(vdsIface.getName())) { interfaceDAO.saveInterfaceForVds(vdsIface); interfaceDAO.saveStatisticsForVds(vdsIface.getStatistics()); } } }
Source:
<code>public static void setTransparency( Element elem, int alpha ) { float ieVersion = getIEVersion(); if ( ieVersion >= 5.5 && ieVersion < 7.0 ) { elem = DOM.getChild( elem, 0 ); if ( map.containsKey( elem ) ) { if ( alpha == 100 ) { DOM.setStyleAttribute( elem, "filter", map.get( elem ) + "" ); } else { DOM.setStyleAttribute( elem, "filter", map.get( elem ) + ", progid:DXImageTransform.Microsoft.Alpha(opacity=" + alpha + ");" ); } } else { map.put( elem, DOM.getStyleAttribute( elem, "filter" ) ); if ( alpha == 100 ) { DOM.setStyleAttribute( elem, "filter", map.get( elem ) + "" ); } else { DOM.setStyleAttribute( elem, "filter", map.get( elem ) + ", progid:DXImageTransform.Microsoft.Alpha(opacity=" + alpha + ");" ); } } } else if ( ieVersion >= 7.0 ) { DOM.setStyleAttribute( elem, "filter", "alpha(opacity=" + alpha + ")" ); } else { <START> DOM.setStyleAttribute( elem, "MozOpacity", "" + ( new Integer( alpha ).floatValue() / 100 ) + "" ); END> DOM.setStyleAttribute( elem, "opacity", "" + ( new Integer( alpha ).floatValue() / 100 ) + "" ); } }</code><technical_language>@krivera-pentaho Kris, is this OK change? I this changed versions. need targeting right versions support. Thanks</technical_language>

Target:
public static void setTransparency( Element elem, int alpha ) { float ieVersion = getIEVersion(); if ( ieVersion >= 5.5 && ieVersion < 7.0 ) { elem = DOM.getChild( elem, 0 ); if ( map.containsKey( elem ) ) { if ( alpha == 100 ) { DOM.setStyleAttribute( elem, "filter", map.get( elem ) + "" ); } else { DOM.setStyleAttribute( elem, "filter", map.get( elem ) + ", progid:DXImageTransform.Microsoft.Alpha(opacity=" + alpha + ");" ); } } else { map.put( elem, DOM.getStyleAttribute( elem, "filter" ) ); if ( alpha == 100 ) { DOM.setStyleAttribute( elem, "filter", map.get( elem ) + "" ); } else { DOM.setStyleAttribute( elem, "filter", map.get( elem ) + ", progid:DXImageTransform.Microsoft.Alpha(opacity=" + alpha + ");" ); } } } else if ( ieVersion >= 7.0 ) { DOM.setStyleAttribute( elem, "filter", "alpha(opacity=" + alpha + ")" ); } else { DOM.setStyleAttribute( elem, "opacity", "" + ( new Integer( alpha ).floatValue() / 100 ) + "" ); } }
Source:
<code>public String toString() { final ByteArrayOutputStream out = new ByteArrayOutputStream(); this.getSnapshot().dump(out); try { <START> return out.toString(Charset.defaultCharset().name()); <END> } catch (UnsupportedEncodingException e) { return super.toString(); } }</code><technical_language>StandardCharsets.UTF_8 avoid deal UnsupportedEncodingException</technical_language>

Target:
public String toString() { final ByteArrayOutputStream out = new ByteArrayOutputStream(); this.getSnapshot().dump(out); try { return out.toString(StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException e) { return super.toString(); } }
Source:
<code>public void testCreateAccount_WithMD5Password() throws JSONException { String userName = "TEST_USER_NAME"; String userNickName = "TEST_USER_NICK_NAME"; String userPassword = "93189e2c4c7b1a2c7b16a24d5daa98a9"; String userEmail = "TEST_USER_EMAIL"; <START> long enbale = 1; <END> JSONObject accountJSON = new JSONObject(); accountJSON.put(AccountJSONEnum.USERNAME, userName); accountJSON.put(AccountJSONEnum.NICK_NAME, userNickName); accountJSON.put(AccountJSONEnum.PASSWORD, userPassword); accountJSON.put(AccountJSONEnum.EMAIL, userEmail); accountJSON.put(AccountJSONEnum.ENABLE, enbale); Response response = mClient.target(BASE_URL) .path("accounts") .request() .post(Entity.text(accountJSON.toString())); AccountObject account = AccountObject.get(userName); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); assertEquals(userName, account.getUsername()); assertEquals(userNickName, account.getNickName()); assertEquals(userPassword, account.getPassword()); assertEquals(userEmail, account.getEmail()); assertEquals(true, account.getEnable()); }</code><technical_language>int enbale = 1;</technical_language>

Target:
public void testCreateAccount_WithMD5Password() throws JSONException { String userName = "TEST_USER_NAME"; String userNickName = "TEST_USER_NICK_NAME"; String userPassword = "93189e2c4c7b1a2c7b16a24d5daa98a9"; String userEmail = "TEST_USER_EMAIL"; int enbale = 1; JSONObject accountJSON = new JSONObject(); accountJSON.put(AccountJSONEnum.USERNAME, userName); accountJSON.put(AccountJSONEnum.NICK_NAME, userNickName); accountJSON.put(AccountJSONEnum.PASSWORD, userPassword); accountJSON.put(AccountJSONEnum.EMAIL, userEmail); accountJSON.put(AccountJSONEnum.ENABLE, enbale); Response response = mClient.target(BASE_URL) .path("accounts") .request() .post(Entity.text(accountJSON.toString())); AccountObject account = AccountObject.get(userName); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); assertEquals(userName, account.getUsername()); assertEquals(userNickName, account.getNickName()); assertEquals(userPassword, account.getPassword()); assertEquals(userEmail, account.getEmail()); assertEquals(true, account.getEnable()); }
Source:
<code>public String getTempFileNames(TopicPartition topicPart) { <START> if (tempFileNames.containsKey(topicPart)) { <END> return tempFileNames.get(topicPart); } else { return null; } }</code><technical_language>return tempFileNames.get(topicPart);</technical_language>

Target:
public String getTempFileNames(TopicPartition topicPart) { return tempFileNames.get(topicPart); }
Source:
<code>public void deleteGroup(String key, IPerson deleter) { if (!canDeleteGroup(deleter, key)) { throw new RuntimeAuthorizationException(deleter, IPermission.DELETE_GROUP_ACTIVITY, key); } log.info("Deleting group with key " + key); IEntityGroup group = GroupService.findGroup(key); <START> Iterator<IEntityGroup> iter = group.getParentGroups().iterator(); <END> while (iter.hasNext()) { IEntityGroup parent = (IEntityGroup) iter.next(); parent.removeChild(group); parent.updateMembers(); } group.delete(); }</code><technical_language>For refactor</technical_language>

Target:
public void deleteGroup(String key, IPerson deleter) { if (!canDeleteGroup(deleter, key)) { throw new RuntimeAuthorizationException(deleter, IPermission.DELETE_GROUP_ACTIVITY, key); } log.info("Deleting group with key " + key); IEntityGroup group = GroupService.findGroup(key); for (IEntityGroup parent : group.getParentGroups()) { parent.removeChild(group); parent.updateMembers(); } group.delete(); }
Source:
<code>public void evaluateIntermediate(int groupId, BlockBuilder output) { if (blockBuilders == null) { if (rawInputs == null) { return; <START> } <END> blockBuilders = new ObjectBigArray<>(); for (GroupIdPage groupIdPage : rawInputs) { Page page = groupIdPage.getPage(); GroupByIdBlock groupIdsBlock = groupIdPage.getGroupByIdBlock(); for (int position = 0; position < page.getPositionCount(); position++) { long currentGroupId = groupIdsBlock.getGroupId(position); blockBuilders.ensureCapacity(currentGroupId); RowBlockBuilder rowBlockBuilder = blockBuilders.get(currentGroupId); if (rowBlockBuilder == null) { rowBlockBuilder = new RowBlockBuilder(spillingTypes, null, (int) groupIdsBlock.getGroupCount()); } BlockBuilder currentOutput = rowBlockBuilder.beginBlockEntry(); for (int channel = 0; channel < spillingTypes.size(); channel++) { spillingTypes.get(channel).appendTo(page.getBlock(channel), position, currentOutput); } rowBlockBuilder.closeEntry(); blockBuilders.set(currentGroupId, rowBlockBuilder); } } rawInputs = null; rawInputsSize = 0; } BlockBuilder singleArrayBlockWriter = output.beginBlockEntry(); checkState(rawInputs == null && blockBuilders != null); checkState(singleArrayBlockWriter instanceof SingleArrayBlockWriter); RowBlock rowBlock = (RowBlock) blockBuilders.get((long) groupId).build(); for (int i = 0; i < rowBlock.getPositionCount(); i++) { singleArrayBlockWriter.appendStructure(rowBlock.getBlock(i)); } output.closeEntry(); }</code><technical_language>break a line</technical_language>

Target:
public void evaluateIntermediate(int groupId, BlockBuilder output) { checkState(output instanceof ArrayBlockBuilder); if (blockBuilders == null) { checkState(rawInputs != null); blockBuilders = new ObjectBigArray<>(); for (int i = 0; i < rawInputsLength; i++) { GroupIdPage groupIdPage = rawInputs.get(i); Page page = groupIdPage.getPage(); GroupByIdBlock groupIdsBlock = groupIdPage.getGroupByIdBlock(); for (int position = 0; position < page.getPositionCount(); position++) { long currentGroupId = groupIdsBlock.getGroupId(position); blockBuilders.ensureCapacity(currentGroupId); RowBlockBuilder rowBlockBuilder = blockBuilders.get(currentGroupId); if (rowBlockBuilder == null) { rowBlockBuilder = new RowBlockBuilder(spillingTypes, null, (int) groupIdsBlock.getGroupCount()); } BlockBuilder currentOutput = rowBlockBuilder.beginBlockEntry(); for (int channel = 0; channel < spillingTypes.size(); channel++) { spillingTypes.get(channel).appendTo(page.getBlock(channel), position, currentOutput); } rowBlockBuilder.closeEntry(); blockBuilders.set(currentGroupId, rowBlockBuilder); } } rawInputs = null; rawInputsLength = 0; } BlockBuilder singleArrayBlockWriter = output.beginBlockEntry(); checkState(rawInputs == null && blockBuilders != null); RowBlock rowBlock = (RowBlock) blockBuilders.get(groupId).build(); for (int i = 0; i < rowBlock.getPositionCount(); i++) { singleArrayBlockWriter.appendStructure(rowBlock.getBlock(i)); } output.closeEntry(); }
Source:
<code>public void scheduleTasks() { ScheduledExecutorService scheduledExecutorService = CoreUtils.createExecutor(); scheduledExecutorService.scheduleWithFixedDelay(new Runnable() { public void run() { dbCleanUpTask(); jwksRegenerationTask(); } <START> }, configurationService.get().getDbCleanupIntervalInHours(), configurationService.get().getDbCleanupIntervalInHours(), TimeUnit.HOURS); <END> }</code><technical_language>Introduce jwksRegenerationInterval schedule separately. Clean run more comparing jwks regeneration</technical_language>

Target:
public void scheduleTasks() { dbCleanUpTask(); jwksRegenerationTask(); }
Source:
<code>public List<String> getDependencies() { List<String> dependencies = new ArrayList<String>(); dependencies.add(AttributesManager.NS_FACILITY_ATTR_DEF + ":unixGID-namespace"); dependencies.add(AttributesManager.NS_FACILITY_ATTR_DEF + ":unixGroupName-namespace"); dependencies.add(AttributesManager.NS_RESOURCE_ATTR_DEF + ":unixGID-namespace" + ":*"); dependencies.add(AttributesManager.NS_GROUP_ATTR_DEF + ":unixGID-namespace" + ":*"); <START> dependencies.add(AttributesManager.NS_GROUP_ATTR_DEF + ":unixGroupName-namespace:*"); <END> return dependencies; }</code><technical_language>output like: dependencies.add(AttributesManager.NS_FACILITY_ATTR_DEF + ":unixGID-namespace"); dependencies.add(AttributesManager.NS_FACILITY_ATTR_DEF + ":unixGroupName-namespace"); //Disallowed of crosschecks modules peformance reason //dependencies.add(A_G_unixGID_namespace + ":*"); //dependencies.add(A_R_unixGID_namespace + ":*"); //dependencies.add(A_G_unixGroupName_namespace + ":*");</technical_language>

Target:
public List<String> getDependencies() { List<String> dependencies = new ArrayList<String>(); dependencies.add(AttributesManager.NS_FACILITY_ATTR_DEF + ":unixGID-namespace"); dependencies.add(AttributesManager.NS_FACILITY_ATTR_DEF + ":unixGroupName-namespace"); return dependencies; }
Source:
<code>JSONArray getPlatformPluginUpdates() { try { return getPlatformPluginsForUpdate(getCurrentLevel(), Jenkins.getVersion()); } catch (IOException e) { <START> throw new RuntimeException(e); <END> } }</code><technical_language>wdyt IllegalState + descriptive msg</technical_language>

Target:
JSONArray getPlatformPluginUpdates() { final VersionNumber version = getCurrentLevel(); if (version == null) { return null; } return getPlatformPluginsForUpdate(version, Jenkins.getVersion()); }
Source:
<code>public boolean isMain() { <START> return main; <END> }</code><technical_language>get rid of field replace implementation test condition</technical_language>

Target:
public boolean isMain() { return name.equals("main") && getArity() == 1; }
Source:
<code>public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) { if (!rawType.isEnum()) { return null; } final Class<Enum<?>> type = (Class<Enum<?>>) rawType; final Enum<?>[] constants = type.getEnumConstants(); final String parameterName = getParameterNameFromAnnotations(annotations).orElse("Parameter"); return new ParamConverter<T>() { @Override public T fromString(String value) { if (Strings.isNullOrEmpty(value)) { return null; } Enum<?> constant = Enums.fromStringFuzzy(value, constants); if (constant != null) { return (T) constant; } <START> throw new WebApplicationException(getErrorResponse(String.format("%s must be one of [%s]", parameterName, Joiner.on(", ").join(constants)))); <END> } @Override public String toString(T value) { return value.toString(); } protected Response getErrorResponse(String message) { return Response .status(400) .entity(new ErrorMessage(400, message)) .type(MediaType.APPLICATION_JSON_TYPE) .build(); } }; }</code><technical_language>This line's pretty long. break move Joiner a static field: final String errorMsg = String.format( "%s of [%s]", parameterName, joiner.join(constants)); throw new WebApplicationException(getErrorResponse(errorMsg));</technical_language>

Target:
public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) { if (!rawType.isEnum()) { return null; } final Class<Enum<?>> type = (Class<Enum<?>>) rawType; final Enum<?>[] constants = type.getEnumConstants(); final String parameterName = getParameterNameFromAnnotations(annotations).orElse("Parameter"); return new ParamConverter<T>() { @Override public T fromString(String value) { if (Strings.isNullOrEmpty(value)) { return null; } final Enum<?> constant = Enums.fromStringFuzzy(value, constants); if (constant != null) { return (T) constant; } final String errMsg = String.format("%s must be one of [%s]", parameterName, JOINER.join(constants)); throw new WebApplicationException(getErrorResponse(errMsg)); } @Override public String toString(T value) { return value.toString(); } protected Response getErrorResponse(String message) { return Response .status(400) .entity(new ErrorMessage(400, message)) .type(MediaType.APPLICATION_JSON_TYPE) .build(); } }; }
Source:
<code>public void pre(Span span, Exchange exchange, Endpoint endpoint) { span.setTag(Tags.COMPONENT.getKey(), CAMEL_COMPONENT + URI.create(endpoint.getEndpointUri()).getScheme()); <START> span.setTag("camel.uri", endpoint.getEndpointUri()); <END> }</code><technical_language>I if mask sensitive information passwords, Camel do org.apache.camel.util.URISupport#sanitizeUri default in toString</technical_language>

Target:
public void pre(Span span, Exchange exchange, Endpoint endpoint) { span.setTag(Tags.COMPONENT.getKey(), CAMEL_COMPONENT + URI.create(endpoint.getEndpointUri()).getScheme()); span.setTag("camel.uri", URISupport.sanitizeUri(endpoint.getEndpointUri())); }
Source:
<code>void enablePreview() { mPreview = new Preview.Builder() .setTargetName("Preview") .build(); Log.d(TAG, "enablePreview"); mPreview.setPreviewSurfaceProvider( (resolution, surfaceReleaseFuture) -> { mResolution = resolution; mSurfaceReleaseFuture = surfaceReleaseFuture; return CallbackToFutureAdapter.getFuture( completer -> { completer.addCancellationListener(() -> { Preconditions.checkState(mSurfaceCompleter == completer); mSurfaceCompleter = null; mSurfaceReleaseFuture = null; }, ContextCompat.getMainExecutor(mTextureView.getContext())); mSurfaceCompleter = completer; tryToProvidePreviewSurface(); return "provide preview surface"; }); }); <START> mPreviewFrameCount.set(0); mViewIdlingResource.increment(); <END> if (bindToLifecycleSafely(mPreview, R.id.PreviewToggle) == null) { mPreview = null; return; } }</code><technical_language>call resetViewIdlingResource()</technical_language>

Target:
void enablePreview() { mPreview = new Preview.Builder() .setTargetName("Preview") .build(); Log.d(TAG, "enablePreview"); mPreview.setPreviewSurfaceProvider( (resolution, surfaceReleaseFuture) -> { mResolution = resolution; mSurfaceReleaseFuture = surfaceReleaseFuture; return CallbackToFutureAdapter.getFuture( completer -> { completer.addCancellationListener(() -> { Preconditions.checkState(mSurfaceCompleter == completer); mSurfaceCompleter = null; mSurfaceReleaseFuture = null; }, ContextCompat.getMainExecutor(mTextureView.getContext())); mSurfaceCompleter = completer; tryToProvidePreviewSurface(); return "provide preview surface"; }); }); resetViewIdlingResource(); if (bindToLifecycleSafely(mPreview, R.id.PreviewToggle) == null) { mPreview = null; return; } }
Source:
<code>protected SSLContext getSslContext(ElasticSearchClientConfig config) { checkDeprecatedProperties(); String trustStorePath = StringUtils.defaultIfBlank(config.getOption(TRUST_STORE_PATH_OPT), config.getOption(DEPRECATED_TRUST_STORE_PATH_OPT)); String trustStorePassword = StringUtils.defaultIfBlank(config.getOption(TRUST_STORE_PASSWORD_OPT), config.getOption(DEPRECATED_TRUST_STORE_PASSWORD_OPT)); String trustStoreType = StringUtils.defaultIfBlank(config.getOption(TRUST_STORE_TYPE_OPT), config.getOption(DEPRECATED_TRUST_STORE_TYPE_OPT)); String keyStorePath = config.getOption(KEY_STORE_PATH_OPT); String keyStorePassword = config.getOption(KEY_STORE_PASSWORD_OPT); String keyStoreType = config.getOption(KEY_STORE_TYPE_OPT); try { KeyStore trustStore = loadKeyStore(trustStorePath, trustStorePassword, trustStoreType); KeyStore keyStore = loadKeyStore(keyStorePath, keyStorePassword, keyStoreType); if (trustStore == null && keyStore == null) { return null; } SSLContextBuilder sslContextBuilder = SSLContexts.custom(); if (trustStore != null) { sslContextBuilder.loadTrustMaterial(trustStore, null); } if (keyStore != null) { <START> sslContextBuilder.loadKeyMaterial(keyStore, keyStorePassword.toCharArray()); <END> } return sslContextBuilder.build(); } catch (GeneralSecurityException | IOException e) { throw new NuxeoException("Cannot setup SSL for RestClient: " + config, e); } }</code><technical_language>Please do #3333 safe: sslContextBuilder.loadKeyMaterial(keyStore, StringUtils.isBlank(keyStorePassword) ? null : keyStorePassword.toCharArray());</technical_language>

Target:
protected SSLContext getSslContext(ElasticSearchClientConfig config) { checkDeprecatedProperties(); String trustStorePath = StringUtils.defaultIfBlank(config.getOption(TRUST_STORE_PATH_OPT), config.getOption(DEPRECATED_TRUST_STORE_PATH_OPT)); String trustStorePassword = StringUtils.defaultIfBlank(config.getOption(TRUST_STORE_PASSWORD_OPT), config.getOption(DEPRECATED_TRUST_STORE_PASSWORD_OPT)); String trustStoreType = StringUtils.defaultIfBlank(config.getOption(TRUST_STORE_TYPE_OPT), config.getOption(DEPRECATED_TRUST_STORE_TYPE_OPT)); String keyStorePath = config.getOption(KEY_STORE_PATH_OPT); String keyStorePassword = config.getOption(KEY_STORE_PASSWORD_OPT); String keyStoreType = config.getOption(KEY_STORE_TYPE_OPT); try { KeyStore trustStore = loadKeyStore(trustStorePath, trustStorePassword, trustStoreType); KeyStore keyStore = loadKeyStore(keyStorePath, keyStorePassword, keyStoreType); if (trustStore == null && keyStore == null) { return null; } SSLContextBuilder sslContextBuilder = SSLContexts.custom(); if (trustStore != null) { sslContextBuilder.loadTrustMaterial(trustStore, null); } if (keyStore != null) { sslContextBuilder.loadKeyMaterial(keyStore, StringUtils.isBlank(keyStorePassword) ? null : keyStorePassword.toCharArray()); } return sslContextBuilder.build(); } catch (GeneralSecurityException | IOException e) { throw new NuxeoException("Cannot setup SSL for RestClient: " + config, e); } }
Source:
<code>public void testAccessDenied() throws Exception { MockWebServer server = mockWebServer(); server.enqueue(new MockResponse().setBody(payloadFromResource("/access-denied.json"))); DigitalOceanApi api = api(server.getUrl("/")); ImageApi imageApi = api.getImageApi(); try { imageApi.list(); fail("Request should have failed"); } catch (Exception ex) { assertTrue(ex instanceof AuthorizationException, "Exception should be an AuthorizationException"); <START> assertEquals(ex.getMessage(), "Access Denied"); <END> } finally { api.close(); server.shutdown(); } }</code><technical_language>"Access Denied" a constant in ResponseStatusFromPayloadHttpCommandExecutorService</technical_language>

Target:
public void testAccessDenied() throws Exception { MockWebServer server = mockWebServer(); server.enqueue(new MockResponse().setBody(payloadFromResource("/access-denied.json"))); DigitalOceanApi api = api(server.getUrl("/")); ImageApi imageApi = api.getImageApi(); try { imageApi.list(); fail("Request should have failed"); } catch (Exception ex) { assertTrue(ex instanceof AuthorizationException, "Exception should be an AuthorizationException"); assertEquals(ex.getMessage(), ACCESS_DENIED); } finally { api.close(); server.shutdown(); } }
Source:
<code>public static void stopSenderInVMsAsync(String senderId, VM... vms) { <START> List<AsyncInvocation> tasks = new LinkedList<>(); for (VM vm : vms) { tasks.add(vm.invokeAsync(() -> stopSender(senderId))); } for (AsyncInvocation invocation : tasks) { <END> try { invocation.await(); } catch (InterruptedException e) { fail("Stopping senders was interrupted"); } } }</code><technical_language>IDE warnings resolved List<AsyncInvocation<Void>></technical_language>

Target:
public static void stopSenderInVMsAsync(String senderId, VM... vms) { List<AsyncInvocation<Void>> tasks = new LinkedList<>(); for (VM vm : vms) { tasks.add(vm.invokeAsync(() -> stopSender(senderId))); } for (AsyncInvocation invocation : tasks) { try { invocation.await(); } catch (InterruptedException e) { fail("Stopping senders was interrupted"); } } }
Source:
<code>private void processRequest(final ChannelHandlerContext ctx, final TNiftyTransport messageTransport) { final int responseSequenceId = dispatcherSequenceId.incrementAndGet(); if ((responseSequenceId > lastResponseWrittenId.get() + queuedResponseLimit) && ((Boolean) ctx.getAttachment() != Boolean.TRUE)) { ctx.setAttachment(Boolean.TRUE); ctx.getChannel().setReadable(false); } else if ((Boolean) ctx.getAttachment() == Boolean.TRUE) { ctx.setAttachment(Boolean.FALSE); ctx.getChannel().setReadable(true); } exe.execute(new Runnable() { @Override public void run() { TProtocol inProtocol = inProtocolFactory.getProtocol(messageTransport); TProtocol outProtocol = outProtocolFactory.getProtocol(messageTransport); try { processorFactory.getProcessor(messageTransport).process( inProtocol, outProtocol ); synchronized (responseMap) { ChannelBuffer response = messageTransport.getOutputBuffer(); int currentResponseId = lastResponseWrittenId.get() + 1; if (responseSequenceId != currentResponseId) { responseMap.put(responseSequenceId, response); } else { writeResponse(ctx, response, messageTransport.getTransportType()); } } } catch (TException e1) { log.error("Exception while invoking!", e1); closeChannel(ctx); } } private void writeResponse(final ChannelHandlerContext ctx, final ChannelBuffer outputBuffer, final ThriftTransportType transportType) { <START> synchronized (responseMap) { <END> ChannelBuffer response = outputBuffer; int currentResponseId = lastResponseWrittenId.get() + 1; if (responseSequenceId != currentResponseId) { responseMap.put(responseSequenceId, response); } else { do { response = addFraming(response, transportType); Channels.write(ctx.getChannel(), response); lastResponseWrittenId.incrementAndGet(); ++currentResponseId; response = responseMap.remove(currentResponseId); } while (null != response); } } } }); }</code><technical_language>entering this method acquired a lock responseMap. is required again? Also, line 150-156 repeated</technical_language>

Target:
private void processRequest(final ChannelHandlerContext ctx, final TNiftyTransport messageTransport) { final int requestSequenceId = dispatcherSequenceId.incrementAndGet(); synchronized (responseMap) { if ((requestSequenceId > lastResponseWrittenId.get() + queuedResponseLimit) && !isChannelReadBlocked(ctx)) { blockChannelReads(ctx); } } exe.execute(new Runnable() { @Override public void run() { TProtocol inProtocol = inProtocolFactory.getProtocol(messageTransport); TProtocol outProtocol = outProtocolFactory.getProtocol(messageTransport); try { processorFactory.getProcessor(messageTransport).process( inProtocol, outProtocol ); writeResponse(ctx, messageTransport, requestSequenceId); } catch (TException e1) { log.error("Exception while invoking!", e1); closeChannel(ctx); } } }); }