auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private SaxEventToXmlElementConverter startConstructingElement( String uri, String localName, Attributes atts) throws XMLStreamException { Multimap<String, String> addedNamespaces = ArrayListMultimap.create(); if (scopeOfNamespacesAdded.peek() != null) { addedNamespaces.putAll(scopeOfNamespacesAdded.peek()); } scopeOfNamespacesAdded.push(addedNamespaces); Map<String, String> scopedNamespaces = new HashMap<>(); Iterator<NamespaceMapping> iter = namespaceStack.descendingIterator(); while (iter.hasNext()) { NamespaceMapping tmpPair = iter.next(); scopedNamespaces.put(tmpPair.getUri(), tmpPair.getPrefix()); } out.writeStartElement(scopedNamespaces.get(uri), localName, uri); if (!checkNamespaceAdded(uri, scopedNamespaces)) { out.writeNamespace(scopedNamespaces.get(uri), uri); addedNamespaces.put(uri, scopedNamespaces.get(uri)); } for (int i = 0; i < atts.getLength(); i++) { if (atts.getURI(i).isEmpty()) { out.writeAttribute(atts.getLocalName(i), atts.getValue(i)); } else { String attUri = atts.getURI(i); if (!checkNamespaceAdded(attUri, scopedNamespaces)) { out.writeNamespace(scopedNamespaces.get(attUri), attUri); addedNamespaces.put(attUri, scopedNamespaces.get(attUri)); } try { out.writeAttribute( scopedNamespaces.get(attUri), attUri, atts.getLocalName(i), atts.getValue(i)); } catch (XMLStreamException e) { Optional<String> altNs = namespaceStack .stream() .filter(p -> attUri.equals(p.getUri()) && !(p.getPrefix().isEmpty())) .map(NamespaceMapping::getPrefix) .findFirst(); if (altNs.isPresent()) { out.writeNamespace(altNs.get(), attUri); addedNamespaces.put(attUri, altNs.get()); out.writeAttribute(altNs.get(), attUri, atts.getLocalName(i), atts.getValue(i)); } } } } return this; }

Target:
private SaxEventToXmlElementConverter startConstructingElement( String uri, String localName, Attributes atts) throws XMLStreamException { Multimap<String, String> addedNamespaces = ArrayListMultimap.create(); if (scopeOfNamespacesAdded.peek() != null) { addedNamespaces.putAll(scopeOfNamespacesAdded.peek()); } scopeOfNamespacesAdded.push(addedNamespaces); Map<String, String> scopedNamespaces = new HashMap<>(); Iterator<NamespaceMapping> iter = namespaceStack.descendingIterator(); while (iter.hasNext()) { NamespaceMapping tmpPair = iter.next(); scopedNamespaces.put(tmpPair.getUri(), tmpPair.getPrefix()); } out.writeStartElement(scopedNamespaces.get(uri), localName, uri); if (!checkNamespaceAdded(uri, scopedNamespaces)) { out.writeNamespace(scopedNamespaces.get(uri), uri); addedNamespaces.put(uri, scopedNamespaces.get(uri)); } for (int i = 0; i < atts.getLength(); i++) { if (atts.getURI(i).isEmpty()) { out.writeAttribute(atts.getLocalName(i), atts.getValue(i)); } else { String attUri = atts.getURI(i); if (!checkNamespaceAdded(attUri, scopedNamespaces)) { out.writeNamespace(scopedNamespaces.get(attUri), attUri); addedNamespaces.put(attUri, scopedNamespaces.get(attUri)); } try { out.writeAttribute( scopedNamespaces.get(attUri), attUri, atts.getLocalName(i), atts.getValue(i)); } catch (XMLStreamException e) { handleNamespaceDupes(atts, addedNamespaces, i, attUri); } } } return this; }
Source:
public UserAuthenticatedEvent() { }

