public PlainSocketImpl(FileDescriptor fd, int localport, InetAddress addr, int port) { this.fd = fd; this.localport = localport; this.address = addr; this.port = port; if (fd.valid()) { guard.open("close"); } }
/** * Returns a CloseGuard instance. If CloseGuard is enabled, {@code * #open(String)} can be used to set up the instance to warn on * failure to close. If CloseGuard is disabled, a non-null no-op * instance is returned. */ public static CloseGuard get() { if (!ENABLED) { return NOOP; } return new CloseGuard(); }
/** * Closes this zip file. This method is idempotent. This method may cause I/O if the * zip file needs to be deleted. * * @throws IOException * if an IOException occurs. */ public void close() throws IOException { guard.close(); RandomAccessFile localRaf = raf; if (localRaf != null) { // Only close initialized instances synchronized (localRaf) { raf = null; localRaf.close(); } if (fileToDeleteOnClose != null) { fileToDeleteOnClose.delete(); fileToDeleteOnClose = null; } } }
CloseGuard guard = CloseGuard.get(); ReflectionHelpers.setField(MediaMuxer.class, realMuxer, "mCloseGuard", guard); ReflectionHelpers.setField(MediaMuxer.class, realMuxer, "mLastTrackIndex", -1); ReflectionHelpers.setField(MediaMuxer.class, realMuxer, "mNativeObject", nativeObject); ReflectionHelpers.setField(MediaMuxer.class, realMuxer, "mState", MUXER_STATE_INITIALIZED); guard.open("release"); } else { ReflectionHelpers.callInstanceMethod(
@Override protected void finalize() throws Throwable { try { if (guard != null) { guard.warnIfOpen(); } close(); } finally { super.finalize(); } }
@Override protected void finalize() throws IOException { try { if (guard != null) { guard.warnIfOpen(); } } finally { try { super.finalize(); } catch (Throwable t) { throw new AssertionError(t); } } }
/** * This constructor allows to create an inflater that expects no header from * the input stream. * * @param noHeader * {@code true} indicates that no ZLIB header comes with the * input. */ public Inflater(boolean noHeader) { streamHandle = createStream(noHeader); guard.open("end"); }
@Override protected void finalize() { try { if (guard != null) { guard.warnIfOpen(); } end(); } finally { try { super.finalize(); } catch (Throwable t) { throw new AssertionError(t); } } }
/** * Closes the socket. After this method is invoked, subsequent * read/write operations will fail. */ public void close() throws IOException { guard.close(); IoBridge.closeSocket(fd); }
/** * Returns a CloseGuard instance. If CloseGuard is enabled, {@code * #open(String)} can be used to set up the instance to warn on * failure to close. If CloseGuard is disabled, a non-null no-op * instance is returned. */ public static CloseGuard get() { if (!ENABLED) { return NOOP; } return new CloseGuard(); }
public PlainSocketImpl(FileDescriptor fd) { this.fd = fd; if (fd.valid()) { guard.open("close"); } }
@Override protected void finalize() throws IOException { try { if (guard != null) { guard.warnIfOpen(); } close(); } finally { try { super.finalize(); } catch (Throwable t) { // for consistency with the RI, we must override Object.finalize() to // remove the 'throws Throwable' clause. throw new AssertionError(t); } } }
@Override public synchronized void close() { guard.close(); try { IoBridge.closeSocket(fd); } catch (IOException ignored) { } }
/** * Returns a CloseGuard instance. If CloseGuard is enabled, {@code * #open(String)} can be used to set up the instance to warn on * failure to close. If CloseGuard is disabled, a non-null no-op * instance is returned. */ public static CloseGuard get() { if (!ENABLED) { return NOOP; } return new CloseGuard(); }
public PlainDatagramSocketImpl(FileDescriptor fd, int localPort) { this.fd = fd; this.localPort = localPort; if (fd.valid()) { guard.open("close"); } }
@Override protected void finalize() throws Throwable { try { if (guard != null) { guard.warnIfOpen(); } close(); } finally { super.finalize(); } } }
/** * Frees all resources held onto by this deflating algorithm. Any unused * input or output is discarded. This method should be called explicitly in * order to free native resources as soon as possible. After {@code end()} is * called, other methods will typically throw {@code IllegalStateException}. */ public synchronized void end() { guard.close(); endImpl(); }
/** * Returns a CloseGuard instance. If CloseGuard is enabled, {@code * #open(String)} can be used to set up the instance to warn on * failure to close. If CloseGuard is disabled, a non-null no-op * instance is returned. */ public static CloseGuard get() { if (!ENABLED) { return NOOP; } return new CloseGuard(); }
/** * Constructs a new {@code Deflater} instance with the * given <a href="#compression_level">compression level</a>. * If {@code noHeader} is true, no ZLIB header is added to the * output. In a zip file, every entry (compressed file) comes with such a * header. The strategy can be specified using {@link #setStrategy}. */ public Deflater(int level, boolean noHeader) { if (level < DEFAULT_COMPRESSION || level > BEST_COMPRESSION) { throw new IllegalArgumentException("Bad level: " + level); } compressLevel = level; streamHandle = createStream(compressLevel, strategy, noHeader); guard.open("end"); }
@Override protected void finalize() throws Throwable { try { if (guard != null) { guard.warnIfOpen(); } close(); } finally { super.finalize(); } }