List of usage examples for java.util.concurrent.atomic AtomicBoolean AtomicBoolean
public AtomicBoolean(boolean initialValue)
From source file:org.eclipse.hono.deviceregistry.FileBasedCredentialsService.java
/** * Get the credentials associated with the authId and the given type. * If type is null, all credentials associated with the authId are returned (as JsonArray inside the return value). * * @param tenantId The id of the tenant the credentials belong to. * @param authId The authentication identifier to look up credentials for. * @param type The type of credentials to look up. * @return The credentials object of the given type or {@code null} if no matching credentials exist. *//*from w ww . jav a 2 s .c o m*/ private JsonObject getSingleCredentials(final String tenantId, final String authId, final String type, final JsonObject clientContext) { Objects.requireNonNull(tenantId); Objects.requireNonNull(authId); Objects.requireNonNull(type); final Map<String, JsonArray> credentialsForTenant = credentials.get(tenantId); if (credentialsForTenant != null) { final JsonArray authIdCredentials = credentialsForTenant.get(authId); if (authIdCredentials != null) { for (final Object authIdCredentialEntry : authIdCredentials) { final JsonObject authIdCredential = (JsonObject) authIdCredentialEntry; // return the first matching type entry for this authId if (type.equals(authIdCredential.getString(CredentialsConstants.FIELD_TYPE))) { if (clientContext != null) { final AtomicBoolean match = new AtomicBoolean(true); clientContext.forEach(field -> { if (authIdCredential.containsKey(field.getKey())) { if (!authIdCredential.getString(field.getKey()).equals(field.getValue())) { match.set(false); } } else { match.set(false); } }); if (!match.get()) { continue; } } return authIdCredential; } } } } return null; }
From source file:com.adaptris.core.ftp.FtpConsumerTest.java
public void testConsumeWithQuietPeriodAndTimezone() throws Exception { int count = 1; EmbeddedFtpServer helper = new EmbeddedFtpServer(); MockMessageListener listener = new MockMessageListener(100); FileSystem filesystem = helper.createFilesystem_DirsOnly(); for (int i = 0; i < count; i++) { filesystem.add(//from w w w.j a v a 2 s .co m new FileEntry(DEFAULT_WORK_DIR_CANONICAL + SLASH + DEFAULT_FILENAME + i + ".txt", PAYLOAD)); } FakeFtpServer server = helper.createAndStart(filesystem); StandaloneConsumer sc = null; try { AtomicBoolean pollFired = new AtomicBoolean(false); PollerImp poller = new FixedIntervalPoller(new TimeInterval(300L, TimeUnit.MILLISECONDS)) .withPollerCallback(e -> { log.trace("Poll Fired {}", getName()); if (e == 0) { pollFired.set(true); } }); FtpConsumer ftpConsumer = createForTests(listener, "testConsumeWithQuietPeriodAndTimezone", poller); ftpConsumer.setQuietInterval(new TimeInterval(3L, TimeUnit.SECONDS)); FtpConnection consumeConnection = create(server); consumeConnection.setAdditionalDebug(true); consumeConnection.setServerTimezone("America/Los_Angeles"); sc = new StandaloneConsumer(consumeConnection, ftpConsumer); start(sc); long waitTime = waitForPollCallback(pollFired); log.trace("Waited for {}ms for == 0 poll", waitTime); helper.assertMessages(listener.getMessages(), 0); assertEquals(count, filesystem.listFiles(DEFAULT_WORK_DIR_CANONICAL).size()); } catch (Exception e) { throw e; } finally { stop(sc); server.stop(); } }
From source file:org.apache.solr.servlet.SolrDispatchFilter.java
private boolean authenticateRequest(ServletRequest request, ServletResponse response, final AtomicReference<ServletRequest> wrappedRequest) throws IOException { boolean requestContinues = false; final AtomicBoolean isAuthenticated = new AtomicBoolean(false); AuthenticationPlugin authenticationPlugin = cores.getAuthenticationPlugin(); if (authenticationPlugin == null) { return true; } else {/* ww w. j a va 2 s . c om*/ // /admin/info/key must be always open. see SOLR-9188 // tests work only w/ getPathInfo //otherwise it's just enough to have getServletPath() if (PKIAuthenticationPlugin.PATH.equals(((HttpServletRequest) request).getServletPath()) || PKIAuthenticationPlugin.PATH.equals(((HttpServletRequest) request).getPathInfo())) return true; String header = ((HttpServletRequest) request).getHeader(PKIAuthenticationPlugin.HEADER); if (header != null && cores.getPkiAuthenticationPlugin() != null) authenticationPlugin = cores.getPkiAuthenticationPlugin(); try { log.debug("Request to authenticate: {}, domain: {}, port: {}", request, request.getLocalName(), request.getLocalPort()); // upon successful authentication, this should call the chain's next filter. requestContinues = authenticationPlugin.doAuthenticate(request, response, (req, rsp) -> { isAuthenticated.set(true); wrappedRequest.set(req); }); } catch (Exception e) { log.info("Error authenticating", e); throw new SolrException(ErrorCode.SERVER_ERROR, "Error during request authentication, ", e); } } // requestContinues is an optional short circuit, thus we still need to check isAuthenticated. // This is because the AuthenticationPlugin doesn't always have enough information to determine if // it should short circuit, e.g. the Kerberos Authentication Filter will send an error and not // call later filters in chain, but doesn't throw an exception. We could force each Plugin // to implement isAuthenticated to simplify the check here, but that just moves the complexity to // multiple code paths. if (!requestContinues || !isAuthenticated.get()) { response.flushBuffer(); return false; } return true; }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.JFreeChartPlotEngine.java
public JFreeChartPlotEngine(PlotInstance plotInstanceForEngine, boolean zoomInOnSelection, boolean useBuffer) { this.plotInstance = plotInstanceForEngine; updatingChart = new AtomicBoolean(false); chartPanel = new LinkAndBrushChartPanel(new JFreeChart(new CategoryPlot()), 50, 50, 50, 50, zoomInOnSelection, useBuffer); chartPanel.setMinimumDrawWidth(50);/*from w w w . ja v a2 s . co m*/ chartPanel.setMinimumDrawHeight(50); chartPanel.setMaximumDrawWidth(10000); chartPanel.setMaximumDrawHeight(10000); chartPanel.addMouseListener(popupMenuListener); subscribeAtPlotInstance(plotInstance); }
From source file:net.centro.rtb.monitoringcenter.metrics.system.os.OperatingSystemMetricSet.java
public OperatingSystemMetricSet() { this.operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean(); this.rootFilePath = new File("/"); // Set up iowait retrieval job if needed Double ioWaitPercentage = fetchIoWaitPercentage(); if (ioWaitPercentage != null) { this.ioWaitPercentageHolder = new AtomicReference<>(ioWaitPercentage); this.executorService = Executors.newSingleThreadScheduledExecutor( new ThreadFactoryBuilder().setNameFormat("OperatingSystemMetricSet-%d").build()); this.executorService.scheduleWithFixedDelay(new Runnable() { @Override/*from ww w .j a va2s . c o m*/ public void run() { Double ioWaitPercentage = fetchIoWaitPercentage(); if (ioWaitPercentage != null) { ioWaitPercentageHolder.set(ioWaitPercentage); } } }, 5, 5, TimeUnit.SECONDS); } // ----- Init and assign metrics ----- this.metricsByNames = new HashMap<>(); // Available everywhere this.availableLogicalProcessorsGauge = new Gauge<Integer>() { @Override public Integer getValue() { return operatingSystemMXBean.getAvailableProcessors(); } }; metricsByNames.put("availableLogicalProcessors", availableLogicalProcessorsGauge); if (operatingSystemMXBean.getSystemLoadAverage() >= 0) { // Where available this.systemLoadAverageGauge = new Gauge<Double>() { @Override public Double getValue() { return operatingSystemMXBean.getSystemLoadAverage(); } }; metricsByNames.put("systemLoadAverage", systemLoadAverageGauge); this.systemLoadAveragePerLogicalProcessorGauge = new Gauge<Double>() { @Override public Double getValue() { return operatingSystemMXBean.getSystemLoadAverage() / operatingSystemMXBean.getAvailableProcessors(); } }; metricsByNames.put("systemLoadAveragePerLogicalProcessor", systemLoadAveragePerLogicalProcessorGauge); } // Sun JVMs, incl. OpenJDK if (com.sun.management.OperatingSystemMXBean.class.isAssignableFrom(operatingSystemMXBean.getClass())) { final com.sun.management.OperatingSystemMXBean sunOsMxBean = com.sun.management.OperatingSystemMXBean.class .cast(operatingSystemMXBean); if (sunOsMxBean.getProcessCpuLoad() >= 0) { this.jvmCpuBusyPercentageGauge = new Gauge<Double>() { @Override public Double getValue() { return sunOsMxBean.getProcessCpuLoad() * 100; } }; metricsByNames.put("jvmCpuBusyPercentage", jvmCpuBusyPercentageGauge); } if (sunOsMxBean.getSystemCpuLoad() >= 0) { this.systemCpuBusyPercentageGauge = new Gauge<Double>() { @Override public Double getValue() { return sunOsMxBean.getSystemCpuLoad() * 100; } }; metricsByNames.put("systemCpuBusyPercentage", systemCpuBusyPercentageGauge); } if (sunOsMxBean.getCommittedVirtualMemorySize() >= 0) { this.committedVirtualMemorySizeInBytesGauge = new Gauge<Long>() { @Override public Long getValue() { return sunOsMxBean.getCommittedVirtualMemorySize(); } }; metricsByNames.put("committedVirtualMemorySizeInBytes", committedVirtualMemorySizeInBytesGauge); } // Physical Memory String physicalMemoryNamespace = "physicalMemory"; this.totalPhysicalMemorySizeInBytesGauge = new Gauge<Long>() { @Override public Long getValue() { return sunOsMxBean.getTotalPhysicalMemorySize(); } }; metricsByNames.put(MetricNamingUtil.join(physicalMemoryNamespace, "totalInBytes"), totalPhysicalMemorySizeInBytesGauge); this.freePhysicalMemorySizeInBytesGauge = new Gauge<Long>() { @Override public Long getValue() { return sunOsMxBean.getFreePhysicalMemorySize(); } }; metricsByNames.put(MetricNamingUtil.join(physicalMemoryNamespace, "freeInBytes"), freePhysicalMemorySizeInBytesGauge); this.usedPhysicalMemoryPercentageGauge = new Gauge<Double>() { @Override public Double getValue() { long totalPhysicalMemorySize = sunOsMxBean.getTotalPhysicalMemorySize(); if (totalPhysicalMemorySize == 0) { return 0.0; } long usedPhysicalMemorySize = totalPhysicalMemorySize - sunOsMxBean.getFreePhysicalMemorySize(); return Double.valueOf(usedPhysicalMemorySize) / totalPhysicalMemorySize * 100; } }; metricsByNames.put(MetricNamingUtil.join(physicalMemoryNamespace, "usedPercentage"), usedPhysicalMemoryPercentageGauge); // Swap Space String swapSpaceNamespace = "swapSpace"; this.totalSwapSpaceSizeInBytesGauge = new Gauge<Long>() { @Override public Long getValue() { return sunOsMxBean.getTotalSwapSpaceSize(); } }; metricsByNames.put(MetricNamingUtil.join(swapSpaceNamespace, "totalInBytes"), totalSwapSpaceSizeInBytesGauge); this.freeSwapSpaceSizeInBytesGauge = new Gauge<Long>() { @Override public Long getValue() { return sunOsMxBean.getFreeSwapSpaceSize(); } }; metricsByNames.put(MetricNamingUtil.join(swapSpaceNamespace, "freeInBytes"), freeSwapSpaceSizeInBytesGauge); this.usedSwapSpacePercentageGauge = new Gauge<Double>() { @Override public Double getValue() { long totalSwapSpaceSize = sunOsMxBean.getTotalSwapSpaceSize(); if (totalSwapSpaceSize == 0) { return 0.0; } long usedSwapSpaceSize = totalSwapSpaceSize - sunOsMxBean.getFreeSwapSpaceSize(); return Double.valueOf(usedSwapSpaceSize) / totalSwapSpaceSize * 100; } }; metricsByNames.put(MetricNamingUtil.join(swapSpaceNamespace, "usedPercentage"), usedSwapSpacePercentageGauge); } // File descriptors (e.g., sockets) String fileDescriptorsNamespace = "fileDescriptors"; if (UnixOperatingSystemMXBean.class.isAssignableFrom(operatingSystemMXBean.getClass())) { final UnixOperatingSystemMXBean unixOsMxBean = UnixOperatingSystemMXBean.class .cast(operatingSystemMXBean); this.maxFileDescriptorsGauge = new Gauge<Long>() { @Override public Long getValue() { return unixOsMxBean.getMaxFileDescriptorCount(); } }; metricsByNames.put(MetricNamingUtil.join(fileDescriptorsNamespace, "max"), maxFileDescriptorsGauge); this.openFileDescriptorsGauge = new Gauge<Long>() { @Override public Long getValue() { return unixOsMxBean.getOpenFileDescriptorCount(); } }; metricsByNames.put(MetricNamingUtil.join(fileDescriptorsNamespace, "open"), openFileDescriptorsGauge); this.usedFileDescriptorsPercentageGauge = new Gauge<Double>() { @Override public Double getValue() { long maxFileDescriptors = unixOsMxBean.getMaxFileDescriptorCount(); if (maxFileDescriptors == 0) { return 0.0; } return Double.valueOf(unixOsMxBean.getOpenFileDescriptorCount()) / maxFileDescriptors * 100; } }; metricsByNames.put(MetricNamingUtil.join(fileDescriptorsNamespace, "usedPercentage"), usedFileDescriptorsPercentageGauge); } // Disk space String diskSpaceNamespace = "diskSpace"; if (rootFilePath.getTotalSpace() > 0) { this.totalDiskSpaceInBytesGauge = new Gauge<Long>() { @Override public Long getValue() { return rootFilePath.getTotalSpace(); } }; metricsByNames.put(MetricNamingUtil.join(diskSpaceNamespace, "totalInBytes"), totalDiskSpaceInBytesGauge); this.freeDiskSpaceInBytesGauge = new Gauge<Long>() { @Override public Long getValue() { return rootFilePath.getFreeSpace(); } }; metricsByNames.put(MetricNamingUtil.join(diskSpaceNamespace, "freeInBytes"), freeDiskSpaceInBytesGauge); this.usedDiskSpacePercentageGauge = new Gauge<Double>() { @Override public Double getValue() { long totalDiskSpace = rootFilePath.getTotalSpace(); if (totalDiskSpace == 0) { return 0.0; } long usedDiskSpace = totalDiskSpace - rootFilePath.getFreeSpace(); return Double.valueOf(usedDiskSpace) / totalDiskSpace * 100; } }; metricsByNames.put(MetricNamingUtil.join(diskSpaceNamespace, "usedPercentage"), usedDiskSpacePercentageGauge); } // CPU IO Wait if (ioWaitPercentageHolder != null) { this.ioWaitPercentageGauge = new Gauge<Double>() { @Override public Double getValue() { return ioWaitPercentageHolder.get(); } }; metricsByNames.put("ioWaitPercentage", ioWaitPercentageGauge); } this.shutdown = new AtomicBoolean(false); }
From source file:io.pcp.parfait.dxm.PcpMmvWriter.java
public static void main(String[] args) throws IOException { PcpMmvWriter bridge;/* w w w. ja v a2s . c o m*/ if (args.length == 0) { // use $PCP_PMDAS_DIR/mmv/mmvdump (no args) as diagnostic tool bridge = new PcpMmvWriter("test", IdentifierSourceSet.DEFAULT_SET); } else { bridge = new PcpMmvWriter(new File(args[0]), IdentifierSourceSet.DEFAULT_SET); } // Automatically uses default int handler bridge.addMetric(MetricName.parse("sheep[baabaablack].bagsfull.count"), Semantics.COUNTER, ONE.multiply(1000), 3); // Automatically uses default boolean-to-int handler bridge.addMetric(MetricName.parse("sheep[baabaablack].bagsfull.haveany"), Semantics.INSTANT, null, new AtomicBoolean(true)); bridge.addMetric(MetricName.parse("sheep[limpy].bagsfull.haveany"), Semantics.INSTANT, null, new AtomicBoolean(false)); // Automatically uses default long handler bridge.addMetric(MetricName.parse("sheep[insomniac].jumps"), Semantics.COUNTER, ONE, 12345678901234L); // Automatically uses default double handler bridge.addMetric(MetricName.parse("sheep[limpy].legs.available"), Semantics.DISCRETE, ONE, 0.75); // Uses this class' custom String handler bridge.addMetric(MetricName.parse("sheep[limpy].jumpitem"), Semantics.DISCRETE, null, "fence"); // addMetric(GregorianCalendar) would fail, as there's no handler registered by default for // GregorianCalendars; use a custom one which puts the year as an int bridge.addMetric(MetricName.parse("sheep[insomniac].lastjumped"), Semantics.INSTANT, null, new GregorianCalendar(), new AbstractTypeHandler<GregorianCalendar>(MmvMetricType.I32, 4) { public void putBytes(ByteBuffer buffer, GregorianCalendar value) { buffer.putInt(value.get(GregorianCalendar.YEAR)); } }); // addMetric(Date) would fail, as there's no handler registered; register one for all date // types from now on bridge.registerType(Date.class, new AbstractTypeHandler<Date>(MmvMetricType.I64, 8) { public void putBytes(ByteBuffer buffer, Date value) { buffer.putLong(value.getTime()); } }); // These will both use the handler we just registered bridge.addMetric(MetricName.parse("cow.how.now"), Semantics.INSTANT, null, new Date()); bridge.addMetric(MetricName.parse("cow.how.then"), Semantics.INSTANT, null, new GregorianCalendar(1990, 1, 1, 12, 34, 56).getTime()); // Uses units bridge.addMetric(MetricName.parse("cow.bytes.total"), Semantics.COUNTER, BYTE, 10000001); bridge.addMetric(MetricName.parse("cow.bytes.rate"), Semantics.INSTANT, BYTE.multiply(1024).divide(SECOND), new Date()); bridge.addMetric(MetricName.parse("cow.bytes.chewtime"), Semantics.INSTANT, HOUR.divide(BYTE), 7); bridge.addMetric(MetricName.parse("cow.bytes.jawmotion"), Semantics.INSTANT, KILO(HERTZ), 0.5); // Set up some help text bridge.setInstanceDomainHelpText("sheep", "sheep in the paddock", "List of all the sheep in the paddock. Includes 'baabaablack', 'insomniac' (who likes to jump fences), and 'limpy' the three-legged wonder sheep."); bridge.setMetricHelpText("sheep.jumps", "# of jumps done", "Number of times the sheep has jumped over its jumpitem"); // All the metrics are added; write the file bridge.start(); // Metrics are visible to the agent from this point on // Sold a bag! Better update the count bridge.updateMetric(MetricName.parse("sheep[baabaablack].bagsfull.count"), 2); // The fence broke! Need something new to jump over bridge.updateMetric(MetricName.parse("sheep[limpy].jumpitem"), "Honda Civic"); // Values will be reflected in the agent immediately }
From source file:com.github.vatbub.tictactoe.view.Main.java
private void connectToRelayServer() { setLoadingStatusText("The server is waking up, hang tight...", true); showLoadingScreen();// w w w. j ava2s .c o m Thread connectionThread = new Thread(() -> { int maxRetries = 10; int remainingRetries = maxRetries; AtomicBoolean readyWithoutException = new AtomicBoolean(false); Exception lastException = null; while (remainingRetries > 0 && !readyWithoutException.get()) { try { int finalRemainingRetries = remainingRetries; KryoGameConnections.connect(() -> { if (maxRetries == finalRemainingRetries) // should only appear the first time setLoadingStatusText("Connecting to the server..."); }, () -> Platform.runLater(() -> { readyWithoutException.set(true); hideLoadingScreen(); showOnlineMenu(); })); } catch (Exception e) { remainingRetries--; setLoadingStatusText("This is taking longer than usual, hang tight (Retry " + (maxRetries - remainingRetries) + " of " + maxRetries + ")..."); FOKLogger.log(Main.class.getName(), Level.SEVERE, "Could not connect to the relay server: " + e.getMessage(), e); lastException = e; } } if (!readyWithoutException.get()) { if (lastException == null) { Platform.runLater(() -> showErrorMessage("Something went wrong.", "Unknown")); } else { Exception finalLastException = lastException; Platform.runLater(() -> showErrorMessage(finalLastException)); } } }); connectionThread.setName("connectionThread"); connectionThread.start(); }
From source file:com.dragoniade.deviantart.favorites.FavoritesDownloader.java
private STATUS downloadFile(Deviation da, String downloadUrl, String filename, boolean reportError, YesNoAllDialog matureMoveDialog, YesNoAllDialog overwriteDialog, YesNoAllDialog overwriteNewerDialog, YesNoAllDialog deleteEmptyDialog) { AtomicBoolean download = new AtomicBoolean(true); File art = getFile(da, downloadUrl, filename, download, matureMoveDialog, overwriteDialog, overwriteNewerDialog, deleteEmptyDialog); if (art == null) { return null; }// w w w . j a va 2 s . c om if (download.get()) { File parent = art.getParentFile(); if (!parent.exists()) { if (!parent.mkdirs()) { showMessageDialog(owner, "Unable to create '" + parent.getPath() + "'.", "Error", JOptionPane.ERROR_MESSAGE); return null; } } GetMethod method = new GetMethod(downloadUrl); try { int sc = -1; do { sc = client.executeMethod(method); requestCount++; if (sc != 200) { if (sc == 404 || sc == 403) { method.releaseConnection(); return STATUS.NOTFOUND; } else { LoggableException ex = new LoggableException(method.getResponseBodyAsString()); Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), ex); int res = showConfirmDialog(owner, "An error has occured when contacting deviantART : error " + sc + ". Try again?", "Continue?", JOptionPane.YES_NO_CANCEL_OPTION); if (res == JOptionPane.NO_OPTION) { String text = "<br/><a style=\"color:red;\" href=\"" + da.getUrl() + "\">" + downloadUrl + " has an error" + "</a>"; setPaneText(text); method.releaseConnection(); progress.incremTotal(); return STATUS.SKIP; } if (res == JOptionPane.CANCEL_OPTION) { return null; } try { Thread.sleep(500); } catch (InterruptedException e) { } } } } while (sc != 200); int length = (int) method.getResponseContentLength(); int copied = 0; progress.setUnitMax(length); InputStream is = method.getResponseBodyAsStream(); File tmpFile = new File(art.getParentFile(), art.getName() + ".tmp"); FileOutputStream fos = new FileOutputStream(tmpFile, false); byte[] buffer = new byte[16184]; int read = -1; while ((read = is.read(buffer)) > 0) { fos.write(buffer, 0, read); copied += read; progress.setUnitValue(copied); if (progress.isCancelled()) { is.close(); method.releaseConnection(); tmpFile.delete(); return null; } } fos.close(); method.releaseConnection(); if (art.exists()) { if (!art.delete()) { showMessageDialog(owner, "Unable to delete '" + art.getPath() + "'.", "Error", JOptionPane.ERROR_MESSAGE); return null; } } if (!tmpFile.renameTo(art)) { showMessageDialog(owner, "Unable to rename '" + tmpFile.getPath() + "' to '" + art.getPath() + "'.", "Error", JOptionPane.ERROR_MESSAGE); return null; } art.setLastModified(da.getTimestamp().getTime()); return STATUS.DOWNLOADED; } catch (HttpException e) { showMessageDialog(owner, "Error contacting deviantART: " + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); return null; } catch (IOException e) { showMessageDialog(owner, "Error contacting deviantART: " + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); return null; } } else { progress.setText("Skipping file '" + filename + "' from " + da.getArtist()); return STATUS.SKIP; } }
From source file:io.atomix.protocols.gossip.map.AntiEntropyMapDelegate.java
private MapValue removeInternal(String key, Optional<byte[]> value, Optional<MapValue> tombstone) { checkState(!closed, destroyedMessage); checkNotNull(key, ERROR_NULL_KEY);/*from w w w. ja v a 2 s. co m*/ checkNotNull(value, ERROR_NULL_VALUE); tombstone.ifPresent(v -> checkState(v.isTombstone())); counter.incrementCount(); AtomicBoolean updated = new AtomicBoolean(false); AtomicReference<MapValue> previousValue = new AtomicReference<>(); items.compute(key, (k, existing) -> { boolean valueMatches = true; if (value.isPresent() && existing != null && existing.isAlive()) { valueMatches = Arrays.equals(value.get(), existing.get()); } if (existing == null) { log.trace("ECMap Remove: Existing value for key {} is already null", k); } if (valueMatches) { if (existing == null) { updated.set(tombstone.isPresent()); } else { updated.set(!tombstone.isPresent() || tombstone.get().isNewerThan(existing)); } } if (updated.get()) { previousValue.set(existing); return tombstone.orElse(null); } else { return existing; } }); return previousValue.get(); }