Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6336804

javax.imageio.ImageIO possible handle leak in some methods

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      1.4
    • Introduced In Version:
    • Resolved In Build:
      b67
    • CPU:
      generic, sparc
    • OS:
      generic, solaris_9, solaris_10

      Description

      J2SE Version (please include all output from java -version flag):
       java version "1.6.0-ea"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b55)
        Java HotSpot(TM) Client VM (build 1.6.0-ea-b55, mixed mode, sharing)

      Does this problem occur on J2SE 1.4.x or 5.0.x ? Yes / No (pick one)
        don't know


      Bug Description:
         javax.imageio.ImageIO possible handle leak in some methods.
         "High level" methods to read/write files do not close streams
         in case of exceptions. See below.

      Steps to Reproduce (be specific):
         For example the method javax.imageio.ImageIO.write(RenderedImage,String,File)
         contains the following code:

      public static boolean write(RenderedImage im, String formatName, File output)
          throws IOException {
      ...
            ImageOutputStream stream = null;
          try {
              output.delete();
      stream = createImageOutputStream(output);
          } catch (IOException e) {
              throw new IIOException("Can't create output stream!", e);
          }
          boolean val = write(im, formatName, stream);
          stream.close(); // not called if above method throws exception!
          return val;
      }

         If write() throws an exception, stream.close(); will never be called and
         the underlying operating system handle will never be closed.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              campbell Christopher Campbell (Inactive)
              Reporter:
              tyao Ting-Yun Ingrid Yao (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: