auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected void fillContextMenu(IMenuManager manager) { final ISelection selection = fViewer.getSelection(); ITmfFilterTreeNode filterTreeNode = null; if (selection instanceof StructuredSelection) { Object element = ((StructuredSelection) selection).getFirstElement(); if (element instanceof ITmfFilterTreeNode) { filterTreeNode = (ITmfFilterTreeNode) element; } } <START> final ITmfFilterTreeNode selectedNode = filterTreeNode; <END> if (selectedNode != null) { fillContextMenuForNode(selectedNode, manager); if (selectedNode.getValidChildren().size() > 0) { manager.add(new Separator()); } Action deleteAction = new Action() { @Override public void run() { selectedNode.remove(); fViewer.refresh(); } }; deleteAction.setText(Messages.FilterViewer_DeleteActionText); manager.add(deleteAction); manager.add(new Separator()); } if (fViewer.getInput() instanceof TmfFilterRootNode || selectedNode == null) { final ITmfFilterTreeNode root = (ITmfFilterTreeNode) fViewer.getInput(); fillContextMenuForNode(root, manager); } }</code><technical_language>nice add Cut, Copy & Paste actions context menu</technical_language>

Target:
protected void fillContextMenu(IMenuManager manager) { final ISelection selection = fViewer.getSelection(); ITmfFilterTreeNode filterTreeNode = null; if (selection instanceof StructuredSelection) { Object element = ((StructuredSelection) selection).getFirstElement(); if (element instanceof ITmfFilterTreeNode) { filterTreeNode = (ITmfFilterTreeNode) element; } } if (filterTreeNode != null) { fillContextMenuForNode(filterTreeNode, manager); manager.add(new Separator("delete")); manager.add(new Separator("edit")); } if (fViewer.getInput() instanceof TmfFilterRootNode || filterTreeNode == null) { manager.add(new Separator()); ITmfFilterTreeNode root = (ITmfFilterTreeNode) fViewer.getInput(); fillContextMenuForNode(root, manager); } }
Source:
<code><START> public UserAuthenticatedEvent() <END> { }</code><technical_language>indentation issue empty constructor (forbidden)</technical_language>

Target:
public UserAuthenticatedEvent() { super(); }
Source:
<code>private double getRequiredSizeForMerge(SubchainInfo subchain, VdcActionType snapshotActionType) { DiskImage baseSnapshot = subchain.getBaseImage(); DiskImage topSnapshot = subchain.getTopImage(); if <START> (VdcActionType.RemoveSnapshotSingleDisk == snapshotActionType) { <END> return Math.min(baseSnapshot.getActualSizeInBytes() + topSnapshot.getActualSizeInBytes(), baseSnapshot.getSize()) * StorageConstants.QCOW_OVERHEAD_FACTOR; } if (Guid.Empty.equals(baseSnapshot.getParentId())) { if (baseSnapshot.getVolumeFormat() == VolumeFormat.RAW) { if (storageDomain.getStorageType().isBlockDomain()) { return 0.0; } else { return Math.min(topSnapshot.getActualSizeInBytes() / StorageConstants.QCOW_OVERHEAD_FACTOR, baseSnapshot.getSize() - baseSnapshot.getActualSizeInBytes()); } } } double requiredExtendSize = Math.min(topSnapshot.getSize() * StorageConstants.QCOW_OVERHEAD_FACTOR - baseSnapshot.getActualSizeInBytes(), topSnapshot.getActualSizeInBytes()); return requiredExtendSize; }</code><technical_language>Style, I prfer: if (snapshotActionType == VdcActionType.RemoveSnapshotSingleDisk)</technical_language>

Target:
private double getRequiredSizeForMerge(SubchainInfo subchain, VdcActionType snapshotActionType) { DiskImage baseSnapshot = subchain.getBaseImage(); DiskImage topSnapshot = subchain.getTopImage(); if (VdcActionType.RemoveSnapshotSingleDisk == snapshotActionType) { return Math.min(baseSnapshot.getActualSizeInBytes() + topSnapshot.getActualSizeInBytes(), baseSnapshot.getSize()) * StorageConstants.QCOW_OVERHEAD_FACTOR; } if (Guid.Empty.equals(baseSnapshot.getParentId())) { if (baseSnapshot.getVolumeFormat() == VolumeFormat.RAW) { if (storageDomain.getStorageType().isBlockDomain()) { return 0.0; } return Math.min(topSnapshot.getActualSizeInBytes() / StorageConstants.QCOW_OVERHEAD_FACTOR, baseSnapshot.getSize() - baseSnapshot.getActualSizeInBytes()); } } return Math.min(topSnapshot.getSize() * StorageConstants.QCOW_OVERHEAD_FACTOR - baseSnapshot.getActualSizeInBytes(), topSnapshot.getActualSizeInBytes()); }
Source:
<code>public ValidationResult validate(Object value) { Long longValue = null; ValidationResult res = new ValidationResult(); <START> if (value instanceof Long) { longValue = (Long) value; } else if (value instanceof String && !((String) value).trim().isEmpty()) { try { longValue = Long.valueOf((String) value); } catch (NumberFormatException e) { } } <END> if (longValue == null || longValue < 0) { res.setSuccess(false); res.getReasons().add(ConstantsManager.getInstance() .getConstants().thisFieldMustContainNonNegativeIntegerNumberInvalidReason()); } return res; }</code><technical_language>mentioned, create method checks for null, checks for type "Long", transforms "String" --> "Long"</technical_language>

Target:
public ValidationResult validate(Object value) { Long longValue = LongValidation.tryParseLong(value);; ValidationResult res = new ValidationResult(); if (longValue == null || longValue < 0) { res.setSuccess(false); res.getReasons().add(ConstantsManager.getInstance() .getConstants().thisFieldMustContainNonNegativeIntegerNumberInvalidReason()); } return res; }
Source:
<code>protected boolean set(TileEntityFurnace container, Integer value) { <START> container.setField(0, container.getField(1) - value); <END> return true; }</code><technical_language>return false if is greater furnace's set maximum</technical_language>

