auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected boolean canDoAction() { boolean returnValue = true; StorageServerConnections paramConnection = getConnection(); if (paramConnection.getstorage_type() == StorageType.NFS && !new NfsMountPointConstraint().isValid(paramConnection.getconnection(), null)) { returnValue = false; addCanDoActionMessage(VdcBllMessages.VALIDATION_STORAGE_CONNECTION_INVALID); } if (paramConnection.getstorage_type() == StorageType.POSIXFS && (StringUtils.isEmpty(paramConnection.getVfsType()))) { return failCanDoAction(VdcBllMessages.VALIDATION_STORAGE_CONNECTION_EMPTY_VFSTYPE); } if(isConnWithSameDetailsExists()) { <START> return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS); <END> } if (getParameters().getVdsId().equals(Guid.Empty)) { returnValue = InitializeVds(); } else if (getVds() == null) { addCanDoActionMessage(VdcBllMessages.VDS_INVALID_SERVER_ID); returnValue = false; } else if (getVds().getStatus() != VDSStatus.Up) { addCanDoActionMessage(VdcBllMessages.VDS_ADD_STORAGE_SERVER_STATUS_MUST_BE_UP); returnValue = false; } return returnValue; }</code><technical_language>if this is a gerrit foobar, indentation fishy here</technical_language>

Target:
protected boolean canDoAction() { boolean returnValue = true; StorageServerConnections paramConnection = getConnection(); if (StringUtils.isNotEmpty(paramConnection.getid())) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_NOT_EMPTY); } if (paramConnection.getstorage_type() == StorageType.NFS && !new NfsMountPointConstraint().isValid(paramConnection.getconnection(), null)) { returnValue = false; addCanDoActionMessage(VdcBllMessages.VALIDATION_STORAGE_CONNECTION_INVALID); } if (paramConnection.getstorage_type() == StorageType.POSIXFS && (StringUtils.isEmpty(paramConnection.getVfsType()))) { return failCanDoAction(VdcBllMessages.VALIDATION_STORAGE_CONNECTION_EMPTY_VFSTYPE); } if (isConnWithSameDetailsExists()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS); } if (getParameters().getVdsId().equals(Guid.Empty)) { returnValue = InitializeVds(); } else if (getVds() == null) { addCanDoActionMessage(VdcBllMessages.VDS_INVALID_SERVER_ID); returnValue = false; } else if (getVds().getStatus() != VDSStatus.Up) { addCanDoActionMessage(VdcBllMessages.VDS_ADD_STORAGE_SERVER_STATUS_MUST_BE_UP); returnValue = false; } return returnValue; }
Source:
<code><START> private SerialNumberObject convert(ResultSet result) throws SQLException { <END> SerialNumberObject serialNumber = new SerialNumberObject(); serialNumber .setId(result.getLong(SerialNumberEnum.ID)) .setProjectId(result.getLong(SerialNumberEnum.PROJECT_ID)) .setReleaseId(result.getLong(SerialNumberEnum.RELEASE)) .setSprintId(result.getLong(SerialNumberEnum.SPRINT)) .setStoryId(result.getLong(SerialNumberEnum.STORY)) .setTaskId(result.getLong(SerialNumberEnum.TASK)) .setUnplannedId(result.getLong(SerialNumberEnum.UNPLANNED)) .setRetrospectiveId( result.getLong(SerialNumberEnum.RETROSPECTIVE)); ; return serialNumber; }</code><technical_language>open</technical_language>

Target:
private SerialNumberObject convert(ResultSet result) throws SQLException { SerialNumberObject serialNumber = new SerialNumberObject(); serialNumber .setId(result.getLong(SerialNumberEnum.ID)) .setProjectId(result.getLong(SerialNumberEnum.PROJECT_ID)) .setReleaseId(result.getLong(SerialNumberEnum.RELEASE)) .setSprintId(result.getLong(SerialNumberEnum.SPRINT)) .setStoryId(result.getLong(SerialNumberEnum.STORY)) .setTaskId(result.getLong(SerialNumberEnum.TASK)) .setUnplannedId(result.getLong(SerialNumberEnum.UNPLANNED)) .setRetrospectiveId( result.getLong(SerialNumberEnum.RETROSPECTIVE)); return serialNumber; }
Source:
<code>public synchronized void clear() { for (int i = 0; i < this.fPageTable.length; i++) { <START> final Chunk <END> chunk = this.fPageTable[i]; if (chunk == null) { continue; } chunk.fCacheIndex = -1; chunk.fDatabase.checkIfChunkReleased(chunk); this.fPageTable[i] = null; } this.fTableIsFull = false; this.fPointer = 0; }</code><technical_language>reasoning for making this final</technical_language>

Target:
public synchronized void clear() { for (int i = 0; i < this.fPageTable.length; i++) { Chunk chunk = this.fPageTable[i]; if (chunk == null) { continue; } chunk.fCacheIndex = -1; chunk.fDatabase.checkIfChunkReleased(chunk); this.fPageTable[i] = null; } this.fTableIsFull = false; this.fPointer = 0; }
Source:
<code>protected String getClassName(EntityType model) { Type type = conf.getTypeMappings().getPathType(model, model, true); String packageName = type.getPackageName(); <START> return !packageName.isEmpty() ? (packageName + "." + type.getSimpleName()) : type.getSimpleName(); <END> }</code><technical_language>negated? flip branches</technical_language>

Target:
protected String getClassName(EntityType model) { Type type = conf.getTypeMappings().getPathType(model, model, true); String packageName = type.getPackageName(); return packageName.isEmpty() ? type.getSimpleName() : (packageName + "." + type.getSimpleName()); }
Source:
<code>protected org.eclipse.jetty.webapp.Configuration[] getWebAppContextConfigurations(WebAppContext webAppContext, ServletContextInitializer... initializers) { webAppContextCustomizers.ifPresent(consumers -> consumers.forEach(c -> c.accept(webAppContext))); <START> webAppContext.setErrorHandler(new ConservedHeadersJettyErrorHandler(webAppContext.getErrorHandler())); <END> return super.getWebAppContextConfigurations(webAppContext, initializers); }</code><technical_language>@mikebell90 voiced a concern this is blindly replacing existing error handler, delegating it. if else is utilizing default handler</technical_language>

