src/share/classes/java/util/logging/SocketHandler.java

Print this page

        

@@ -116,20 +116,23 @@
      * @throws IOException if we are unable to connect to the target
      *         host and port.
      */
     public SocketHandler() throws IOException {
         // We are going to use the logging defaults.
-        sealed = false;
+        try {
+            doWithControlPermission(() -> {
         configure();
-
         try {
             connect();
-        } catch (IOException ix) {
+                } catch (IOException ioe) {
+                    throw new UncheckedIOException(ioe);
+                }
+            });
+        } catch (UncheckedIOException uioe) {
             System.err.println("SocketHandler: connect failed to " + host + ":" + port);
-            throw ix;
+            throw uioe.getCause();
         }
-        sealed = true;
     }
 
     /**
      * Construct a <tt>SocketHandler</tt> using a specified host and port.
      *

@@ -144,13 +147,11 @@
      * @throws IllegalArgumentException if the host or port are invalid.
      * @throws IOException if we are unable to connect to the target
      *         host and port.
      */
     public SocketHandler(String host, int port) throws IOException {
-        sealed = false;
-        configure();
-        sealed = true;
+        doWithControlPermission(this::configure);
         this.port = port;
         this.host = host;
         connect();
     }