Target:
public UserAuthenticatedEvent() { super(); }
Source:
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; } 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; }

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:
public ValidationResult validate(Object value) { Long longValue = null; ValidationResult res = new ValidationResult(); 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) { } } if (longValue == null || longValue < 0) { res.setSuccess(false); res.getReasons().add(ConstantsManager.getInstance() .getConstants().thisFieldMustContainNonNegativeIntegerNumberInvalidReason()); } return res; }

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:
private void updateActionAvailability(GlusterVolumeEntity volumeEntity) { boolean allowStartSessionCommand = false; boolean allowStopSessionCommand = false; boolean allowResumeSessionCommand = false; boolean allowPauseSessionCommand = false; if(volumeEntity == null) { return; } if (getSelectedItem() == null) { allowStartSessionCommand = false; allowStopSessionCommand = false; allowResumeSessionCommand = false; allowPauseSessionCommand = false; } else if(getSelectedItems().size() == 1) { GlusterGeoRepSession selectedSession = (GlusterGeoRepSession)getSelectedItem(); GeoRepSessionStatus sessionStatus = selectedSession.getStatus(); allowStartSessionCommand = sessionStatus == GeoRepSessionStatus.NOTSTARTED || sessionStatus == GeoRepSessionStatus.STOPPED; allowStopSessionCommand = !allowStartSessionCommand; allowResumeSessionCommand = sessionStatus == GeoRepSessionStatus.PAUSED; allowPauseSessionCommand = sessionStatus == GeoRepSessionStatus.ACTIVE; } else { allowStartSessionCommand = false; } getNewSessionCommand().setIsAvailable(true); getRemoveSessionCommand().setIsAvailable(false); getStartSessionCommand().setIsExecutionAllowed(allowStartSessionCommand); getStopSessionCommand().setIsExecutionAllowed(allowStopSessionCommand); getPauseSessionCommand().setIsExecutionAllowed(allowPauseSessionCommand); getResumeSessionCommand().setIsExecutionAllowed(allowResumeSessionCommand); getSessionOptionsCommand().setIsExecutionAllowed(true); getViewSessionDetailsCommand().setIsAvailable(false); getRefreshSessionsCommand().setIsAvailable(true); }

Target:
private void updateActionAvailability(GlusterVolumeEntity volumeEntity) { boolean allowStartSessionCommand = false; boolean allowStopSessionCommand = false; boolean allowResumeSessionCommand = false; boolean allowPauseSessionCommand = false; if(volumeEntity == null) { return; } if (getSelectedItem() == null) { allowStartSessionCommand = false; allowStopSessionCommand = false; allowResumeSessionCommand = false; allowPauseSessionCommand = false; } else if(getSelectedItems().size() == 1) { GlusterGeoRepSession selectedSession = (GlusterGeoRepSession)getSelectedItem(); GeoRepSessionStatus sessionStatus = selectedSession.getStatus(); allowStartSessionCommand = sessionStatus == GeoRepSessionStatus.NOTSTARTED || sessionStatus == GeoRepSessionStatus.STOPPED; allowStopSessionCommand = !allowStartSessionCommand; allowResumeSessionCommand = sessionStatus == GeoRepSessionStatus.PAUSED; allowPauseSessionCommand = sessionStatus == GeoRepSessionStatus.ACTIVE; } getNewSessionCommand().setIsAvailable(true); getRemoveSessionCommand().setIsAvailable(false); getStartSessionCommand().setIsExecutionAllowed(allowStartSessionCommand); getStopSessionCommand().setIsExecutionAllowed(allowStopSessionCommand); getPauseSessionCommand().setIsExecutionAllowed(allowPauseSessionCommand); getResumeSessionCommand().setIsExecutionAllowed(allowResumeSessionCommand); getSessionOptionsCommand().setIsExecutionAllowed(true); getViewSessionDetailsCommand().setIsAvailable(false); getRefreshSessionsCommand().setIsAvailable(true); }
Source:
protected boolean set(TileEntityFurnace container, Integer value) { container.setField(0, container.getField(1) - value); return true; }

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:
public void paint(final RenderContext renderContext) { boolean doTransform = Config.getInstance().getBoolean(PARAMETERS_KEY, false); 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"); }

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:
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; } } } return false; } return delegate.hasChildren(childType); }

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:
public void start() { LOG.info("Started"); }