Target:
protected org.eclipse.jetty.webapp.Configuration[] getWebAppContextConfigurations(WebAppContext webAppContext, ServletContextInitializer... initializers) { webAppContextCustomizers.ifPresent(consumers -> consumers.forEach(c -> c.accept(webAppContext))); webAppContext.setErrorHandler(new ConservedHeadersJettyErrorHandler(webAppContext.getErrorHandler(), showStacks)); return super.getWebAppContextConfigurations(webAppContext, initializers); }
Source:
<code>public int compareTo(DfsPackDescription b) { PackSource as = getPackSource(); PackSource bs = b.getPackSource(); if (as != null && bs != null) { int cmp = as.category - bs.category; if (cmp != 0) return cmp; } if (as != null && <START> as.equals(bs) <END> && isGC(as)) { int cmp = Long.signum(getFileSize(PACK) - b.getFileSize(PACK)); if (cmp != 0) { return cmp; } } int cmp = Long.signum(b.getLastModified() - getLastModified()); if (cmp != 0) return cmp; return Long.signum(getObjectCount() - b.getObjectCount()); }</code><technical_language>== instead for enum</technical_language>

Target:
public int compareTo(DfsPackDescription b) { PackSource as = getPackSource(); PackSource bs = b.getPackSource(); if (as != null && bs != null) { int cmp = as.category - bs.category; if (cmp != 0) return cmp; } if (as != null && as == bs && isGC(as)) { int cmp = Long.signum(getFileSize(PACK) - b.getFileSize(PACK)); if (cmp != 0) { return cmp; } } int cmp = Long.signum(b.getLastModified() - getLastModified()); if (cmp != 0) return cmp; return Long.signum(getObjectCount() - b.getObjectCount()); }
Source:
<code>public void setUp() { injector = Guice.createInjector(new UnitTestModule()); mockRobotIO = injector.getInstance(MockRobotIO.class); HLUsageReporting.SetImplementation(new MockHLUsageReporting()); Timer.SetImplementation(injector.getInstance(MockTimer.class)); this.mockRobotState = injector.getInstance(MockRobotState.class); RobotState.SetImplementation(mockRobotState); propertyManager = injector.getInstance(PropertyManager.class); SafeRobotAssertionManager assertionMan = injector.getInstance(SafeRobotAssertionManager.class); <START> assertionMan.setExceptionsEnabled(true); <END> DOMConfigurator.configure("lib/log4jConfig/log4j4unitTesting.xml"); }</code><technical_language>cleaner this set part of UnitTestModule() guice level people need remember do this themselves</technical_language>

Target:
public void setUp() { injector = Guice.createInjector(new UnitTestModule()); mockRobotIO = injector.getInstance(MockRobotIO.class); HLUsageReporting.SetImplementation(new MockHLUsageReporting()); Timer.SetImplementation(injector.getInstance(MockTimer.class)); this.mockRobotState = injector.getInstance(MockRobotState.class); RobotState.SetImplementation(mockRobotState); propertyManager = injector.getInstance(PropertyManager.class); DOMConfigurator.configure("lib/log4jConfig/log4j4unitTesting.xml"); }
Source:
<code>public void moveSelectedPathToRootPath() { fVariablesTreeContentProvider.addPath(new Path(ID_GROUP1)); fVariablesTreeContentProvider.addPath(new Path(ID_GROUP1_SUBGROUP1)); fVariablesTreeContentProvider.moveSelectedPath(new Path("/subgroup1"), new Path("/group1/subgroup1")); fVariablesTreeContentProvider.getElements(new HashSet<IPath>()); final Object[] actualAdditionalPathRoot = fVariablesTreeContentProvider.getChildren(new Path("")); assertEquals(2, actualAdditionalPathRoot.length); assertEquals(new Path("group1"), actualAdditionalPathRoot[0]); assertEquals(new Path("subgroup1"), actualAdditionalPathRoot[1]); <START> assertTrue(!fVariablesTreeContentProvider.hasChildren(new Path(ID_GROUP1).makeRelative())); <END> }</code><technical_language>here, pleas assertFalse</technical_language>

Target:
public void moveSelectedPathToRootPath() { fVariablesTreeContentProvider.addPath(new Path(ID_GROUP1)); fVariablesTreeContentProvider.addPath(new Path(ID_GROUP1_SUBGROUP1)); fVariablesTreeContentProvider.moveSelectedPath(new Path("/subgroup1"), new Path("/group1/subgroup1")); fVariablesTreeContentProvider.getElements(new HashSet<IPath>()); final Object[] actualAdditionalPathRoot = fVariablesTreeContentProvider.getChildren(new Path("")); assertEquals(2, actualAdditionalPathRoot.length); assertEquals(new Path("group1"), actualAdditionalPathRoot[0]); assertEquals(new Path("subgroup1"), actualAdditionalPathRoot[1]); assertFalse(fVariablesTreeContentProvider.hasChildren(new Path(ID_GROUP1).makeRelative())); }
Source:
<code>protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception { final int length = in.readableBytes(); final int idx = in.readerIndex(); final byte[] input; final int inputPtr; if (in.hasArray()) { input = in.array(); inputPtr = in.arrayOffset() + idx; } else { input = recycler.allocInputBuffer(length); in.getBytes(idx, input, 0, length); inputPtr = 0; } final int maxOutputLength = LZFEncoder.estimateMaxWorkspaceSize(length); out.ensureWritable(maxOutputLength); final byte[] output = out.array(); final int outputPtr = out.arrayOffset() + out.writerIndex(); <START> int outputLength; <END> if (length >= compressThreshold) { outputLength = encodeCompress(input, inputPtr, length, output, outputPtr); } else { outputLength = encodeNonCompress(input, inputPtr, length, output, outputPtr); } out.writerIndex(out.writerIndex() + outputLength); in.skipBytes(length); if (!in.hasArray()) { recycler.releaseInputBuffer(input); } }</code><technical_language>nit: this final</technical_language>

