Returns a {@link Closeable} which action is to call {@link #decrement()} only once. If close() is called on the
returned Closeable object for the second time, it won't call {@link #decrement()} again.
183638
public Closeable decrementOnceCloseable()
  {
    AtomicBoolean decremented = new AtomicBoolean(false);
    return () -> {
      if (decremented.compareAndSet(false, true)) {
        decrement();
      } else {
        log.warn("close() is called more than once on ReferenceCountingSegment.decrementOnceCloseable()");
      }
    };
  }
415991
public static void close(Iterable<? extends Closeable> closeables)
            throws IOException {
        IOException first = null;
        for (final Closeable c : closeables) {
            if (c == null) {
                LOG.debug("trying to call .close() on null reference");
                continue;
            }
            try {
                c.close();
            } catch (final IOException e) {
                if (first == null) {
                    first = e;
                } else {
                    first.addSuppressed(e);
                }
            }
        }
        if (first != null) {
            throw first;
        }
    }
20075
public boolean isClosed()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        {
            SibTr.entry(tc, "isClosed", this);
            SibTr.exit(tc, "isClosed", Boolean.valueOf(_closed));
        }
        return _closed;
    }
1009779
public static void closeSilently(Closeable closeable) {
    try {
      if(closeable != null) {
        closeable.close();
      }
    }
    catch(IOException ignore) {
      LOG.debugCloseException(ignore);
    }
  }
116000
public Future<Void> forceClose() {
    this.close();
    if (forceClosing.compareAndSet(false, true) && channel.isOpen()) {
      writeCoalescer
          .writeAndFlush(channel, FORCEFUL_CLOSE_MESSAGE)
          .addListener(UncaughtExceptions::log);
    }
    return channel.closeFuture();
  }
728860
public String close() {
        if (instance == null) {
            return null;
        }
        try {
            container.close();
            instance = null;
        } catch (IOException e) {
            return e.getMessage();
        }
        return null;
    }
577105
public CompletableFuture<Void> close() {
    CompletableFuture[] futures = new CompletableFuture[connections.size()];

    for (CompletableFuture<Connection> future : this.connectionFutures.values()) {
      future.cancel(false);
    }

    int i = 0;
    for (Connection connection : connections.values()) {
      futures[i++] = connection.close();
    }

    return CompletableFuture.allOf(futures);
  }
666566
public boolean remove()
    {
        if (_last1.key() == null)
            throw new java.util.NoSuchElementException(
                                                      "remove() without calling next()");

        boolean result = internalRemove();

        return result;
    }
466300
public static void close(@Nullable final Closeable closeable) {
        if (null != closeable) {
            try {
                closeable.close();
            } catch (IOException ex) {
                LOGGER.trace("", ex);
            }
        }
    }
499321
public int decrementAndGet(T obj) {
        int prev, next;
        do {
            prev = get(obj);
            next = prev - 1;
        } while (!compareAndSet(obj, prev, next));
        return next;
    }
169743
@Override
	public int close() throws IOException {
		if (!writer.isClosed()) {
			int currentPositionInSegment = getCurrentPositionInSegment();
			// write last segment
			writer.writeBlock(getCurrentSegment());
			clear();

			writer.getReturnQueue().clear();
			this.writer.close();

			return currentPositionInSegment;
		}
		return -1;
	}
49473
CloseableIterator<T> seperateIteratorThrow(int flags) throws SQLException {
		// check state to make sure we have a DAO in case we have a deserialized collection
		if (dao == null) {
			throw new IllegalStateException(
					"Internal DAO object is null.  Maybe the collection was deserialized or otherwise constructed wrongly.  "
							+ "Use dao.assignEmptyForeignCollection(...) or dao.getEmptyForeignCollection(...) instead");
		} else {
			return dao.iterator(getPreparedQuery(), flags);
		}
	}
562191
public static void close(Closeable...closeable) {
    for(Closeable c : closeable)
      try { if( c != null ) c.close(); } catch( IOException ex ) {
        Log.err(ex);
      }
  }
43621
@Weight(Weight.Unit.LIGHT)
  @Nullable
  public static Closeable closeQuietly(@Nullable final Closeable closeable) {
    if (closeable != null) {
      try {
        closeable.close();
      } catch (Exception ex) {
        MetaErrorListeners.fireError("Exception in closeQuietly", ex);
      }
    }
    return closeable;
  }
1326689
public ListenableFuture<?> closeAndDelete() {

        // We're going away, so shut ourselves from the external world
        m_closed = true;
        m_ackMailboxRefs.set(null);

        // Export mastership should have been released: force it.
        m_mastershipAccepted.set(false);

        // FIXME: necessary? Old processor should have been shut down.
        // Returning null indicates end of stream
        try {
            if (m_pollTask != null) {
                m_pollTask.setFuture(null);
            }
        } catch (RejectedExecutionException reex) {
            // Ignore, {@code GuestProcessor} was closed
        }
        m_pollTask = null;

        return m_es.submit(new Runnable() {
            @Override
            public void run() {
                try {
                    // Discard the pending container, shortcutting the standard discard logic
                    AckingContainer ack = m_pendingContainer.getAndSet(null);
                    if (ack != null) {
                        if (exportLog.isDebugEnabled()) {
                            exportLog.debug("Discard pending container, lastSeqNo: " + ack.getLastSeqNo());
                        }
                        ack.internalDiscard();
                    }
                    m_committedBuffers.closeAndDelete();
                    m_adFile.delete();
                } catch(IOException e) {
                    exportLog.rateLimitedLog(60, Level.WARN, e, "Error closing commit buffers");
                } finally {
                    m_es.shutdown();
                }
            }
        });
    }
462854
public CompletableFuture<Void> close() {
    protocol.unregisterPublishListener(state.getSessionId());
    return CompletableFuture.completedFuture(null);
  }
61338
public static boolean safeCloseAll(Iterable<? extends Closeable> closeables) {
        final Iterator<? extends Closeable> it = closeables.iterator();
        boolean result = true;
        while (it.hasNext()) {
            result &= safeClose(it.next());
        }
        return result;
    }