Target:
protected boolean set(TileEntityFurnace container, Integer value) { if(value > container.getField(1)){ return false; } container.setField(0, container.getField(1) - value); return true; }
Source:
<code>public void paint(final RenderContext renderContext) { <START> boolean doTransform = Config.getInstance().getBoolean(PARAMETERS_KEY, false); <END> if (!doTransform) { super.paint(renderContext); return; } if (!(renderContext instanceof WebXmlRenderContext)) { LOG.warn("Unable to transform a " + renderContext); super.paint(renderContext); return; } LOG.debug("Transform XML Interceptor: Start"); UIContext uic = UIContextHolder.getCurrent(); StringWriter xmlBuffer = new StringWriter(); PrintWriter xmlWriter = new PrintWriter(xmlBuffer); WebXmlRenderContext xmlContext = new WebXmlRenderContext(xmlWriter, uic.getLocale()); super.paint(xmlContext); WebXmlRenderContext webRenderContext = (WebXmlRenderContext) renderContext; PrintWriter writer = webRenderContext.getWriter(); Response response = getResponse(); response.setContentType(WebUtilities.CONTENT_TYPE_HTML); String xml = xmlBuffer.toString(); transform(xml, uic, writer); LOG.debug("Transform XML Interceptor: Finished"); }</code><technical_language>Lets turn default</technical_language>

Target:
public void paint(final RenderContext renderContext) { boolean doTransform = Config.getInstance().getBoolean(PARAMETERS_KEY, true); if (!doTransform) { super.paint(renderContext); return; } if (!(renderContext instanceof WebXmlRenderContext)) { LOG.warn("Unable to transform a " + renderContext); super.paint(renderContext); return; } LOG.debug("Transform XML Interceptor: Start"); UIContext uic = UIContextHolder.getCurrent(); StringWriter xmlBuffer = new StringWriter(); PrintWriter xmlWriter = new PrintWriter(xmlBuffer); WebXmlRenderContext xmlContext = new WebXmlRenderContext(xmlWriter, uic.getLocale()); super.paint(xmlContext); WebXmlRenderContext webRenderContext = (WebXmlRenderContext) renderContext; PrintWriter writer = webRenderContext.getWriter(); Response response = getResponse(); response.setContentType(WebUtilities.CONTENT_TYPE_HTML); String xml = xmlBuffer.toString(); transform(xml, uic, writer); LOG.debug("Transform XML Interceptor: Finished"); }
Source:
<code>public boolean hasChildren(final String childType) { if (LOG_FILE.equals(childType)) { final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); if (logDir != null) { final Path dir = Paths.get(logDir); final Collection<String> validFileNames = findValidFileNames(getFileHandlersModel()); for (String name : validFileNames) { final Path file = dir.resolve(name); if (Files.exists(file) && Files.isReadable(file)) { return true; } } } <START> return false; <END> } return delegate.hasChildren(childType); }</code><technical_language>this result in longer reporting children if base file removed a rotated file is present? if is ok</technical_language>

Target:
public boolean hasChildren(final String childType) { if (LOG_FILE.equals(childType)) { final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); if (logDir != null) { final Path dir = Paths.get(logDir); final Collection<String> validFileNames = findValidFileNames(getFileHandlersModel()); for (String name : validFileNames) { final Path file = dir.resolve(name); if (Files.exists(file) && Files.isReadable(file)) { return true; } else { final AtomicBoolean found = new AtomicBoolean(false); try { Files.walkFileTree(dir, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException { final Path relativeFile = dir.relativize(file); final String resourceName = relativeFile.toString(); if ((resourceName.equals(name) || resourceName.startsWith(name)) && Files.isReadable(file)) { found.set(true); return FileVisitResult.TERMINATE; } return FileVisitResult.CONTINUE; } }); if (found.get()) { return true; } } catch (IOException e) { LoggingLogger.ROOT_LOGGER.errorDeterminingChildrenExist(e, childType); } } } } return false; } return delegate.hasChildren(childType); }
Source:
<code>public void start() { <START> LOG.info("Started"); <END> }</code><technical_language>nit: put "File connector started" instead</technical_language>

Target:
public void start() { LOG.info("FileConnector started"); }
Source:
<code>public List<AbstractContainer> getContainers() { <START> return Collections.unmodifiableList(containers); <END> }</code><technical_language>I try protect internal collections, complicates later. return as-is</technical_language>

Target:
public List<AbstractContainer> getContainers() { return containers; }
Source:
<code><START> private Space(String enumeratedValue) { <END> this.enumeratedValue = enumeratedValue; }</code><technical_language>Modifier 'private' is redundant for Enum constructor - needs removed</technical_language>

Target:
Space(String enumeratedValue) { this.enumeratedValue = enumeratedValue; }
Source:
<code>public void setGenerateTestResultAttributes(final Boolean generateTestResultAttributes) { <START> m_generateTestResultAttributes = generateTestResultAttributes; <END> }</code><technical_language>if is null below</technical_language>

Target:
public void setGenerateTestResultAttributes(final Boolean generateTestResultAttributes) { m_generateTestResultAttributes = generateTestResultAttributes != null ? generateTestResultAttributes : false; }
Source:
<code>public void offerPaymentStateTransition(String externalId, ChargeStatus fromChargeState, ChargeStatus targetChargeState, ChargeEventEntity chargeEventEntity) { PaymentGatewayStateTransitions.getInstance() .getEventForTransition(fromChargeState, targetChargeState) .ifPresent(eventClass -> { PaymentStateTransition transition = new PaymentStateTransition(chargeEventEntity.getId(), eventClass); stateTransitionQueue.offer(transition); var logMessage = format("Offered payment state transition to emitter queue [from=%s] [to=%s] [chargeEventId=%s] [chargeId=%s]", fromChargeState, targetChargeState, chargeEventEntity.getId(), externalId); logger.info(logMessage, kv(PROVIDER, chargeEventEntity.getChargeEntity().getPaymentGatewayName().getName()), kv(PAYMENT_EXTERNAL_ID, externalId), kv(GATEWAY_ACCOUNT_TYPE, chargeEventEntity.getChargeEntity().getGatewayAccount().getType()), <START> kv(GATEWAY_ACCOUNT_ID, chargeEventEntity.getChargeEntity().getGatewayAccount().getId()), <END> kv("from_state", fromChargeState), kv("to_state", targetChargeState)); eventService.recordOfferedEvent(ResourceType.PAYMENT, externalId, Event.eventTypeForClass(eventClass), chargeEventEntity.getUpdated() ); }); }</code><technical_language>getStructuredKeys method added ChargeEntity public get basic keys</technical_language>