Target:
protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception { final int length = in.readableBytes(); final int idx = in.readerIndex(); final byte[] input; final int inputPtr; if (in.hasArray()) { input = in.array(); inputPtr = in.arrayOffset() + idx; } else { input = recycler.allocInputBuffer(length); in.getBytes(idx, input, 0, length); inputPtr = 0; } final int maxOutputLength = LZFEncoder.estimateMaxWorkspaceSize(length); out.ensureWritable(maxOutputLength); final byte[] output = out.array(); final int outputPtr = out.arrayOffset() + out.writerIndex(); final int outputLength; if (length >= compressThreshold) { outputLength = encodeCompress(input, inputPtr, length, output, outputPtr); } else { outputLength = encodeNonCompress(input, inputPtr, length, output, outputPtr); } out.writerIndex(out.writerIndex() + outputLength); in.skipBytes(length); if (!in.hasArray()) { recycler.releaseInputBuffer(input); } }
Source:
<code><START> void setUniverseWrapper(UniverseWrapper wrapper) { <END> this.universeWrapper = wrapper; }</code><technical_language>another access modification need (probably for isLoadingAsServer() ?)</technical_language>

Target:
public void setUniverseWrapper(UniverseWrapper wrapper) { this.universeWrapper = wrapper; }
Source:
<code>private void addPublishCache(String tenantId, String triggerId, Set<String> dataIds) { if (!isEmpty(dataIds)) { dataIds.stream().forEach(dataId -> { CacheKey cacheKey = new CacheKey(tenantId, dataId); Set<String> triggers = publishCache.get(cacheKey); Set<String> newTriggers = triggers == null ? new HashSet<>() : new HashSet<>(triggers); newTriggers.add(triggerId); <START> publishCache.put(cacheKey, newTriggers); <END> }); } }</code><technical_language>wrap existing Set in a new HashSet? Is necessary do put if existed a Set already? Set reference is unchanged, Set contents changed. is required ispn for distribution purposes</technical_language>

Target:
private void addPublishCache(String tenantId, String triggerId, Set<String> dataIds) { if (!isEmpty(dataIds)) { dataIds.stream().forEach(dataId -> { CacheKey cacheKey = new CacheKey(tenantId, dataId); Set<String> triggerIds = publishCache.get(cacheKey); if (triggerIds == null) { triggerIds = new HashSet<>(); } triggerIds.add(triggerId); publishCache.put(cacheKey, triggerIds); }); } }
Source:
<code>public final void cancel() { logger.info("Cancelling task " + taskId); if (participant != null) { participant.unregisterRunningTask(this); <START> } <END> onCancel(); }</code><technical_language>Print a warn log if participant is null</technical_language>

Target:
public final void cancel() { try { logger.info("Cancelling task " + taskId); onCancel(); } finally { if (participant != null) { participant.unregisterRunningTask(this); } else { logger.warn("Task with id: " + taskId + " is not unregistered since the participant is not set"); } } }
Source:
<code>public IModel loadModel(ResourceLocation modelLocation) throws IOException { ResourceLocation file = new ResourceLocation(modelLocation.getResourceDomain(), modelLocation.getResourcePath()); if (!cache.containsKey(file)) { try { IResource resource = null; try { resource = manager.getResource(file); } catch (FileNotFoundException e) { if (modelLocation.getResourcePath().startsWith("models/block/")) resource = manager.getResource(new ResourceLocation(file.getResourceDomain(), "models/item/" + file.getResourcePath().substring("models/block/".length()))); else if (modelLocation.getResourcePath().startsWith("models/item/")) resource = manager.getResource(new ResourceLocation(file.getResourceDomain(), "models/block/" + file.getResourcePath().substring("models/item/".length()))); else throw e; } OBJModel.Parser parser = new OBJModel.Parser(resource, manager); OBJModel model = null; try { model = parser.parse(); } <START> catch (OBJModel.UVsOutOfBoundsException e) <END> { throw e; } finally { cache.put(modelLocation, model); } } catch (IOException e) { throw e; } } OBJModel model = cache.get(file); if (model == null) return ModelLoaderRegistry.getMissingModel(); return model; }</code><technical_language>This catch block is completely unnecessary, omit leave finally block</technical_language>

Target:
public IModel loadModel(ResourceLocation modelLocation) throws IOException { ResourceLocation file = new ResourceLocation(modelLocation.getResourceDomain(), modelLocation.getResourcePath()); if (!cache.containsKey(file)) { try { IResource resource = null; try { resource = manager.getResource(file); } catch (FileNotFoundException e) { if (modelLocation.getResourcePath().startsWith("models/block/")) resource = manager.getResource(new ResourceLocation(file.getResourceDomain(), "models/item/" + file.getResourcePath().substring("models/block/".length()))); else if (modelLocation.getResourcePath().startsWith("models/item/")) resource = manager.getResource(new ResourceLocation(file.getResourceDomain(), "models/block/" + file.getResourcePath().substring("models/item/".length()))); else throw e; } OBJModel.Parser parser = new OBJModel.Parser(resource, manager); OBJModel model = null; try { model = parser.parse(); } finally { cache.put(modelLocation, model); } } catch (IOException e) { throw e; } } OBJModel model = cache.get(file); if (model == null) return ModelLoaderRegistry.getMissingModel(); return model; }
Source:
<code>@NonNull @Override public CardType type() { return <START> CardType.ONBOARDING_CUSTOMIZE_FEED; <END> }</code><technical_language>This return is incorrect. Please create a new card type represent this card</technical_language>

Target:
@NonNull @Override public CardType type() { return CardType.ONBOARDING_READING_LIST_SYNC; }
Source:
<code>public int doStartTag() throws JspException { try { JspWriter out = pageContext.getOut(); PageParameters pageParameters = new PageParameters(); if (query != null) { RequestUtils.decodeParameters(query, pageParameters); } CharSequence urlFor = RequestCycle.get().urlFor( <START> (Class<? extends WebPage>) Class.forName(page), <END> pageParameters); out.write(urlFor.toString()); out.flush(); } catch (IOException e) { LOGGER.error("Error while generating url for page " + page, e); } catch (ClassNotFoundException e) { LOGGER.error( "Error while receiving the class with the name" + page, e); } return SKIP_BODY; }</code><technical_language>WicketObjects.resolveClass() here. configured IClassResolver (for OSGi other more complicated class loadings)</technical_language>

