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

java.awt.MediaTracker.waitForAll() does not close image files

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 1.3.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description

      JDK 1.3 java.awt.MediaTracker.waitForAll() does not close image files which
      causes a leak in file descriptors.

      A test example which demonstrates this problem.
      ===== test.java ========
      import java.net.*;
      import java.awt.*;

      public class test1 {
          public static void main (String argv[]) {
                  Component comp = new Canvas();
                  MediaTracker tracker = new MediaTracker(comp);
                  Image image = null;

                  try {
                      image = Toolkit.getDefaultToolkit().getImage(new URL("file:/tmp/im0.gif"));
                  } catch (MalformedURLException mue) {
                      System.out.println(" failed: Unexpected " + mue);
                  }

                  try {
                       tracker.addImage(image, 0);
      try {
      tracker.waitForAll();
                       } catch (InterruptedException ie) {
                           System.out.println(" failed: Unexpected " + ie);
                           return;
      }
                      tracker.removeImage(image, 0);
                } finally {
                  image.flush();
                  System.out.println("QUIT");
                  System.exit(0);
                }
          }

      }

      In the example above the following file "/tmp/im0.gif" wouldn't be closed directly after it was read. In this example the file would be closed only
      by the system _exit() call when VM dies. (Analyse requests to the OS system
      libraries)

        Attachments

          Activity

            People

            Assignee:
            ibdsunw Ibd Ibd (Inactive)
            Reporter:
            akuzminorcl Alexander Kuzmin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: