If the instance is provided by the user, {@link Closeable#close()}
will not be invoked.
778414
protected void releaseInstance(T instance) throws IOException {
    AtomicInteger currentCount = providedVsCount.get(instance);
    if(currentCount != null) {
      if(currentCount.decrementAndGet() < 0) {
        currentCount.incrementAndGet();
        throw new IllegalArgumentException("Given instance of " + instance.getClass().getName() + " is not managed by this provider");
      }
    } else {
      throw new IllegalArgumentException("Given instance of " + instance.getClass().getName() + " is not managed by this provider");
    }

    if(instantiated.remove(instance) && instance instanceof Closeable) {
      ((Closeable)instance).close();
    }
  }
1107087
public static void close(@Nullable Object object) throws IOException {
		if (object instanceof Closeable) {
			((Closeable) object).close();
		}
	}
1247024
public static void closeQuietly(Iterable<Closeable> closeables) {
    for (Closeable c : closeables) {
      try {
        //Check if we also need to flush
        if (c instanceof Flushable) {
          ((Flushable) c).flush();
        }

        if (c != null) {
          c.close();
        }
      } catch (IOException e) {
        LOGGER.debug("Error closing:" + c);
      }
    }
  }
712551
@Override
  public void close() throws IOException {
    if (open.compareAndSet(true, false)) {
      onClose.run();

      Throwable thrown = null;
      do {
        for (Closeable resource : resources) {
          try {
            resource.close();
          } catch (Throwable e) {
            if (thrown == null) {
              thrown = e;
            } else {
              thrown.addSuppressed(e);
            }
          } finally {
            // ensure the resource is removed even if it doesn't remove itself when closed
            resources.remove(resource);
          }
        }

        // It's possible for a thread registering a resource to register that resource after open
        // has been set to false and even after we've looped through and closed all the resources.
        // Since registering must be incremented *before* checking the state of open, however,
        // when we reach this point in that situation either the register call is still in progress
        // (registering > 0) or the new resource has been successfully added (resources not empty).
        // In either case, we just need to repeat the loop until there are no more register calls
        // in progress (no new calls can start and no resources left to close.
      } while (registering.get() > 0 || !resources.isEmpty());
      Throwables.propagateIfPossible(thrown, IOException.class);
    }
  }
1252863
@Override
    public void close() {
        if (mIsClosed) {
            return;
        }
        mIsClosed = true;

        mRetrofit = null;
        mRetrofitService = null;
        mRequestSignatorInterceptor = null;
        mHttpLoggingInterceptor = null;

        mApplicationContext.clear();
        mApplicationContext = null;

        mClientKey = null;
    }
834998
@Override
  public void close() {
    synchronized (lock) {
      if (closed) {
        return;
      }

      closed = true;
      tokenSource.unregister(this);
      tokenSource = null;
      action = null;
    }
  }
59868
public synchronized void close(final boolean forceClose) throws SQLException {
        Collection<SQLException> exceptions = new LinkedList<>();
        MasterVisitedManager.clear();
        exceptions.addAll(closeResultSets());
        exceptions.addAll(closeStatements());
        if (!stateHandler.isInTransaction() || forceClose) {
            exceptions.addAll(releaseConnections(forceClose));
        }
        stateHandler.doNotifyIfNecessary();
        throwSQLExceptionIfNecessary(exceptions);
    }
342188
public void closeQuietly(@Nullable final Closeable pCloseable)
    {
        if (pCloseable != null) {
            try {
                pCloseable.close();
            }
            catch (IOException e) {
                // ignore
            }
        }
    }
114415
public static void close(Closeable closeable) {
    if (closeable != null) {
      try {
        closeable.close();
      } catch (Exception e) {
        logger.info("Unable to close %s", closeable, e);
      }
    }
  }
577092
public static void closeQuietly( Closeable closeable ) {
        if (closeable == null) {
            return;
        }
        try {
            closeable.close();
        } catch (Throwable t) {
            LOGGER.debug(t, "Ignored error at closing stream");
        }
    }
439736
public static void closeQuietly(@Nullable final Closeable closeable, @Nonnull final Logger log) {
        try {
            if (null != closeable) {
                closeable.close();
            }
        } catch (Exception e) {
            log.error("Exception during cleanup of a Closeable, ignoring", e);
        }
    }
1133075
public static void safeClose(final Iterable<? extends Closeable> ci) {
        if (ci != null) {
            for (Closeable closeable : ci) {
                safeClose(closeable);
            }
        }
    }
421075
public static void safeClose(Closeable obj)
   {
      try
      {
         obj.close();
      }
      catch (IOException e)
      {
         LOG.error("Error while closing " + obj, e);
      }
   }
364061
public static boolean tryToClose(Closeable c) {
        if (c != null) {
            try {
                c.close();
                return true;
            } catch (IOException e) {
            }
        }
        return false;
    }
1270250
public static void closeQuietly(Closeable closeable) {
        try {
            closeable.close();
        } catch (IOException e) {
            LOGGER.error("Could not close closable", e);
        }
    }
1348291
private static void close(Closeable closeable) {
		if (closeable != null) {
			try {
				closeable.close();
			} catch (IOException ignored) {
				logger.error("Failed to close output stream: "
						+ ignored.getMessage());
			}
		}
	}
220403
public synchronized void close() throws IOException, InterruptedException {
		if (isClosed){
			return;
		}
		
		logger.info("closing client endpoint");
		if (connState == CONN_STATE_CONNECTED) {
			idPriv.disconnect();
			this.wait(1000);
		}
		if (connState >= CONN_STATE_RESOURCES_ALLOCATED) {
			idPriv.destroyQP();
		}
		idPriv.destroyId();
		group.unregisterClientEp(this);
		isClosed = true;
		logger.info("closing client done");
	}