Target:
public int doStartTag() throws JspException { try { JspWriter out = pageContext.getOut(); PageParameters pageParameters = new PageParameters(); if (query != null) { RequestUtils.decodeParameters(query, pageParameters); } Class<Page> resolveClass = WicketObjects.resolveClass(page); CharSequence urlFor = RequestCycle.get().urlFor( resolveClass, pageParameters); out.write(urlFor.toString()); out.flush(); } catch (IOException e) { LOGGER.error("Error while generating url for page " + page, e); throw new JspException("Error while generating url for page ",e); } return SKIP_BODY; }
Source:
<code>public String toString() { StringBuilder sb = new StringBuilder(); <START> sb.append("TmfLocationArray ["); <END> for (int i = 0; i < fLocations.length; i++) { if (i > 0) { sb.append(", "); } sb.append("[" + fLocations[i] + "," + fRanks[i] + "]"); } sb.append("]"); return sb.toString(); }</code><technical_language>getClass().getSimpleName()</technical_language>

Target:
public String toString() { StringBuilder sb = new StringBuilder(); sb.append(getClass().getSimpleName() + " ["); for (int i = 0; i < fLocations.length; i++) { if (i > 0) { sb.append(", "); } sb.append("[location=" + fLocations[i] + ",rank=" + fRanks[i] + "]"); } sb.append("]"); return sb.toString(); }
Source:
<code>public Map<Timestamp, Set<Object>> chronologize(final String key, final long record) { Map<Timestamp, Set<Object>> result = TLinkedHashMap.newTLinkedHashMap( <START> "DateTime", "Value"); <END> for (Timestamp timestamp : audit(key, record).keySet()) { Set<Object> values = fetch(key, record, timestamp); if (!values.isEmpty()) { result.put(timestamp, values); } } return result; }</code><technical_language>Change "Value" "Values" a set</technical_language>

Target:
public Map<Timestamp, Set<Object>> chronologize(final String key, final long record) { return execute(new Callable<Map<Timestamp, Set<Object>>>() { @Override public Map<Timestamp, Set<Object>> call() throws Exception { Map<Long, Set<TObject>> chronologie = client.chronologize(record, key, creds, transaction); Map<Timestamp, Set<Object>> result = TLinkedHashMap. newTLinkedHashMap("DateTime", "Values"); for (Entry<Long, Set<TObject>> entry : chronologie.entrySet()) { result.put(Timestamp.fromMicros(entry.getKey()), Transformers.transformSet(entry.getValue(), new Function<TObject, Object>() { @Override public Object apply(TObject input) { return Convert.thriftToJava(input); } })); } return result; } }); }
Source:
<code>private void addPresentation(TextPresentation presentation) { StyleRange range = presentation.getDefaultStyleRange(); if (range != null) { range = modelStyleRange2WidgetStyleRange(range); if (range != null) { updateStyle(range); fMinimapTextWidget.setStyleRange(range); } List<StyleRange> ranges = new ArrayList<>(presentation.getDenumerableRanges()); Iterator<StyleRange> e = presentation.getNonDefaultStyleRangeIterator(); while (e.hasNext()) { range = e.next(); range = modelStyleRange2WidgetStyleRange(range); if (range != null) { updateStyle(range); ranges.add(range); } } <START> if (!ranges.isEmpty()) <END> fMinimapTextWidget.replaceStyleRanges(0, 0, ranges.toArray(new StyleRange[ranges.size()])); } else { IRegion region = modelRange2WidgetRange(presentation.getCoverage()); if (region == null) return; List<StyleRange> list = new ArrayList<>(presentation.getDenumerableRanges()); Iterator<StyleRange> e = presentation.getAllStyleRangeIterator(); while (e.hasNext()) { range = e.next(); range = modelStyleRange2WidgetStyleRange(range); if (range != null) { updateStyle(range); list.add(range); } } if (!list.isEmpty()) { StyleRange[] ranges = new StyleRange[list.size()]; list.toArray(ranges); fMinimapTextWidget.replaceStyleRanges(region.getOffset(), region.getLength(), ranges); } } }</code><technical_language>For new code braces for single statements</technical_language>

Target:
private void addPresentation(TextPresentation presentation) { StyleRange range = presentation.getDefaultStyleRange(); if (range != null) { range = modelStyleRange2WidgetStyleRange(range); if (range != null) { updateStyle(range); fMinimapTextWidget.setStyleRange(range); } List<StyleRange> ranges = new ArrayList<>(presentation.getDenumerableRanges()); Iterator<StyleRange> e = presentation.getNonDefaultStyleRangeIterator(); while (e.hasNext()) { range = e.next(); range = modelStyleRange2WidgetStyleRange(range); if (range != null) { updateStyle(range); ranges.add(range); } } if (!ranges.isEmpty()) { fMinimapTextWidget.replaceStyleRanges(0, 0, ranges.toArray(new StyleRange[ranges.size()])); } } else { IRegion region = modelRange2WidgetRange(presentation.getCoverage()); if (region == null) return; List<StyleRange> list = new ArrayList<>(presentation.getDenumerableRanges()); Iterator<StyleRange> e = presentation.getAllStyleRangeIterator(); while (e.hasNext()) { range = e.next(); range = modelStyleRange2WidgetStyleRange(range); if (range != null) { updateStyle(range); list.add(range); } } if (!list.isEmpty()) { StyleRange[] ranges = new StyleRange[list.size()]; list.toArray(ranges); fMinimapTextWidget.replaceStyleRanges(region.getOffset(), region.getLength(), ranges); } } }
Source:
<code>public FF4j getFF4j() { try { FF4j ff4j = new FF4j(); JdbcFeatureStore featureStore = new JdbcFeatureStore(ff4jDataSource()); <START> featureStore.setQueryBuilder(new JdbcQueryBuilder(TABLE_PREFIX, "", BaseDAOImpl.SCHEMA_NAME)); <END> ff4j.setFeatureStore(featureStore); JdbcPropertyStore propertyStore = new JdbcPropertyStore(ff4jDataSource()); propertyStore.setQueryBuilder(new JdbcQueryBuilder(TABLE_PREFIX, "", BaseDAOImpl.SCHEMA_NAME)); ff4j.setPropertiesStore(propertyStore); JdbcEventRepository eventRepository = new JdbcEventRepository(ff4jDataSource()); eventRepository.setQueryBuilder(new JdbcQueryBuilder(TABLE_PREFIX, "", BaseDAOImpl.SCHEMA_NAME)); ff4j.setEventRepository(new JdbcEventRepository(ff4jDataSource())); FF4JCacheManager ff4jCache = new FeatureCacheProviderEhCache(); ff4j.cache(ff4jCache); return ff4j; } catch (NamingException | SQLException e) { return null; } }</code><technical_language>this add a ton of tables? wondering if tables in schema (like quartz is) mixed in of chpl/listing data</technical_language>