Target:
public void start() { LOG.info("FileConnector started"); }
Source:
public List<AbstractContainer> getContainers() { return Collections.unmodifiableList(containers); }

Target:
public List<AbstractContainer> getContainers() { return containers; }
Source:
private Space(String enumeratedValue) { this.enumeratedValue = enumeratedValue; }

Target:
Space(String enumeratedValue) { this.enumeratedValue = enumeratedValue; }
Source:
public void setGenerateTestResultAttributes(final Boolean generateTestResultAttributes) { m_generateTestResultAttributes = generateTestResultAttributes; }

Target:
public void setGenerateTestResultAttributes(final Boolean generateTestResultAttributes) { m_generateTestResultAttributes = generateTestResultAttributes != null ? generateTestResultAttributes : false; }
Source:
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()), kv(GATEWAY_ACCOUNT_ID, chargeEventEntity.getChargeEntity().getGatewayAccount().getId()), kv("from_state", fromChargeState), kv("to_state", targetChargeState)); eventService.recordOfferedEvent(ResourceType.PAYMENT, externalId, Event.eventTypeForClass(eventClass), chargeEventEntity.getUpdated() ); }); }

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:
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.getTableViewer().setInput(fSymbolProvider.getMappingFiles()); }

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:
public Resource getResource() { return getResource(null); }

Target:
public Resource getResource() { return resource; }
Source:
public void forget(Xid xid) throws XAException { System.out.println("[" + Thread.currentThread().getName() + "] DummyXAResource (" + serverId + ") XA_FORGET[" + xid + "]"); }

Target:
public void forget(Xid xid) throws XAException { }
Source:
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); boolean isArgument = skipParentheses(typeCastTree.parent()).is(Tree.Kind.ARGUMENTS); if (target != null && (isRedundantNumericalCast(cast, expressionType) || isUnnecessarySubtypeCast(expressionType, typeCastTree, target, isArgument))) { reportIssue(typeCastTree.type(), "Remove this unnecessary cast to \"" + cast.erasure() + "\"."); } }

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:
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); }

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:
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); }

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:
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(ignite1.configuration().getFailureDetectionTimeout() + 50, MILLISECONDS); }

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:
public void testSerializableInstantiation() { List<Command<?>> commands = new LinkedList<Command<?>>(); commands.add(KieServices.Factory.get().getCommands().newInsert(new SerializableWrapper("hello"))); commands.add(KieServices.Factory.get().getCommands().newFireAllRules()); for (int i = 0; i < 500; i++) { session.execute(KieServices.Factory.get().getCommands().newBatchExecution(commands)); } }

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:
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()); } else { newEntry.setMethod(ZipEntry.DEFLATED); } outputFile.putNextEntry(newEntry); BufferedInputStream unknownFile = new BufferedInputStream(new FileInputStream(inputFile)); copy(unknownFile, outputFile, buffer); outputFile.closeEntry(); } }

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:
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 { HashMap map = new JaxbJsonSerializer<HashMap>(HashMap.class).deserialize(message); 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(); }

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:
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); } pendingEvents.addAll(events); } }

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:
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); }

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:
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.warn(this.getClass(), errorMessage); 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; }

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:
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)); assertThat(mapper.readValue(json, VndError.class)).isEqualTo(error); }

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:
void putTicket() { assertDoesNotThrow(() -> imageioClient.putTicket(imageTicket)); }

Target:
void putTicket() { assertDoesNotThrow(() -> imageioClient.putTicket(imageTicket)); ImageTicketInformation ticket = imageioClient.getTicket(imageTicket.getId()); assertEquals(imageTicket.getId(), ticket.getId()); }
Source:
public void createTableIfDoesNotExist() { helper.createTableIfDoesNotExist(prefixedTimestampTableName()); }

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

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:
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); } else if (logger.isInfoEnabled()) { logger.warn("Execution of Rabbit message listener failed, and no ErrorHandler has been set: " + ex.getClass() + ": " + ex.getMessage()); } }

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:
private void showToastAndClose(int error) { Toast.makeText(loginActivity, error, Toast.LENGTH_LONG).show(); Thread thread = new Thread(){ @Override public void run() { try { Thread.sleep(3500); onBackPressed(); } catch (Exception e) { e.printStackTrace(); } } }; thread.start(); }

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:
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) { } }

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:
public void testEmptyNodeSelectionStrategyConfig() { ConnectorSession connectorSession = new TestingConnectorSession( new HiveSessionProperties( new HiveClientConfig(), new OrcFileWriterConfig(), new ParquetFileWriterConfig()).getSessionProperties()); assertEquals(getNodeSelectionStrategy(connectorSession), NodeSelectionStrategy.NO_PREFERENCE); }

Target:
public void testEmptyNodeSelectionStrategyConfig() { ConnectorSession connectorSession = new TestingConnectorSession( new HiveSessionProperties( new HiveClientConfig(), new OrcFileWriterConfig(), new ParquetFileWriterConfig()).getSessionProperties()); assertEquals(getNodeSelectionStrategy(connectorSession), NO_PREFERENCE); }
Source:
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(); if (samSequenceRecord == null) return null; sequenceRecords.add(samSequenceRecord); } return new SAMSequenceDictionary(sequenceRecords); }

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:
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; for(int i = 0; i < heights.length; i++) { if(y < heights[i]) { TinkerNetwork.sendToServer(new SmelteryFluidClicked(i)); return; } y -= heights[i]; } } mouseX += guiLeft; mouseY += guiTop; } super.mouseClicked(mouseX, mouseY, mouseButton); }

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:
private void fillReleaseBulletList(XWPFDocument document, Collection<LicenseInfoParsingResult> projectLicenseInfoResults) throws XmlException { List<String> releaseList = new ArrayList<>(); for (LicenseInfoParsingResult result : projectLicenseInfoResults) { releaseList.add(nullToEmptyString(result.getName()) + " " + nullToEmptyString(result.getVersion())); } addBulletList(document, releaseList, true); addPageBreak(document.createParagraph().createRun()); }

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:
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) { exception.printStackTrace(); WatchDogLogger.getInstance() .logSevere("Caught sever exception on top-level: "); WatchDogLogger.getInstance().logSevere(exception); } }

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:
public boolean hasEmptyInputsMapping(String elementId) { ProcessVariablesMapping processVariablesMapping = mappings.get(elementId); ProcessConstantsMapping processConstantsMapping = constants.get(elementId); return (processVariablesMapping != null && processVariablesMapping.getInputs().size() == 0) && (processConstantsMapping != null && processConstantsMapping.size() == 0); }

Target:
public boolean hasEmptyInputsMapping(String elementId) { ProcessVariablesMapping processVariablesMapping = mappings.get(elementId); return processVariablesMapping != null && processVariablesMapping.getInputs().size() == 0; }
Source:
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(null)); } 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()); } }

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:
public static List<String> listXAttr(String path) { long bufferLength = XAttr.INSTANCE.listxattr(path, Pointer.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)); }

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:
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); assertTrueDelayed(1, new AssertTask() { @Override public void run() throws Exception { assertEquals(2, getLongAttribute(localHitsName).longValue()); assertEquals(2, getLongAttribute(localOwnedEntryCountName).longValue()); } }); }

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()); } }); }
Source:
public Result(List<MetricComparison> metricComparisons) { Preconditions.checkArgument(metricComparisons.isEmpty(), "No metric "); this.metricComparisons = ImmutableList.copyOf(metricComparisons); }

Target:
public Result(List<MetricComparison> metricComparisons) { checkArgument(!metricComparisons.isEmpty(), "No metric comparisons given"); this.metricComparisons = ImmutableList.copyOf(metricComparisons); }