src/share/classes/com/sun/imageio/stream/StreamCloser.java

Print this page
rev 9292 : 8033716: Fix raw and unchecked lint warnings in com.sun.imageio
Reviewed-by: darcy, prr


  65                                 // Make a copy of the set in order to avoid
  66                                 // concurrent modification (the is.close()
  67                                 // will in turn call removeFromQueue())
  68                                 CloseAction[] actions =
  69                                     new CloseAction[set.size()];
  70                                 actions = set.toArray(actions);
  71                                 for (CloseAction ca : actions) {
  72                                     if (ca != null) {
  73                                         try {
  74                                             ca.performAction();
  75                                         } catch (IOException e) {
  76                                         }
  77                                     }
  78                                 }
  79                             }
  80                         }
  81                     }
  82                 };
  83 
  84                 java.security.AccessController.doPrivileged(
  85                     new java.security.PrivilegedAction() {
  86                         public Object run() {
  87                             /* The thread must be a member of a thread group
  88                              * which will not get GCed before VM exit.
  89                              * Make its parent the top-level thread group.
  90                              */
  91                             ThreadGroup tg =
  92                                 Thread.currentThread().getThreadGroup();
  93                             for (ThreadGroup tgn = tg;
  94                                  tgn != null;
  95                                  tg = tgn, tgn = tg.getParent());
  96                             streamCloser = new Thread(tg, streamCloserRunnable);
  97                             /* Set context class loader to null in order to avoid
  98                              * keeping a strong reference to an application classloader.
  99                              */
 100                             streamCloser.setContextClassLoader(null);
 101                             Runtime.getRuntime().addShutdownHook(streamCloser);
 102                             return null;
 103                         }
 104                     });
 105             }




  65                                 // Make a copy of the set in order to avoid
  66                                 // concurrent modification (the is.close()
  67                                 // will in turn call removeFromQueue())
  68                                 CloseAction[] actions =
  69                                     new CloseAction[set.size()];
  70                                 actions = set.toArray(actions);
  71                                 for (CloseAction ca : actions) {
  72                                     if (ca != null) {
  73                                         try {
  74                                             ca.performAction();
  75                                         } catch (IOException e) {
  76                                         }
  77                                     }
  78                                 }
  79                             }
  80                         }
  81                     }
  82                 };
  83 
  84                 java.security.AccessController.doPrivileged(
  85                     new java.security.PrivilegedAction<Object>() {
  86                         public Object run() {
  87                             /* The thread must be a member of a thread group
  88                              * which will not get GCed before VM exit.
  89                              * Make its parent the top-level thread group.
  90                              */
  91                             ThreadGroup tg =
  92                                 Thread.currentThread().getThreadGroup();
  93                             for (ThreadGroup tgn = tg;
  94                                  tgn != null;
  95                                  tg = tgn, tgn = tg.getParent());
  96                             streamCloser = new Thread(tg, streamCloserRunnable);
  97                             /* Set context class loader to null in order to avoid
  98                              * keeping a strong reference to an application classloader.
  99                              */
 100                             streamCloser.setContextClassLoader(null);
 101                             Runtime.getRuntime().addShutdownHook(streamCloser);
 102                             return null;
 103                         }
 104                     });
 105             }