Target:
public FF4j getFF4j() { try { FF4j ff4j = new FF4j(); JdbcFeatureStore featureStore = new JdbcFeatureStore(ff4jDataSource()); featureStore.setQueryBuilder(new JdbcQueryBuilder(TABLE_PREFIX, "", FF4J_SCHEMA)); ff4j.setFeatureStore(featureStore); JdbcPropertyStore propertyStore = new JdbcPropertyStore(ff4jDataSource()); propertyStore.setQueryBuilder(new JdbcQueryBuilder(TABLE_PREFIX, "", FF4J_SCHEMA)); ff4j.setPropertiesStore(propertyStore); JdbcEventRepository eventRepository = new JdbcEventRepository(ff4jDataSource()); eventRepository.setQueryBuilder(new JdbcQueryBuilder(TABLE_PREFIX, "", FF4J_SCHEMA)); ff4j.setEventRepository(new JdbcEventRepository(ff4jDataSource())); FF4JCacheManager ff4jCache = new FeatureCacheProviderEhCache(); ff4j.cache(ff4jCache); return ff4j; } catch (NamingException | SQLException e) { return null; } }
Source:
<code>private int getHighestProblemSeverity(IResource resource) { int problemSeverity = -1; try { for (IMarker marker : resource.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE)) { problemSeverity = Math.max(problemSeverity, marker.getAttribute(IMarker.SEVERITY, -1)); } } catch (CoreException e) { <START> WorkbenchNavigatorPlugin.log(e.getMessage(), <END> new Status(IStatus.ERROR, WorkbenchNavigatorPlugin.PLUGIN_ID, e.getMessage(), e)); } return problemSeverity; }</code><technical_language>I mute this error, pop if resource marker deleted diring decorator run</technical_language>

Target:
private int getHighestProblemSeverity(IResource resource) { int problemSeverity = -1; try { for (IMarker marker : resource.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE)) { problemSeverity = Math.max(problemSeverity, marker.getAttribute(IMarker.SEVERITY, -1)); } } catch (CoreException e) { } return problemSeverity; }
Source:
<code>public PDOMCPPMemberBlock(PDOMLinkage linkage, long record) throws CoreException { this.linkage = linkage; this.record = record; <START> updateNextPosition(); <END> }</code><technical_language>nextMemberPosition is needed for addMember. Initialize lazily needed</technical_language>

Target:
public PDOMCPPMemberBlock(PDOMLinkage linkage, long record) throws CoreException { this.linkage = linkage; this.record = record; }
Source:
<code>public JobWorkerHealth(alluxio.grpc.JobWorkerHealth jobWorkerHealth) { mWorkerId = jobWorkerHealth.getWorkerId(); <START> mLoadAverage = Lists.newArrayList(jobWorkerHealth.getLoadAverageList()); <END> mLastUpdated = jobWorkerHealth.getLastUpdated(); mHostname = jobWorkerHealth.getHostname(); }</code><technical_language>reason copy gRPC a new list</technical_language>

Target:
public JobWorkerHealth(alluxio.grpc.JobWorkerHealth jobWorkerHealth) { mWorkerId = jobWorkerHealth.getWorkerId(); mLoadAverage = jobWorkerHealth.getLoadAverageList(); mLastUpdated = jobWorkerHealth.getLastUpdated(); mHostname = jobWorkerHealth.getHostname(); }
Source:
<code>public void visit(File file, String relativePath) throws IOException { if(Functions.isWindows()) relativePath = relativePath.replace('\\','/'); if(file.isDirectory()) relativePath+='/'; TarArchiveEntry te = new TarArchiveEntry(relativePath); int mode = IOUtils.mode(file); if (mode!=-1) te.setMode(mode); te.setModTime(file.lastModified()); long size = 0; if (!file.isDirectory()) { size = file.length(); te.setSize(size); } tar.putArchiveEntry(te); try { if (!file.isDirectory()) { FileInputStream in = new FileInputStream(file); try { int len; int read = 0; while ((len = in.read(buf)) >= 0) { if (len + read <= size) { tar.write(buf, 0, len); read += len; } else { tar.write(buf, 0, (int) size - read); break; } } } catch (IOException e) { <START> LOGGER.log(Level.SEVERE, "Error writing to tar file from: " + file, e); <END> throw e; } finally { in.close(); } } } finally { tar.closeArchiveEntry(); } entriesWritten++; }</code><technical_language>log here? IMO is responsibility of caller log errors, not. If wish record filename causing error (in case is obvious), java throw new IOException("Error writing tar file " + file + ": " + e, e);</technical_language>

Target:
public void visit(File file, String relativePath) throws IOException { if(Functions.isWindows()) relativePath = relativePath.replace('\\','/'); if(file.isDirectory()) relativePath+='/'; TarArchiveEntry te = new TarArchiveEntry(relativePath); int mode = IOUtils.mode(file); if (mode!=-1) te.setMode(mode); te.setModTime(file.lastModified()); long size = 0; if (!file.isDirectory()) { size = file.length(); te.setSize(size); } tar.putArchiveEntry(te); try { if (!file.isDirectory()) { try (FileInputStream fin = new FileInputStream(file); BoundedInputStream in = new BoundedInputStream(fin, size)) { int len; while ((len = in.read(buf)) >= 0) { tar.write(buf, 0, len); } } catch (IOException e) { IOException ioE = new IOException("Error writing to tar file from: " + file, e); throw ioE; } } } finally { tar.closeArchiveEntry(); } entriesWritten++; }
Source:
<code><START> public boolean supports(VectorDriver.Capability cap) { <END> switch(cap) { case BOUND: return true; case FILTER: case LIMIT: case OFFSET: case SIMPLIFY: case REPROJECT: case SORT: default: return false; } }</code><technical_language>move implementations a static EnumSet field EnumSet.contains</technical_language>

Target:
public boolean supports(VectorDriver.Capability cap) { return VECTOR_CAPABILITIES.contains(cap); }
Source:
<code>public String apply(String oldName) { if ( UNDERSCORE_TO_CAMEL_CASE.equals(strategyName)) <START> return caches.computeIfAbsent(oldName, k -> underscore2Camel(k)); <END> return oldName; }</code><technical_language>wondering necessary underscore-to-camel-case cache is. guess is if measured it, cost of String#hash cost of underscore2Camel. close enough</technical_language>