Target:
public void offerPaymentStateTransition(String externalId, ChargeStatus fromChargeState, ChargeStatus targetChargeState, ChargeEventEntity chargeEventEntity) { PaymentGatewayStateTransitions.getInstance() .getEventForTransition(fromChargeState, targetChargeState) .ifPresent(eventClass -> { PaymentStateTransition transition = new PaymentStateTransition(chargeEventEntity.getId(), eventClass); stateTransitionQueue.offer(transition); var logMessage = format("Offered payment state transition to emitter queue [from=%s] [to=%s] [chargeEventId=%s] [chargeId=%s]", fromChargeState, targetChargeState, chargeEventEntity.getId(), externalId); var structuredArgs = Stream.concat( chargeEventEntity.getChargeEntity().getStructuredLoggingArgs().stream(), List.of(kv("from_state", fromChargeState), kv("to_state", targetChargeState)).stream()); logger.info(logMessage, structuredArgs); eventService.recordOfferedEvent(ResourceType.PAYMENT, externalId, Event.eventTypeForClass(eventClass), chargeEventEntity.getUpdated() ); }); }
Source:
<code>private void addSelectedMappingFiles(String filterPath, String[] fileNames) { List<String> invalidFiles = new ArrayList<>(); for (String fileName : fileNames) { String fullPath = filterPath + File.separator + fileName; File file = new File(fullPath); Map<String, String> results = null; boolean isBinaryFile = isBinaryFile(fullPath); if (isBinaryFile) { results = FunctionNameMapper.mapFromBinaryFile(file); } else if ("txt".equals(FilenameUtils.getExtension(fileName))) { results = FunctionNameMapper.mapFromNmTextFile(file); } if (results != null) { MappingFile mf = new MappingFile(file.getAbsolutePath(), isBinaryFile, results); <START> fSymbolProvider.addMappingFile(mf); <END> } else { invalidFiles.add(fullPath); } } if (!invalidFiles.isEmpty()) { displayErrorMessage(invalidFiles); } fMappingTable.getTableViewer().setInput(fSymbolProvider.getMappingFiles()); }</code><technical_language>This happen user presses OK</technical_language>

Target:
private void addSelectedMappingFiles(String filterPath, String[] fileNames) { List<String> invalidFiles = new ArrayList<>(); for (String fileName : fileNames) { String fullPath = filterPath + File.separator + fileName; File file = new File(fullPath); Map<String, String> results = null; boolean isBinaryFile = isBinaryFile(fullPath); if (isBinaryFile) { results = FunctionNameMapper.mapFromBinaryFile(file); } else if ("txt".equals(FilenameUtils.getExtension(fileName))) { results = FunctionNameMapper.mapFromNmTextFile(file); } if (results != null) { MappingFile mf = new MappingFile(file.getAbsolutePath(), isBinaryFile, results); fSymbolProvider.addMappingFile(mf); } else { invalidFiles.add(fullPath); } } if (!invalidFiles.isEmpty()) { displayErrorMessage(invalidFiles); } fMappingTable.setInput(fSymbolProvider.getMappingFiles()); }
Source:
<code>public Resource getResource() { <START> return getResource(null); <END> }</code><technical_language>This kinda pointless a bit brittle. return resource</technical_language>

Target:
public Resource getResource() { return resource; }
Source:
<code>public void forget(Xid xid) throws XAException { <START> System.out.println("[" + Thread.currentThread().getName() + "] DummyXAResource (" + serverId + ") XA_FORGET[" + xid + "]"); <END> }</code><technical_language>worth debugging for this QS</technical_language>

Target:
public void forget(Xid xid) throws XAException { }
Source:
<code>public void visitNode(Tree tree) { if(!hasSemantic()) { return; } TypeCastTree typeCastTree = (TypeCastTree) tree; Type expressionType = typeCastTree.expression().symbolType(); if (isPrimitiveWrapperInConditional(expressionType, typeCastTree) || requiredForMemberAccess(typeCastTree)) { return; } Type cast = typeCastTree.type().symbolType(); Type target = targetType(typeCastTree); <START> boolean isArgument = skipParentheses(typeCastTree.parent()).is(Tree.Kind.ARGUMENTS); <END> if (target != null && (isRedundantNumericalCast(cast, expressionType) || isUnnecessarySubtypeCast(expressionType, typeCastTree, target, isArgument))) { reportIssue(typeCastTree.type(), "Remove this unnecessary cast to \"" + cast.erasure() + "\"."); } }</code><technical_language>need isArgument method isUnnecessarySubtypeCast(), computed there, passing typeCastTree parameter</technical_language>

Target:
public void visitNode(Tree tree) { if (!hasSemantic()) { return; } TypeCastTree typeCastTree = (TypeCastTree) tree; Type expressionType = typeCastTree.expression().symbolType(); if (isPrimitiveWrapperInConditional(expressionType, typeCastTree) || requiredForMemberAccess(typeCastTree)) { return; } Type cast = typeCastTree.type().symbolType(); Type target = targetType(typeCastTree); if (target != null && (isRedundantNumericalCast(cast, expressionType) || isUnnecessarySubtypeCast(expressionType, typeCastTree, target))) { reportIssue(typeCastTree.type(), "Remove this unnecessary cast to \"" + cast.erasure() + "\"."); } }
Source:
<code>public void shouldReturn422ForInvalidCardType() { HashMap<String, Object> postBody = new HashMap<>(); postBody.put("amount", 12000); postBody.put("reference", "MRPC12345"); postBody.put("description", "New passport application"); postBody.put("created_date", "2018-02-21T16:04:25Z"); postBody.put("authorised_date", "2018-02-21T16:05:33Z"); postBody.put("processor_id", "183f2j8923j8"); postBody.put("provider_id", "17498-8412u9-1273891239"); postBody.put("auth_code", "666"); postBody.put("payment_outcome", Map.of( "status", "success" ) ); postBody.put("card_type", "invalid-card"); postBody.put("name_on_card", "Jane Doe"); postBody.put("email_address", "jane_doe@example.com"); postBody.put("card_expiry", "02/19"); postBody.put("last_four_digits", "1234"); postBody.put("first_six_digits", "123456"); postBody.put("telephone_number", "+447700900796"); String payload = toJson(postBody); connectorRestApiClient .postCreateTelephoneCharge(payload) <START> .statusCode(422); <END> }</code><technical_language>error message? (To fails for valid reason)</technical_language>

Target:
public void shouldReturn422ForInvalidCardType() { HashMap<String, Object> postBody = new HashMap<>(); postBody.put("amount", 12000); postBody.put("reference", "MRPC12345"); postBody.put("description", "New passport application"); postBody.put("created_date", "2018-02-21T16:04:25Z"); postBody.put("authorised_date", "2018-02-21T16:05:33Z"); postBody.put("processor_id", "183f2j8923j8"); postBody.put("provider_id", "17498-8412u9-1273891239"); postBody.put("auth_code", "666"); postBody.put("payment_outcome", Map.of( "status", "success" ) ); postBody.put("card_type", "invalid-card"); postBody.put("name_on_card", "Jane Doe"); postBody.put("email_address", "jane_doe@example.com"); postBody.put("card_expiry", "02/19"); postBody.put("last_four_digits", "1234"); postBody.put("first_six_digits", "123456"); postBody.put("telephone_number", "+447700900796"); String payload = toJson(postBody); connectorRestApiClient .postCreateTelephoneCharge(payload) .statusCode(422) .body("message[0]", is("Must be either master-card, visa, maestro, diners-club or american-express")); }
Source:
<code>public static boolean renderWorldBlock(IBlockState blockState, BlockPos blockPos, IBlockAccess blockAccess, WorldRenderer worldRenderer, int modelId) { if (!instance().blockRendererMap.containsKey(modelId)) return false; return instance().blockRendererMap.get(modelId).renderWorldBlock(blockState, blockPos, blockAccess, worldRenderer, modelId); <START> } <END></code><technical_language>Note, this is rendering do renderer = get a null check instead of lookup calls</technical_language>

Target:
public static boolean renderWorldBlock(IBlockState blockState, BlockPos blockPos, IBlockAccess blockAccess, WorldRenderer worldRenderer, int modelId) { IBlockRenderer blockRenderer = instance().blockRendererMap.get(modelId); return blockRenderer == null ? false : blockRenderer.renderWorldBlock(blockState, blockPos, blockAccess, worldRenderer, modelId); }
Source:
<code>public void testFailFast() throws Exception { startGridsMultiThreaded(5); final CountDownLatch failLatch = new CountDownLatch(4); for (int i = 0; i < 5; i++) { ignite(i).events().localListen(new IgnitePredicate<Event>() { @Override public boolean apply(Event evt) { info(evt.shortDisplay()); failLatch.countDown(); return true; } }, EVT_NODE_FAILED); } Ignite ignite1 = ignite(0); Ignite ignite2 = ignite(1); final CountDownLatch evtLatch = new CountDownLatch(1); ignite1.message().localListen(null, new MessagingListenActor<Object>() { @Override protected void receive(UUID nodeId, Object rcvMsg) throws Throwable { respond(rcvMsg); } }); ignite2.message().localListen(null, new MessagingListenActor<Object>() { @Override protected void receive(UUID nodeId, Object rcvMsg) throws Throwable { evtLatch.countDown(); respond(rcvMsg); } }); ignite1.message(ignite1.cluster().forRemotes()).send(null, "Message"); evtLatch.await(); log.info("Fail node: " + ignite1.cluster().localNode()); failNode(ignite1); <START> assert failLatch.await(ignite1.configuration().getFailureDetectionTimeout() + 50, MILLISECONDS); <END> }</code><technical_language>magic number</technical_language>

Target:
public void testFailFast() throws Exception { startGridsMultiThreaded(5); final CountDownLatch failLatch = new CountDownLatch(4); for (int i = 0; i < 5; i++) { ignite(i).events().localListen(new IgnitePredicate<Event>() { @Override public boolean apply(Event evt) { info(evt.shortDisplay()); failLatch.countDown(); return true; } }, EVT_NODE_FAILED); } Ignite ignite1 = ignite(0); Ignite ignite2 = ignite(1); final CountDownLatch evtLatch = new CountDownLatch(1); ignite1.message().localListen(null, new MessagingListenActor<Object>() { @Override protected void receive(UUID nodeId, Object rcvMsg) throws Throwable { respond(rcvMsg); } }); ignite2.message().localListen(null, new MessagingListenActor<Object>() { @Override protected void receive(UUID nodeId, Object rcvMsg) throws Throwable { evtLatch.countDown(); respond(rcvMsg); } }); ignite1.message(ignite1.cluster().forRemotes()).send(null, "Message"); evtLatch.await(); log.info("Fail node: " + ignite1.cluster().localNode()); failNode(ignite1); assert failLatch.await(1500, MILLISECONDS); }
Source:
<code>public void testSerializableInstantiation() { List<Command<?>> commands = new LinkedList<Command<?>>(); commands.add(KieServices.Factory.get().getCommands().newInsert(new SerializableWrapper("hello"))); <START> commands.add(KieServices.Factory.get().getCommands().newFireAllRules()); <END> for (int i = 0; i < 500; i++) { session.execute(KieServices.Factory.get().getCommands().newBatchExecution(commands)); } }</code><technical_language>Reuse code</technical_language>

