JDK-8224642: Test sun/tools/jcmd/TestJcmdSanity.java fails: Bad file descriptor

gary.adams at oracle.com gary.adams at oracle.com
Tue Jun 18 11:01:49 UTC 2019


So you prefer the fix in VirtualMachineImpl SocketInputStream close()
rather than the JCmd try with resources.

If we were dealing with output streams, it would be important
to apply the flush to the writer. Since these are input
streams we just need to guard against the duplicate close
for the native resource.

On 6/18/19 6:34 AM, Schmelter, Ralf wrote:
> Hi,
>
> since InputStream imeplements Closeable, calling close multiple times *must* work:
>
> public interface Closeable extends AutoCloseable {
>
>      /**
>       * Closes this stream and releases any system resources associated
>       * with it. If the stream is already closed then invoking this
>       * method has no effect.
>       *
>       * <p> As noted in {@link AutoCloseable#close()}, cases where the
>       * close may fail require careful attention. It is strongly advised
>       * to relinquish the underlying resources and to internally
>       * <em>mark</em> the {@code Closeable} as closed, prior to throwing
>       * the {@code IOException}.
>       *
>       * @throws IOException if an I/O error occurs
>       */
>      public void close() throws IOException;
> }
>
> So the close() method must be fixed in the same way FileInputStream and friends implement close().
>
> Best regards,
> Ralf



More information about the serviceability-dev mailing list