Target:
public String apply(String oldName) { if ( strategyType == TYPE_UNDERSCORE_TO_CAMEL_CASE ) return caches.computeIfAbsent(oldName, k -> underscore2Camel(k)); return oldName; }
Source:
<code>private Collection<Map.Entry<String, String>> enrich( final Collection<Map.Entry<String, String>> headers, final Response rsp) { <START> final List<String> list = rsp.headers().get(LAST_MODIFIED); <END> final Map<String, String> map = new ConcurrentHashMap<>(headers.size() + 1); for (final Map.Entry<String, String> entry : headers) { map.put(entry.getKey(), entry.getValue()); } map.put(IF_MODIFIED_SINCE, list.iterator().next()); return map.entrySet(); }</code><technical_language>@piddubnyi full path LastModifiedCachingWire.LAST_MODIFIED</technical_language>

Target:
private Collection<Map.Entry<String, String>> enrich( final Collection<Map.Entry<String, String>> headers, final Response rsp) { final List<String> list = rsp.headers().get( LastModifiedCachingWire.LAST_MODIFIED ); final Map<String, String> map = new ConcurrentHashMap<>(headers.size() + 1); for (final Map.Entry<String, String> entry : headers) { map.put(entry.getKey(), entry.getValue()); } map.put( LastModifiedCachingWire.IF_MODIFIED_SINCE, list.iterator().next() ); return map.entrySet(); }
Source:
<code>public void testSyndicateExistingSyndication() throws Exception { <START> final ArticleRevisionIdentifier revisionId = ArticleRevisionIdentifier.create("0", 1); <END> when(mockArticleCrudService.readRevision(revisionId)).thenReturn(createStubArticleRevision()); when(mockHibernateTemplate.execute(any())).thenReturn(createStubSyndication()); mockSyndicationCrudService.syndicate(revisionId, "test"); verify(mockHibernateTemplate).update(any(Syndication.class)); verify(mockMessageSender).sendBody(any(String.class), any(String.class)); }</code><technical_language>Assigning revisionId = ArticleRevisionIdentifier.create("0", 1) done @BeforeMethod</technical_language>

Target:
public void testSyndicateExistingSyndication() throws Exception { when(mockArticleCrudService.readRevision(stubRevisionId)).thenReturn(createStubArticleRevision()); when(mockHibernateTemplate.execute(any())).thenReturn(createStubSyndication()); mockSyndicationCrudService.syndicate(stubRevisionId, "test"); verify(mockHibernateTemplate).update(any(Syndication.class)); verify(mockMessageSender).sendBody(any(String.class), any(String.class)); }
Source:
<code>public NotificationPopup(@NotNull StatusNotification notification, @NotNull Resources resources, @NotNull NotificationActionDelegate delegate) { this.notification = notification; this.resources = resources; this.delegate = delegate; setStyleName(resources.notificationCss().notificationPopupPanel()); notification.addObserver(this); <START> FlowPanel contentWrapper = new FlowPanel("div"); <END> contentWrapper.add(titlePanel = createTitleWidget()); contentWrapper.add(messagePanel = createMessageWidget()); contentWrapper.setStyleName(resources.notificationCss().notificationPopupContentWrapper()); contentWrapper.ensureDebugId(getDebugId(CONTENT_DBG_ID, notification)); FlowPanel notificationWrapper = new FlowPanel("div"); notificationWrapper.add(iconPanel = createIconWidget()); notificationWrapper.add(contentWrapper); notificationWrapper.add(createCloseWidget()); notificationWrapper.setStyleName(resources.notificationCss().notificationPopup()); notificationWrapper.ensureDebugId(getDebugId(NOTIFICATION_WRAPPER_DBG_ID, notification)); getElement().getStyle().setOpacity(0); setWidget(notificationWrapper); }</code><technical_language>do new FlowPanel()</technical_language>

Target:
public NotificationPopup(@NotNull StatusNotification notification, @NotNull Resources resources, @NotNull NotificationActionDelegate delegate) { this.notification = notification; this.resources = resources; this.delegate = delegate; setStyleName(resources.notificationCss().notificationPopupPanel()); notification.addObserver(this); FlowPanel contentWrapper = new FlowPanel(); contentWrapper.add(titlePanel = createTitleWidget()); contentWrapper.add(messagePanel = createContentWidget()); contentWrapper.setStyleName(resources.notificationCss().notificationPopupContentWrapper()); contentWrapper.ensureDebugId(CONTENT_DBG_ID + notification.getId()); FlowPanel notificationWrapper = new FlowPanel(); notificationWrapper.add(iconPanel = createIconWidget()); notificationWrapper.add(contentWrapper); notificationWrapper.add(createCloseWidget()); notificationWrapper.setStyleName(resources.notificationCss().notificationPopup()); notificationWrapper.ensureDebugId(NOTIFICATION_WRAPPER_DBG_ID + notification.getId()); getElement().getStyle().setOpacity(0); setWidget(notificationWrapper); }
Source:
<code>public String getName() { <START> return "CrackShotPlayerFinishesReloadingWeaponEvent"; <END> }</code><technical_language>Remove Event getName's</technical_language>

Target:
public String getName() { return "CrackShotPlayerFinishesReloadingWeapon"; }
Source:
<code>public int run(String[] args) throws Exception { String command = args[0]; checkArgument(FSCK_COMMANDS.contains(command), "Unknown %s command, should be %s", command); <START> int argsCount = COMMAND_CHECK.equals(command) ? 2 : 3; <END> checkArgument( args.length == argsCount, "%s arguments should be specified for %s command, but were: %s", argsCount, lazy(() -> Arrays.toString(args))); String bucket = args[1]; checkArgument( bucket.startsWith(GoogleCloudStorageFileSystem.SCHEME + "://"), "bucket parameter should have 'gs://' scheme"); String operationId = COMMAND_CHECK.equals(command) ? null : args[2]; return new CoopLockFsckRunner(getConf(), URI.create(bucket), command, operationId).run(); }</code><technical_language>s/argsCount/expectedNumArgs/g</technical_language>