Target:
public void testSerializableInstantiation() { session.setGlobal("LOGGER", LOGGER); List<Command<?>> commands = new LinkedList<Command<?>>(); commands.add(getCommands().newInsert(new SerializableWrapper("hello"))); commands.add(getCommands().newFireAllRules()); for (int i = 0; i < 500; i++) { session.execute(getCommands().newBatchExecution(commands)); } }
Source:
<code>private void copyUnknownFiles(File appDir, ZipOutputStream outputFile, Map<String, String> files, byte[] buffer) throws IOException { File unknownFileDir = new File(appDir, UNK_DIRNAME); for (Map.Entry<String,String> unknownFileInfo : files.entrySet()) { File inputFile = new File(unknownFileDir, unknownFileInfo.getKey()); if(inputFile.isDirectory()) { continue; } ZipEntry newEntry = new ZipEntry(unknownFileInfo.getKey()); int method = Integer.valueOf(unknownFileInfo.getValue()); LOGGER.fine(String.format("Copying unknown file %s with method %d", unknownFileInfo.getKey(), method)); if(method == ZipEntry.STORED) { newEntry.setMethod(ZipEntry.STORED); newEntry.setSize(inputFile.length()); newEntry.setCompressedSize(-1); BufferedInputStream unknownFile = new BufferedInputStream(new FileInputStream(inputFile)); CRC32 crc = calculateCrc(unknownFile, buffer); newEntry.setCrc(crc.getValue()); LOGGER.fine("\tsize: " + newEntry.getSize()); } <START> else { <END> newEntry.setMethod(ZipEntry.DEFLATED); } outputFile.putNextEntry(newEntry); BufferedInputStream unknownFile = new BufferedInputStream(new FileInputStream(inputFile)); copy(unknownFile, outputFile, buffer); outputFile.closeEntry(); } }</code><technical_language>newline, } else {</technical_language>

Target:
private void copyUnknownFiles(File appDir, ZipOutputStream outputFile, Map<String, String> files, byte[] buffer) throws IOException { File unknownFileDir = new File(appDir, UNK_DIRNAME); for (Map.Entry<String,String> unknownFileInfo : files.entrySet()) { File inputFile = new File(unknownFileDir, unknownFileInfo.getKey()); if(inputFile.isDirectory()) { continue; } ZipEntry newEntry = new ZipEntry(unknownFileInfo.getKey()); int method = Integer.valueOf(unknownFileInfo.getValue()); LOGGER.fine(String.format("Copying unknown file %s with method %d", unknownFileInfo.getKey(), method)); if(method == ZipEntry.STORED) { newEntry.setMethod(ZipEntry.STORED); newEntry.setSize(inputFile.length()); newEntry.setCompressedSize(-1); BufferedInputStream unknownFile = new BufferedInputStream(new FileInputStream(inputFile)); CRC32 crc = BrutIO.calculateCrc(unknownFile, buffer); newEntry.setCrc(crc.getValue()); LOGGER.fine("\tsize: " + newEntry.getSize()); } else { newEntry.setMethod(ZipEntry.DEFLATED); } outputFile.putNextEntry(newEntry); BufferedInputStream unknownFile = new BufferedInputStream(new FileInputStream(inputFile)); BrutIO.copy(unknownFile, outputFile, buffer); outputFile.closeEntry(); } }
Source:
<code>protected String callBridge(RestHttpHelper restHelper, String snapshotURL, String snapshotBody) throws Exception { log.info("Making SNAPSHOT call to URL with body {}", snapshotURL, snapshotBody); Map<String, String> headers = new HashMap<>(); headers.put(HttpHeaders.CONTENT_TYPE, "application/json"); RestHttpHelper.HttpResponse response = restHelper.put(snapshotURL, snapshotBody, headers); int statusCode = response.getStatusCode(); if(statusCode != 200 && statusCode != 201) { String message = response.getResponseBody(); try { <START> HashMap map = new JaxbJsonSerializer<HashMap>(HashMap.class).deserialize(message); <END> String m = (String)map.get("message"); if(m != null){ message = m; } } catch (IOException ex) if(statusCode == 409){ throw new ServerConflictException(message); }else { throw new RuntimeException(message + " (" + statusCode + ")"); } } return response.getResponseBody(); }</code><technical_language>this parsing of bridge response message generic enough live a higher level, if in another class, in method</technical_language>

Target:
protected String callBridge(RestHttpHelper restHelper, String snapshotURL, String snapshotBody) throws Exception { log.info("Making SNAPSHOT call to URL with body {}", snapshotURL, snapshotBody); Map<String, String> headers = new HashMap<>(); headers.put(HttpHeaders.CONTENT_TYPE, "application/json"); RestHttpHelper.HttpResponse response = restHelper.put(snapshotURL, snapshotBody, headers); int statusCode = response.getStatusCode(); if(statusCode != 200 && statusCode != 201) { String responseStr = response.getResponseBody(); try { String m = getMessageValue(responseStr); if(m != null){ responseStr = m; } } catch (IOException ex) { log.warn(ex.getMessage(), ex); } if(statusCode == 409){ throw new ServerConflictException(responseStr); }else { throw new RuntimeException(responseStr + " (" + statusCode + ")"); } } return response.getResponseBody(); }
Source:
<code>private void addEvents(TreeSet<Event> events) { if (distributed) { events = filterIncomingEventsForNode(events); } if (engineExtensions) { events = processEventsExtensions(events); } synchronized (pendingEvents) { if (log.isDebugEnabled()) { log.debugf("Adding [%s] to pendingEvents [%s]", events, pendingEvents); <START> } <END> pendingEvents.addAll(events); } }</code><technical_language>Same, remove wrapper</technical_language>

Target:
private void addEvents(TreeSet<Event> events) { if (distributed) { events = filterIncomingEventsForNode(events); } if (engineExtensions) { events = processEventsExtensions(events); } synchronized (pendingEvents) { log.debugf("Adding [%s] to pendingEvents [%s]", events, pendingEvents); pendingEvents.addAll(events); } }
Source:
<code>int calculatePosition(LocalDate startDate, LocalDate date) { int unadjusted = (int) DAYS.between(startDate, date); int weekendAdjustment = startDate.getDayOfWeek().compareTo(date.getDayOfWeek()) > 0 ? 1 : 0; <START> int numWeekends = unadjusted / 7 + weekendAdjustment; <END> return unadjusted - (2 * numWeekends); }</code><technical_language>Brackets this clearer (unadjusted / 7) + weekendAdjustment</technical_language>

Target:
int calculatePosition(LocalDate startDate, LocalDate date) { int unadjusted = (int) DAYS.between(startDate, date); int weekendAdjustment = startDate.getDayOfWeek().compareTo(date.getDayOfWeek()) > 0 ? 1 : 0; int numWeekends = (unadjusted / 7) + weekendAdjustment; return unadjusted - (2 * numWeekends); }
Source:
<code>private Map<String, Object> getForcedMetaDataMap(final File binFile, final Set<String> metadataFields, final int maxLength) { if (!osgiInitialized) { Logger.error(this.getClass(), "Unable to get file Meta Data, OSGI Framework not initialized"); return Collections.emptyMap(); } final Map<String, Object> metaMap = new TreeMap<>(); this.tikaService.setMaxStringLength(maxLength); try (InputStream stream = Files.newInputStream(binFile.toPath())) { final String content = this.tikaService.parseToString(stream); metaMap.putAll(this.buildMetaDataMap()); metaMap.put(FileAssetAPI.CONTENT_FIELD, content); } catch (IOException ioExc) { if (this.isZeroByteFileException(ioExc.getCause())) { logWarning(binFile, ioExc.getCause()); } else { final String errorMessage = String .format("Error Reading Tika parsed Stream for file [%s] [%s] ", binFile.getAbsolutePath(), UtilMethods.isSet(ioExc.getMessage()) ? ioExc.getMessage() : ioExc.getCause().getMessage()); <START> Logger.warn(this.getClass(), errorMessage); <END> Logger.debug(this.getClass(), errorMessage, ioExc); } } catch (Throwable e) { if (this.isZeroByteFileException(e)) { logWarning(binFile, e); } else { logError(binFile, e); } } finally { metaMap.put("length", binFile.length()); } this.filterMetadataFields(metaMap, metadataFields); return metaMap; }</code><technical_language>Logger.warnAndDebug method instead</technical_language>

Target:
private Map<String, Object> getForcedMetaDataMap(final File binFile, final Set<String> metadataFields, final int maxLength) { if (!osgiInitialized) { Logger.error(this.getClass(), "Unable to get file Meta Data, OSGI Framework not initialized"); return Collections.emptyMap(); } final Map<String, Object> metaMap = new TreeMap<>(); this.tikaService.setMaxStringLength(maxLength); try (InputStream stream = Files.newInputStream(binFile.toPath())) { final String content = this.tikaService.parseToString(stream); metaMap.putAll(this.buildMetaDataMap()); metaMap.put(FileAssetAPI.CONTENT_FIELD, content); } catch (IOException ioExc) { if (this.isZeroByteFileException(ioExc.getCause())) { logWarning(binFile, ioExc.getCause()); } else { final String errorMessage = String .format("Error Reading Tika parsed Stream for file [%s] [%s] ", binFile.getAbsolutePath(), UtilMethods.isSet(ioExc.getMessage()) ? ioExc.getMessage() : ioExc.getCause().getMessage()); Logger.warnAndDebug(this.getClass(), ioExc); } } catch (Throwable e) { if (this.isZeroByteFileException(e)) { logWarning(binFile, e); } else { logError(binFile, e); } } finally { metaMap.put("length", binFile.length()); } this.filterMetadataFields(metaMap, metadataFields); return metaMap; }
Source:
<code>public void singleItemVndErrorShouldDeserialize() throws IOException { String json = read(new ClassPathResource("vnderror-single-item.json")); VndError error = new VndError("Validation failed", "/username", 42, new Link("<LINK_2>", VndErrors.REL_ABOUT), new Link("<LINK_4>", VndErrors.REL_DESCRIBES), new Link("<LINK_3>", VndErrors.REL_HELP)); <START> assertThat(mapper.readValue(json, VndError.class)).isEqualTo(error); <END> }</code><technical_language>I if isEqualToIgnoringWhitespace in this similar tests</technical_language>

Target:
public void singleItemVndErrorShouldDeserialize() throws IOException { String json = read(new ClassPathResource("vnderror-single-item.json")); VndError error = new VndError("Validation failed", "/username", 42, new Link("<LINK_5>", VndErrors.REL_ABOUT), new Link("<LINK_0>", VndErrors.REL_DESCRIBES), new Link("<LINK_1>", VndErrors.REL_HELP)); assertThat(mapper.readValue(json, VndError.class)).isEqualTo(error); }
Source:
<code>void putTicket() { <START> assertDoesNotThrow(() -> imageioClient.putTicket(imageTicket)); <END> }</code><technical_language>Test socket exist</technical_language>

Target:
void putTicket() { assertDoesNotThrow(() -> imageioClient.putTicket(imageTicket)); ImageTicketInformation ticket = imageioClient.getTicket(imageTicket.getId()); assertEquals(imageTicket.getId(), ticket.getId()); }
Source:
<code>public void createTableIfDoesNotExist() { <START> helper.createTableIfDoesNotExist(prefixedTimestampTableName()); <END> }</code><technical_language>nit: mention this time, initializer is more accurate</technical_language>

Target:
public void createTableIfDoesNotExist() { try (Connection conn = connManager.getConnection()) { createTimestampTable(conn); } catch (SQLException error) { throw PalantirSqlException.create(error); } }
Source:
<code>private String findQueryIDByQueryString(String query) { return study.getSearchQueryEntries() .parallelStream() <START> .filter(bibEntry -> bibEntry.getField(new UnknownField("query")).orElse("").equals(query)) <END> .map(BibEntry::getCitationKey) .filter(Optional::isPresent) .map(Optional::get) .findFirst() .orElseThrow() .replaceFirst("query", ""); }</code><technical_language>extract constant</technical_language>

Target:
private String findQueryIDByQueryString(String query) { String queryField = "query"; return study.getSearchQueryEntries() .parallelStream() .filter(bibEntry -> bibEntry.getField(new UnknownField(queryField)).orElse("").equals(query)) .map(BibEntry::getCitationKey) .filter(Optional::isPresent) .map(Optional::get) .findFirst() .orElseThrow() .replaceFirst(queryField, ""); }
Source:
<code>protected void invokeErrorHandler(Throwable ex) { if (this.errorHandler != null) { this.errorHandler.handleError(ex); } else if (logger.isDebugEnabled()) { logger.warn("Execution of Rabbit message listener failed, and no ErrorHandler has been set.", ex); <START> } else if (logger.isInfoEnabled()) { <END> logger.warn("Execution of Rabbit message listener failed, and no ErrorHandler has been set: " + ex.getClass() + ": " + ex.getMessage()); } }</code><technical_language>log warn testing for isInfoEnabled (or isDebugEnabled). log level if test. simply replace a single if (logger.isWarnEnabled() { logger.warn(...., ex); } (See JMS AMLC)</technical_language>

Target:
protected void invokeErrorHandler(Throwable ex) { if (this.errorHandler != null) { this.errorHandler.handleError(ex); } else if (logger.isWarnEnabled()) { logger.warn("Execution of Rabbit message listener failed, and no ErrorHandler has been set.", ex); } }
Source:
<code>private void showToastAndClose(int error) { Toast.makeText(loginActivity, error, Toast.LENGTH_LONG).show(); <START> Thread thread = new Thread(){ <END> @Override public void run() { try { Thread.sleep(3500); onBackPressed(); } catch (Exception e) { e.printStackTrace(); } } }; thread.start(); }</code><technical_language>for this purpose a handler postDelayed function</technical_language>

Target:
private void showToastAndClose(int error) { Toast.makeText(loginActivity, error, Toast.LENGTH_LONG).show(); Runnable runnable = new Runnable() { @Override public void run() { loginActivity.onBackPressed(); } }; new Handler().postDelayed(runnable, 3500); }
Source:
<code>public void invalidFileShouldFail() throws Exception { ExecutionContext executionContext = MetaDataInstanceFactory.createStepExecution().getExecutionContext(); final String inputFilePath = "/wrong_no_alt.vcf.gz"; String inputFile = VcfReaderTest.class.getResource(inputFilePath).getFile(); String fileId = "5"; String studyId = "7"; String studyName = "study name"; VariantSource source = new VariantSource(inputFile, fileId, studyId, studyName, VariantStudy.StudyType.COLLECTION, VariantSource.Aggregation.NONE); VcfReader vcfReader = new VcfReader(source, inputFile); vcfReader.setSaveState(false); vcfReader.open(executionContext); exception.expect(FlatFileParseException.class); while (vcfReader.read() != null) { <START> } <END> }</code><technical_language>empty loop written while (vcfReader.read() != null);</technical_language>

Target:
public void invalidFileShouldFail() throws Exception { ExecutionContext executionContext = MetaDataInstanceFactory.createStepExecution().getExecutionContext(); final String inputFilePath = "/wrong_no_alt.vcf.gz"; String inputFile = VcfReaderTest.class.getResource(inputFilePath).getFile(); String fileId = "5"; String studyId = "7"; String studyName = "study name"; VcfHeaderReader headerReader = new VcfHeaderReader(new File(inputFile), fileId, studyId, studyName, VariantStudy.StudyType.COLLECTION, VariantSource.Aggregation.NONE); VariantSource source = headerReader.read(); VcfReader vcfReader = new VcfReader(source, inputFile); vcfReader.setSaveState(false); vcfReader.open(executionContext); exception.expect(FlatFileParseException.class); while (vcfReader.read() != null) { } }
Source:
<code>public void testEmptyNodeSelectionStrategyConfig() { ConnectorSession connectorSession = new TestingConnectorSession( new HiveSessionProperties( new HiveClientConfig(), new OrcFileWriterConfig(), new ParquetFileWriterConfig()).getSessionProperties()); <START> assertEquals(getNodeSelectionStrategy(connectorSession), NodeSelectionStrategy.NO_PREFERENCE); <END> }</code><technical_language>static import</technical_language>

Target:
public void testEmptyNodeSelectionStrategyConfig() { ConnectorSession connectorSession = new TestingConnectorSession( new HiveSessionProperties( new HiveClientConfig(), new OrcFileWriterConfig(), new ParquetFileWriterConfig()).getSessionProperties()); assertEquals(getNodeSelectionStrategy(connectorSession), NO_PREFERENCE); }
Source:
<code>public SAMSequenceDictionary getSequenceDictionary() { final List<VCFContigHeaderLine> contigHeaderLines = this.getContigLines(); if (contigHeaderLines.isEmpty()) return null; final List<SAMSequenceRecord> sequenceRecords = new ArrayList<SAMSequenceRecord>(contigHeaderLines.size()); for (final VCFContigHeaderLine contigHeaderLine : contigHeaderLines) { final SAMSequenceRecord samSequenceRecord = contigHeaderLine.getSAMSequenceRecord(); <START> if (samSequenceRecord == null) return null; <END> sequenceRecords.add(samSequenceRecord); } return new SAMSequenceDictionary(sequenceRecords); }</code><technical_language>do end nulls here? returning lines UNKNOWN_SEQUENCE_LENGTH</technical_language>

Target:
public SAMSequenceDictionary getSequenceDictionary() { final List<VCFContigHeaderLine> contigHeaderLines = this.getContigLines(); if (contigHeaderLines.isEmpty()) return null; final List<SAMSequenceRecord> sequenceRecords = new ArrayList<SAMSequenceRecord>(contigHeaderLines.size()); for (final VCFContigHeaderLine contigHeaderLine : contigHeaderLines) { final SAMSequenceRecord samSequenceRecord = contigHeaderLine.getSAMSequenceRecord(); sequenceRecords.add(samSequenceRecord); } return new SAMSequenceDictionary(sequenceRecords); }
Source:
<code>protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { if(mouseButton == 0) { mouseX -= guiLeft; mouseY -= guiTop; if(8 <= mouseX && mouseX < 114 && 16 <= mouseY && mouseY < 122) { SmelteryTank tank = tinkerTank.getTank(); int[] heights = calcLiquidHeights(tank.getFluids(), tank.getCapacity()); int y = 122 - mouseY - 1; <START> for(int i = 0; i < heights.length; i++) { <END> if(y < heights[i]) { TinkerNetwork.sendToServer(new SmelteryFluidClicked(i)); return; } y -= heights[i]; } } mouseX += guiLeft; mouseY += guiTop; } super.mouseClicked(mouseX, mouseY, mouseButton); }</code><technical_language>Duplicate code</technical_language>

Target:
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { if(mouseButton == 0) { GuiUtil.handleTankClick(tinkerTank.getTank(), mouseX - guiLeft, mouseY - guiTop, 8, 16, 114, 122); } super.mouseClicked(mouseX, mouseY, mouseButton); }
Source:
<code>private void fillReleaseBulletList(XWPFDocument document, Collection<LicenseInfoParsingResult> projectLicenseInfoResults) throws XmlException { List<String> releaseList = new ArrayList<>(); for (LicenseInfoParsingResult result : projectLicenseInfoResults) { <START> releaseList.add(nullToEmptyString(result.getName()) + " " + nullToEmptyString(result.getVersion())); <END> } addBulletList(document, releaseList, true); addPageBreak(document.createParagraph().createRun()); }</code><technical_language>I thougt a function print string</technical_language>

Target:
private void fillReleaseBulletList(XWPFDocument document, Collection<LicenseInfoParsingResult> projectLicenseInfoResults) throws XmlException { List<String> releaseList = new ArrayList<>(); for (LicenseInfoParsingResult result : projectLicenseInfoResults) { releaseList.add(getComponentLongName(result)); } addBulletList(document, releaseList, true); addPageBreak(document); }
Source:
<code>public static void startWatchDog() { try { WatchDogLogger.getInstance().logInfo("Starting WatchDog ..."); InitializationManager.getInstance(); WatchDogGlobals.isActive = true; UIUtils.refreshCommand(UIUtils.COMMAND_SHOW_INFO); updateView(); } catch (Exception exception) { <START> exception.printStackTrace(); <END> WatchDogLogger.getInstance() .logSevere("Caught sever exception on top-level: "); WatchDogLogger.getInstance().logSevere(exception); } }</code><technical_language>want stdout cluttered. this in log</technical_language>

Target:
public static void startWatchDog() { try { WatchDogLogger.getInstance().logInfo("Starting WatchDog ..."); InitializationManager.getInstance(); WatchDogGlobals.isActive = true; UIUtils.refreshCommand(UIUtils.COMMAND_SHOW_INFO); updateView(); } catch (Exception exception) { WatchDogLogger.getInstance() .logSevere("Caught sever exception on top-level: "); WatchDogLogger.getInstance().logSevere(exception); } }
Source:
<code>public boolean hasEmptyInputsMapping(String elementId) { ProcessVariablesMapping processVariablesMapping = mappings.get(elementId); ProcessConstantsMapping processConstantsMapping = constants.get(elementId); <START> return (processVariablesMapping != null && processVariablesMapping.getInputs().size() == 0) && <END> (processConstantsMapping != null && processConstantsMapping.size() == 0); }</code><technical_language>Constants included there: this method is if send of process variables task. want do mappings section is empty, constant is empty</technical_language>

Target:
public boolean hasEmptyInputsMapping(String elementId) { ProcessVariablesMapping processVariablesMapping = mappings.get(elementId); return processVariablesMapping != null && processVariablesMapping.getInputs().size() == 0; }
Source:
<code>public void writeObject(ObjectOutput output, Q object) throws IOException { if (object.getQueryString().isPresent()) { output.writeBoolean(true); output.writeUTF(object.getQueryString().get()); } else { output.writeBoolean(false); <START> output.writeObject(object.getHsQuery(null)); <END> } output.writeInt(object.getFirstResult()); output.writeInt(object.getMaxResults()); output.writeObject(object.getSortableFields()); output.writeObject(object.getIndexedType()); Map<String, Object> namedParameters = object.getNamedParameters(); int size = namedParameters.size(); output.writeShort(size); for (Map.Entry<String, Object> param : namedParameters.entrySet()) { output.writeUTF(param.getKey()); output.writeObject(param.getValue()); } }</code><technical_language>I understand this work null cache parameter</technical_language>

Target:
public void writeObject(ObjectOutput output, Q object) throws IOException { if (object.getQueryString().isPresent()) { output.writeBoolean(true); output.writeUTF(object.getQueryString().get()); } else { output.writeBoolean(false); output.writeObject(object.getHsQuery()); } output.writeInt(object.getFirstResult()); output.writeInt(object.getMaxResults()); output.writeObject(object.getSortableFields()); output.writeObject(object.getIndexedType()); Map<String, Object> namedParameters = object.getNamedParameters(); int size = namedParameters.size(); output.writeShort(size); for (Map.Entry<String, Object> param : namedParameters.entrySet()) { output.writeUTF(param.getKey()); output.writeObject(param.getValue()); } }
Source:
<code>public static List<String> listXAttr(String path) { <START> long bufferLength = XAttr.INSTANCE.listxattr(path, Pointer.NULL, 0, 0); <END> if (bufferLength < 0) return null; if (bufferLength == 0) return new ArrayList<String>(0); Memory valueBuffer = new Memory(bufferLength); long valueLength = XAttr.INSTANCE.listxattr(path, valueBuffer, bufferLength, 0); if (valueLength < 0) return null; return decodeStringSequence(valueBuffer.getByteBuffer(0, valueLength)); }</code><technical_language>I generally prefer null instead of Pointer.NULL. I remove definition altogether, deprecate it</technical_language>

Target:
public static List<String> listXAttr(String path) { long bufferLength = XAttr.INSTANCE.listxattr(path, null, 0, 0); if (bufferLength < 0) return null; if (bufferLength == 0) return new ArrayList<String>(0); Memory valueBuffer = new Memory(bufferLength); long valueLength = XAttr.INSTANCE.listxattr(path, valueBuffer, bufferLength, 0); if (valueLength < 0) return null; return decodeStringSequence(valueBuffer.getByteBuffer(0, valueLength)); }
Source:
<code>public void testAttributeHitsAndOwnedEntryCountUpdatedAfterInterval() throws Exception { String firstKey = "firstKey"; String secondKey = "secondKey"; replicatedMap.put(firstKey, "firstValue"); replicatedMap.get(firstKey); final String localHitsName = "localHits"; final String localOwnedEntryCountName = "localOwnedEntryCount"; long localHits = getLongAttribute(localHitsName); long localEntryCount = getLongAttribute(localOwnedEntryCountName); replicatedMap.get(firstKey); replicatedMap.put(secondKey, "secondValue"); long localHitsNotUpdated = getLongAttribute(localHitsName); long localEntryCountNotUpdated = getLongAttribute(localOwnedEntryCountName); assertEquals(1, localHits); assertEquals(1, localHitsNotUpdated); assertEquals(1, localEntryCount); assertEquals(1, localEntryCountNotUpdated); <START> assertTrueDelayed(1, new AssertTask() { <END> @Override public void run() throws Exception { assertEquals(2, getLongAttribute(localHitsName).longValue()); assertEquals(2, getLongAttribute(localOwnedEntryCountName).longValue()); } }); }</code><technical_language>assertTrueDelayed wake thread slightly earlier expected AFAIK. test failed 4 out 100 times local machine. want give some extra milliseconds actual update time lastUpdated in LocalStatsDelegate differ slightly. sleepAtLeastMillis(int) ensure a amount of time passes</technical_language>

Target:
public void testAttributeHitsAndOwnedEntryCountUpdatedAfterInterval() throws Exception { String firstKey = "firstKey"; String secondKey = "secondKey"; replicatedMap.put(firstKey, "firstValue"); replicatedMap.get(firstKey); final String localHitsName = "localHits"; final String localOwnedEntryCountName = "localOwnedEntryCount"; long localHits = getLongAttribute(localHitsName); long localEntryCount = getLongAttribute(localOwnedEntryCountName); replicatedMap.get(firstKey); replicatedMap.put(secondKey, "secondValue"); long localHitsNotUpdated = getLongAttribute(localHitsName); long localEntryCountNotUpdated = getLongAttribute(localOwnedEntryCountName); assertEquals(1, localHits); assertEquals(1, localHitsNotUpdated); assertEquals(1, localEntryCount); assertEquals(1, localEntryCountNotUpdated); sleepAtLeastSeconds(1); assertTrueEventually(new AssertTask() { @Override public void run() throws Exception { assertEquals(2, getLongAttribute(localHitsName).longValue()); assertEquals(2, getLongAttribute(localOwnedEntryCountName).longValue()); } }); }