Target:
public int run(String[] args) throws Exception { String command = args[0]; checkArgument(FSCK_COMMANDS.contains(command), "Unknown %s command, should be %s", command); int expectedArgsNumber = COMMAND_CHECK.equals(command) ? 2 : 3; checkArgument( args.length == expectedArgsNumber, "%s arguments should be specified for %s command, but were: %s", expectedArgsNumber, lazy(() -> Arrays.toString(args))); String bucket = args[1]; checkArgument( bucket.startsWith(GoogleCloudStorageFileSystem.SCHEME + "://"), "bucket parameter should have 'gs://' scheme"); String operationId = COMMAND_CHECK.equals(command) ? null : args[2]; return new CoopLockFsckRunner(getConf(), URI.create(bucket), command, operationId).run(); }
Source:
<code>public void onEntityCollision(World world, BlockPos pos, IBlockState blockState, Entity entity) { if (!world.isRemote && world.getTileEntity(pos) instanceof TileDimensionalPortal) { TileDimensionalPortal tile = (TileDimensionalPortal) world.getTileEntity(pos); LocationsHandler.verifyIsInitialized(); ArrayList<PortalLocation> linkedLocations = LocationsHandler.getLinkedLocations(tile.portalID); if (linkedLocations != null && linkedLocations.size() > 1) { if (world.getTileEntity(tile.getMasterStonePos()) != null && world.getTileEntity(tile.getMasterStonePos()) instanceof IMasterRitualStone) { IMasterRitualStone masterRitualStone = (IMasterRitualStone) world.getTileEntity(tile.getMasterStonePos()); PortalLocation portal; int index = linkedLocations.size() - 1; <START> if (linkedLocations.get(index).equals(new PortalLocation(masterRitualStone.getBlockPos().up(), world.provider.getDimension()))) { <END> portal = linkedLocations.get(index-1); } else { portal = linkedLocations.get(index); } if (portal.getDimension() == world.provider.getDimension()) { TeleportQueue.getInstance().addITeleport(new Teleports.TeleportSameDim(portal.getX(), portal.getY(), portal.getZ(), entity, masterRitualStone.getOwner(), false)); } else { TeleportQueue.getInstance().addITeleport(new Teleports.TeleportToDim(portal.getX(), portal.getY(), portal.getZ(), entity, masterRitualStone.getOwner(), world, portal.getDimension(), false)); } } } } }</code><technical_language><LINK_0> --> java if (linkedLocations.get(index).equals(new PortalLocation(masterRitualStone.getBlockPos().up(), world.provider.getDimension()))) index--; // if PortalLocation = this, get 2nd portal = linkedLocations.get(index);</technical_language>

Target:
public void onEntityCollision(World world, BlockPos pos, IBlockState blockState, Entity entity) { if (!world.isRemote && world.getTileEntity(pos) instanceof TileDimensionalPortal) { TileDimensionalPortal tile = (TileDimensionalPortal) world.getTileEntity(pos); ArrayList<PortalLocation> linkedLocations = LocationsHandler.getLinkedLocations(tile.portalID); if (linkedLocations != null && linkedLocations.size() > 1) { TileEntity tileEntity = world.getTileEntity(tile.getMasterStonePos()); if (tileEntity instanceof IMasterRitualStone) { IMasterRitualStone masterRitualStone = (IMasterRitualStone) tileEntity; PortalLocation portal; int index = linkedLocations.size() - 1; if (linkedLocations.get(index).equals(new PortalLocation(masterRitualStone.getBlockPos().up(), world.provider.getDimension()))) index--; portal = linkedLocations.get(index); if (portal.getDimension() == world.provider.getDimension()) { TeleportQueue.getInstance().addITeleport(new Teleports.TeleportSameDim(portal.getX(), portal.getY(), portal.getZ(), entity, masterRitualStone.getOwner(), false)); } else { TeleportQueue.getInstance().addITeleport(new Teleports.TeleportToDim(portal.getX(), portal.getY(), portal.getZ(), entity, masterRitualStone.getOwner(), world, portal.getDimension(), false)); } } } } }
Source:
<code>private TableConfiguration buildVertexTableConf(final String tableId) throws InjectionException { final DataParser dataParser = masterConfInjector.getInstance(DataParser.class); return TableConfiguration.newBuilder() .setId(tableId) .setKeyCodecClass(SerializableCodec.class) .setValueCodecClass(DefaultVertexCodec.class) <START> .setUpdateValueCodecClass(SerializableCodec.class) <END> .setUpdateFunctionClass(VoidUpdateFunction.class) .setIsMutableTable(true) .setIsOrderedTable(false) .setDataParserClass(dataParser.getClass()) .setBulkDataLoaderClass(ExistKeyBulkDataLoader.class) .build(); }</code><technical_language>Yes, I "bind a NullCodec for UpdateValueCodecClass of vertex table"</technical_language>

Target:
private TableConfiguration buildVertexTableConf(final String tableId) throws InjectionException { final DataParser dataParser = masterConfInjector.getInstance(DataParser.class); final StreamingCodec vertexValueCodec = masterConfInjector.getNamedInstance(VertexValueCodec.class); final StreamingCodec edgeCodec = masterConfInjector.getNamedInstance(EdgeCodec.class); final Configuration vertexComponentCodecConf = Tang.Factory.getTang().newConfigurationBuilder() .bindNamedParameter(VertexValueCodec.class, vertexValueCodec.getClass()) .bindNamedParameter(EdgeCodec.class, edgeCodec.getClass()) .build(); return TableConfiguration.newBuilder() .setId(tableId) .setKeyCodecClass(SerializableCodec.class) .setValueCodecClass(DefaultVertexCodec.class) .setUpdateValueCodecClass(NullCodec.class) .setUpdateFunctionClass(VoidUpdateFunction.class) .setIsMutableTable(true) .setIsOrderedTable(false) .setDataParserClass(dataParser.getClass()) .setBulkDataLoaderClass(ExistKeyBulkDataLoader.class) .setUserParamConf(vertexComponentCodecConf) .build(); }
Source:
<code>public Map<String, String> getProperties() { try (InputStream in = resource.getInputStream()) { <START> if (in != null) { <END> try { Class.forName("org.yaml.snakeyaml.Yaml"); Yaml yaml = new Yaml(); Map config = yaml.loadAs(in, Map.class); return getFlattenedMap(config); } catch (ClassNotFoundException e) { log.warn("YAML not found in classpath, add 'org.yaml:snakeyaml' to support YAML configuration"); } } } catch (IOException e) { throw new IllegalArgumentException("Unable to read resource [" + resource + "]: " + e.getMessage(), e); } return new LinkedHashMap<>(); }</code><technical_language>scenario in in null this point? if file exist, getInputStream throw a FileNotFoundException FileResource.java. add a catch FileNotFoundException? Then, get rid of null check, yes</technical_language>

Target:
public Map<String, String> getProperties() { try (InputStream in = resource.getInputStream()) { if (in != null && Classes.isAvailable("org.yaml.snakeyaml.Yaml")) { Yaml yaml = new Yaml(); Map config = yaml.loadAs(in, Map.class); return getFlattenedMap(config); } else { log.warn("YAML not found in classpath, add 'org.yaml.snakeyaml' to support YAML configuration"); } } catch (IOException e) { throw new IllegalArgumentException("Unable to read resource [" + resource + "]: " + e.getMessage(), e); } return new LinkedHashMap<>(); }
Source:
<code>public boolean isNetworkProviderEnabled() { <START> return locationManager.isProviderEnabled(String.valueOf(R.string.network_provider)); <END> }</code><technical_language>constants enums</technical_language>

Target:
public boolean isNetworkProviderEnabled() { return locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); }
Source:
<code>private StartupStrategyProvider() { if (strategyName == null || strategyName.length() == 0) { strategyName = ControllerBasedStartupStrategy.class.getSimpleName(); } <START> System.setProperty(KieServerConstants.KIE_SERVER_STARTUP_STRATEGY, strategyName); <END> if ("OpenShiftStartupStrategy".equals(strategyName) || "KubernetesStartupStrategy".equals(strategyName)) System.setProperty(KieServerConstants.KIE_SERVER_STATE_REPO_TYPE, "KieServerStateCloudRepository"); strategies.forEach( s -> { foundStrategies.put(s.getClass().getSimpleName(), s); logger.debug("Discovered '{}' startup strategy and registered under '{}'", s, s.getClass().getSimpleName()); } ); foundStrategies.put(ControllerBasedStartupStrategy.class.getSimpleName(), new ControllerBasedStartupStrategy()); }</code><technical_language>do need set this system property</technical_language>

Target:
private StartupStrategyProvider() { if (strategyName == null || strategyName.length() == 0) { strategyName = ControllerBasedStartupStrategy.class.getSimpleName(); } strategies.forEach( s -> { foundStrategies.put(s.getClass().getSimpleName(), s); logger.debug("Discovered '{}' startup strategy and registered under '{}'", s, s.getClass().getSimpleName()); } ); foundStrategies.put(ControllerBasedStartupStrategy.class.getSimpleName(), new ControllerBasedStartupStrategy()); }
Source:
<code>private static long retrieveIsoFileSize(Map.Entry<String, Map<String, String>> isoFileWithMetadata) { String sizeValue = isoFileWithMetadata.getValue().get("size"); if (sizeValue == null) { return SIZE_IS_NOT_AVAILABLE; } <START> <END> try { return Long.valueOf(sizeValue); } catch (NumberFormatException e) { log.errorFormat("File's '{0}' size is illegal number", isoFileWithMetadata.getKey(), e); return SIZE_IS_NOT_AVAILABLE; } }</code><technical_language>Lines 578-581 removed Long.valueOf handles null</technical_language>

Target:
private static long retrieveIsoFileSize(Map.Entry<String, Map<String, String>> isoFileWithMetadata) { String sizeValue = isoFileWithMetadata.getValue().get("size"); try { return Long.valueOf(sizeValue); } catch (NumberFormatException e) { log.errorFormat("File's '{0}' size is illegal number", isoFileWithMetadata.getKey(), e); return SIZE_IS_NOT_AVAILABLE; } }
Source:
<code>public CollapsedNode(InternalNode wrapped) { wrappedNode = wrapped; wrappedNode.getChildren().forEach(child -> child.setVisible(false)); <START> wrappedNode.getChildren().add(0, this); <END> wrappedNode.marginProperty().bind(this.marginProperty()); this.label = new Text(LeafNode.LABEL_X_OFFSET, LeafNode.LABEL_Y_OFFSET, "collapsed."); this.label.onMouseClickedProperty().bind(shape.onMouseClickedProperty()); this.label.setTextAlignment(TextAlignment.CENTER); getChildren().add(this.label); this.marginProperty().set(LeafNode.LEAFHEIGHT); }</code><technical_language>do add beginning of list</technical_language>

Target:
public CollapsedNode(InternalNode wrapped) { wrappedNode = wrapped; wrappedNode.getChildren().forEach(child -> child.setVisible(false)); wrappedNode.getChildren().add(this); wrappedNode.marginProperty().bind(this.marginProperty()); this.label = new Text(LeafNode.LABEL_X_OFFSET, LeafNode.LABEL_Y_OFFSET, ""); this.label.textProperty().bind(wrapped.leafCountProperty().asString().concat(" strains")); this.label.onMouseClickedProperty().bind(shape.onMouseClickedProperty()); this.label.setTextAlignment(TextAlignment.CENTER); getChildren().add(this.label); this.marginProperty().set(LeafNode.LEAFHEIGHT); }
Source:
<code>public void test() throws Exception { <START> ChatManager m1 = ChatManager.getInstanceFor(conOne); <END> ChatManager m2 = ChatManager.getInstanceFor(conTwo); m2.addIncomingListener(listener); Chat chat = m1.chatWith(conTwo.getUser().asEntityBareJid()); chat.send(body); syncPoint.waitForResult(10 * 1000); }</code><technical_language>ChatManagers fields of test class. named patter other tests use, i.e. chatManagerOne chatManagerTwo</technical_language>

Target:
public void test() throws Exception { ChatManager chatManagerOne = ChatManager.getInstanceFor(conOne); ChatManager chatManagerTwo = ChatManager.getInstanceFor(conTwo); final String body = StringUtils.randomString(16); final SimpleResultSyncPoint syncPoint = new SimpleResultSyncPoint(); final IncomingChatMessageListener listener = new IncomingChatMessageListener() { @Override public void newIncomingMessage(EntityBareJid from, Message message, Chat chat) { if (body.equals(message.getBody())) { syncPoint.signal(); } } }; try { chatManagerTwo.addIncomingListener(listener); Chat chat = chatManagerOne.chatWith(conTwo.getUser().asEntityBareJid()); chat.send(body); syncPoint.waitForResult(10 * 1000); } finally { chatManagerTwo.removeIncomingListener(listener); } }