Merge jdk7-b73
authorkevinw
Tue, 22 Sep 2009 17:16:30 +0100
changeset 1712f708138c9aca
parent 1711 b8004f6f4812
parent 1710 44ccaa4bb8a0
child 1713 59b45d636384
child 1725 e6ced7714609
child 1732 c715b68cdcaf
Merge
     1.1 --- a/src/share/classes/sun/net/www/http/HttpCapture.java	Tue Sep 22 17:01:08 2009 +0100
     1.2 +++ b/src/share/classes/sun/net/www/http/HttpCapture.java	Tue Sep 22 17:16:30 2009 +0100
     1.3 @@ -24,14 +24,12 @@
     1.4   */
     1.5  
     1.6  package sun.net.www.http;
     1.7 +
     1.8  import java.io.*;
     1.9 -import java.lang.reflect.InvocationTargetException;
    1.10 -import java.lang.reflect.Method;
    1.11  import java.util.ArrayList;
    1.12 -import java.util.logging.Level;
    1.13 -import java.util.logging.Logger;
    1.14 +import java.util.regex.*;
    1.15  import sun.net.NetProperties;
    1.16 -import java.util.regex.*;
    1.17 +import sun.util.logging.PlatformLogger;
    1.18  
    1.19  /**
    1.20   * Main class of the HTTP traffic capture tool.
    1.21 @@ -62,76 +60,6 @@
    1.22      private static boolean initialized = false;
    1.23      private static volatile ArrayList<Pattern> patterns = null;
    1.24      private static volatile ArrayList<String> capFiles = null;
    1.25 -    /* Logging is done in an ugly way so that it does not require the presence
    1.26 -     * the java.util.logging package. If the Logger class is not available, then
    1.27 -     * logging is turned off. This is for helping the modularization effort.
    1.28 -     */
    1.29 -    private static Object logger = null;
    1.30 -    private static boolean logging = false;
    1.31 -
    1.32 -    static {
    1.33 -        Class cl;
    1.34 -        try {
    1.35 -            cl = Class.forName("java.util.logging.Logger");
    1.36 -        } catch (ClassNotFoundException ex) {
    1.37 -            cl = null;
    1.38 -        }
    1.39 -        if (cl != null) {
    1.40 -            try {
    1.41 -                Method m = cl.getMethod("getLogger", String.class);
    1.42 -                logger = m.invoke(null, "sun.net.www.protocol.http.HttpURLConnection");
    1.43 -                logging = true;
    1.44 -            } catch (NoSuchMethodException noSuchMethodException) {
    1.45 -            } catch (SecurityException securityException) {
    1.46 -            } catch (IllegalAccessException illegalAccessException) {
    1.47 -            } catch (IllegalArgumentException illegalArgumentException) {
    1.48 -            } catch (InvocationTargetException invocationTargetException) {
    1.49 -            }
    1.50 -        }
    1.51 -    }
    1.52 -
    1.53 -    public static void fine(String s) {
    1.54 -        if (logging) {
    1.55 -            ((Logger)logger).fine(s);
    1.56 -        }
    1.57 -    }
    1.58 -
    1.59 -    public static void finer(String s) {
    1.60 -        if (logging) {
    1.61 -            ((Logger)logger).finer(s);
    1.62 -        }
    1.63 -    }
    1.64 -
    1.65 -    public static void finest(String s) {
    1.66 -        if (logging) {
    1.67 -            ((Logger)logger).finest(s);
    1.68 -        }
    1.69 -    }
    1.70 -
    1.71 -    public static void severe(String s) {
    1.72 -        if (logging) {
    1.73 -            ((Logger)logger).finest(s);
    1.74 -        }
    1.75 -    }
    1.76 -
    1.77 -    public static void info(String s) {
    1.78 -        if (logging) {
    1.79 -            ((Logger)logger).info(s);
    1.80 -        }
    1.81 -    }
    1.82 -
    1.83 -    public static void warning(String s) {
    1.84 -        if (logging) {
    1.85 -            ((Logger)logger).warning(s);
    1.86 -        }
    1.87 -    }
    1.88 -
    1.89 -    public static boolean isLoggable(String level) {
    1.90 -        if (!logging) {
    1.91 -            return false;
    1.92 -        }
    1.93 -        return ((Logger)logger).isLoggable(Level.parse(level));
    1.94 -    }
    1.95  
    1.96      private static synchronized void init() {
    1.97          initialized = true;
    1.98 @@ -187,7 +115,7 @@
    1.99              out = new BufferedWriter(new FileWriter(file, true));
   1.100              out.write("URL: " + url + "\n");
   1.101          } catch (IOException ex) {
   1.102 -            Logger.getLogger(HttpCapture.class.getName()).log(Level.SEVERE, null, ex);
   1.103 +            PlatformLogger.getLogger(HttpCapture.class.getName()).severe(null, ex);
   1.104          }
   1.105      }
   1.106  
     2.1 --- a/src/share/classes/sun/net/www/http/HttpClient.java	Tue Sep 22 17:01:08 2009 +0100
     2.2 +++ b/src/share/classes/sun/net/www/http/HttpClient.java	Tue Sep 22 17:16:30 2009 +0100
     2.3 @@ -35,6 +35,7 @@
     2.4  import sun.net.www.MeteredStream;
     2.5  import sun.net.www.ParseUtil;
     2.6  import sun.net.www.protocol.http.HttpURLConnection;
     2.7 +import sun.util.logging.PlatformLogger;
     2.8  
     2.9  /**
    2.10   * @author Herb Jellinek
    2.11 @@ -804,8 +805,9 @@
    2.12  
    2.13              if (isKeepingAlive())   {
    2.14                  // Wrap KeepAliveStream if keep alive is enabled.
    2.15 -                if (HttpCapture.isLoggable("FINEST")) {
    2.16 -                    HttpCapture.finest("KeepAlive stream used: " + url);
    2.17 +                PlatformLogger logger = HttpURLConnection.getHttpLogger();
    2.18 +                if (logger.isLoggable(PlatformLogger.FINEST)) {
    2.19 +                    logger.finest("KeepAlive stream used: " + url);
    2.20                  }
    2.21                  serverInput = new KeepAliveStream(serverInput, pi, cl, this);
    2.22                  failedOnce = false;
     3.1 --- a/src/share/classes/sun/net/www/http/KeepAliveCache.java	Tue Sep 22 17:01:08 2009 +0100
     3.2 +++ b/src/share/classes/sun/net/www/http/KeepAliveCache.java	Tue Sep 22 17:16:30 2009 +0100
     3.3 @@ -25,12 +25,11 @@
     3.4  
     3.5  package sun.net.www.http;
     3.6  
     3.7 -import java.io.InputStream;
     3.8  import java.io.IOException;
     3.9  import java.io.NotSerializableException;
    3.10 -import java.util.*;
    3.11 +import java.util.ArrayList;
    3.12 +import java.util.HashMap;
    3.13  import java.net.URL;
    3.14 -import java.util.concurrent.ConcurrentHashMap;
    3.15  
    3.16  /**
    3.17   * A class that implements a cache of idle Http connections for keep-alive
    3.18 @@ -39,7 +38,7 @@
    3.19   * @author Dave Brown
    3.20   */
    3.21  public class KeepAliveCache
    3.22 -    extends ConcurrentHashMap<KeepAliveKey, ClientVector>
    3.23 +    extends HashMap<KeepAliveKey, ClientVector>
    3.24      implements Runnable {
    3.25      private static final long serialVersionUID = -2937172892064557949L;
    3.26  
    3.27 @@ -163,8 +162,8 @@
    3.28       * Errs on the side of caution (leave connections idle for a relatively
    3.29       * short time).
    3.30       */
    3.31 +    @Override
    3.32      public void run() {
    3.33 -        int total_cache;
    3.34          do {
    3.35              try {
    3.36                  Thread.sleep(LIFETIME);
    3.37 @@ -311,6 +310,7 @@
    3.38      /**
    3.39       * Determine whether or not two objects of this type are equal
    3.40       */
    3.41 +    @Override
    3.42      public boolean equals(Object obj) {
    3.43          if ((obj instanceof KeepAliveKey) == false)
    3.44              return false;
    3.45 @@ -325,6 +325,7 @@
    3.46       * The hashCode() for this object is the string hashCode() of
    3.47       * concatenation of the protocol, host name and port.
    3.48       */
    3.49 +    @Override
    3.50      public int hashCode() {
    3.51          String str = protocol+host+port;
    3.52          return this.obj == null? str.hashCode() :
     4.1 --- a/src/share/classes/sun/net/www/http/KeepAliveStream.java	Tue Sep 22 17:01:08 2009 +0100
     4.2 +++ b/src/share/classes/sun/net/www/http/KeepAliveStream.java	Tue Sep 22 17:16:30 2009 +0100
     4.3 @@ -25,10 +25,7 @@
     4.4  
     4.5  package sun.net.www.http;
     4.6  
     4.7 -import java.net.URL;
     4.8 -import java.net.HttpURLConnection;
     4.9  import java.io.*;
    4.10 -import java.util.StringTokenizer;
    4.11  import sun.net.ProgressSource;
    4.12  import sun.net.www.MeteredStream;
    4.13  
    4.14 @@ -50,9 +47,8 @@
    4.15      // has this KeepAliveStream been put on the queue for asynchronous cleanup.
    4.16      protected boolean queuedForCleanup = false;
    4.17  
    4.18 -    private static KeepAliveStreamCleaner queue = new KeepAliveStreamCleaner();
    4.19 -    private static Thread cleanerThread = null;
    4.20 -    private static boolean startCleanupThread;
    4.21 +    private static final KeepAliveStreamCleaner queue = new KeepAliveStreamCleaner();
    4.22 +    private static Thread cleanerThread; // null
    4.23  
    4.24      /**
    4.25       * Constructor
    4.26 @@ -155,43 +151,46 @@
    4.27          }
    4.28      }
    4.29  
    4.30 -    private static synchronized void queueForCleanup(KeepAliveCleanerEntry kace) {
    4.31 -        if(queue != null && !kace.getQueuedForCleanup()) {
    4.32 -            if (!queue.offer(kace)) {
    4.33 -                kace.getHttpClient().closeServer();
    4.34 -                return;
    4.35 +    private static void queueForCleanup(KeepAliveCleanerEntry kace) {
    4.36 +        synchronized(queue) {
    4.37 +            if(!kace.getQueuedForCleanup()) {
    4.38 +                if (!queue.offer(kace)) {
    4.39 +                    kace.getHttpClient().closeServer();
    4.40 +                    return;
    4.41 +                }
    4.42 +
    4.43 +                kace.setQueuedForCleanup();
    4.44 +                queue.notifyAll();
    4.45              }
    4.46  
    4.47 -            kace.setQueuedForCleanup();
    4.48 -        }
    4.49 +            boolean startCleanupThread = (cleanerThread == null);
    4.50 +            if (!startCleanupThread) {
    4.51 +                if (!cleanerThread.isAlive()) {
    4.52 +                    startCleanupThread = true;
    4.53 +                }
    4.54 +            }
    4.55  
    4.56 -        startCleanupThread = (cleanerThread == null);
    4.57 -        if (!startCleanupThread) {
    4.58 -            if (!cleanerThread.isAlive()) {
    4.59 -                startCleanupThread = true;
    4.60 +            if (startCleanupThread) {
    4.61 +                java.security.AccessController.doPrivileged(
    4.62 +                    new java.security.PrivilegedAction<Void>() {
    4.63 +                    public Void run() {
    4.64 +                        // We want to create the Keep-Alive-SocketCleaner in the
    4.65 +                        // system threadgroup
    4.66 +                        ThreadGroup grp = Thread.currentThread().getThreadGroup();
    4.67 +                        ThreadGroup parent = null;
    4.68 +                        while ((parent = grp.getParent()) != null) {
    4.69 +                            grp = parent;
    4.70 +                        }
    4.71 +
    4.72 +                        cleanerThread = new Thread(grp, queue, "Keep-Alive-SocketCleaner");
    4.73 +                        cleanerThread.setDaemon(true);
    4.74 +                        cleanerThread.setPriority(Thread.MAX_PRIORITY - 2);
    4.75 +                        cleanerThread.start();
    4.76 +                        return null;
    4.77 +                    }
    4.78 +                });
    4.79              }
    4.80 -        }
    4.81 -
    4.82 -        if (startCleanupThread) {
    4.83 -            java.security.AccessController.doPrivileged(
    4.84 -                new java.security.PrivilegedAction<Void>() {
    4.85 -                public Void run() {
    4.86 -                    // We want to create the Keep-Alive-SocketCleaner in the
    4.87 -                    // system threadgroup
    4.88 -                    ThreadGroup grp = Thread.currentThread().getThreadGroup();
    4.89 -                    ThreadGroup parent = null;
    4.90 -                    while ((parent = grp.getParent()) != null) {
    4.91 -                        grp = parent;
    4.92 -                    }
    4.93 -
    4.94 -                    cleanerThread = new Thread(grp, queue, "Keep-Alive-SocketCleaner");
    4.95 -                    cleanerThread.setDaemon(true);
    4.96 -                    cleanerThread.setPriority(Thread.MAX_PRIORITY - 2);
    4.97 -                    cleanerThread.start();
    4.98 -                    return null;
    4.99 -                }
   4.100 -            });
   4.101 -        }
   4.102 +        } // queue
   4.103      }
   4.104  
   4.105      protected long remainingToRead() {
     5.1 --- a/src/share/classes/sun/net/www/http/KeepAliveStreamCleaner.java	Tue Sep 22 17:01:08 2009 +0100
     5.2 +++ b/src/share/classes/sun/net/www/http/KeepAliveStreamCleaner.java	Tue Sep 22 17:16:30 2009 +0100
     5.3 @@ -25,9 +25,8 @@
     5.4  
     5.5  package sun.net.www.http;
     5.6  
     5.7 -import java.util.concurrent.LinkedBlockingQueue;
     5.8 -import java.util.concurrent.TimeUnit;
     5.9  import java.io.IOException;
    5.10 +import java.util.LinkedList;
    5.11  import sun.net.NetProperties;
    5.12  import java.security.AccessController;
    5.13  import java.security.PrivilegedAction;
    5.14 @@ -44,7 +43,9 @@
    5.15   */
    5.16  
    5.17  @SuppressWarnings("serial")  // never serialized
    5.18 -public class KeepAliveStreamCleaner extends LinkedBlockingQueue<KeepAliveCleanerEntry> implements Runnable
    5.19 +class KeepAliveStreamCleaner
    5.20 +    extends LinkedList<KeepAliveCleanerEntry>
    5.21 +    implements Runnable
    5.22  {
    5.23      // maximum amount of remaining data that we will try to cleanup
    5.24      protected static int MAX_DATA_REMAINING = 512;
    5.25 @@ -78,23 +79,39 @@
    5.26      }
    5.27  
    5.28  
    5.29 -    public KeepAliveStreamCleaner()
    5.30 -    {
    5.31 -        super(MAX_CAPACITY);
    5.32 +    @Override
    5.33 +    public boolean offer(KeepAliveCleanerEntry e) {
    5.34 +        if (size() >= MAX_CAPACITY)
    5.35 +            return false;
    5.36 +
    5.37 +        return super.offer(e);
    5.38      }
    5.39  
    5.40 -    public KeepAliveStreamCleaner(int capacity)
    5.41 -    {
    5.42 -        super(capacity);
    5.43 -    }
    5.44 -
    5.45 +    @Override
    5.46      public void run()
    5.47      {
    5.48          KeepAliveCleanerEntry kace = null;
    5.49  
    5.50          do {
    5.51              try {
    5.52 -                kace = poll((long)TIMEOUT, TimeUnit.MILLISECONDS);
    5.53 +                synchronized(this) {
    5.54 +                    long before = System.currentTimeMillis();
    5.55 +                    long timeout = TIMEOUT;
    5.56 +                    while ((kace = poll()) == null) {
    5.57 +                        this.wait(timeout);
    5.58 +
    5.59 +                        long after = System.currentTimeMillis();
    5.60 +                        long elapsed = after - before;
    5.61 +                        if (elapsed > timeout) {
    5.62 +                            /* one last try */
    5.63 +                            kace = poll();
    5.64 +                            break;
    5.65 +                        }
    5.66 +                        before = after;
    5.67 +                        timeout -= elapsed;
    5.68 +                    }
    5.69 +                }
    5.70 +
    5.71                  if(kace == null)
    5.72                      break;
    5.73  
     6.1 --- a/src/share/classes/sun/net/www/protocol/http/HttpLogFormatter.java	Tue Sep 22 17:01:08 2009 +0100
     6.2 +++ b/src/share/classes/sun/net/www/protocol/http/HttpLogFormatter.java	Tue Sep 22 17:16:30 2009 +0100
     6.3 @@ -49,8 +49,10 @@
     6.4  
     6.5      @Override
     6.6      public String format(LogRecord record) {
     6.7 -        if (!"sun.net.www.http.HttpCapture".equalsIgnoreCase(record.getSourceClassName())) {
     6.8 -            // Don't change format for stuff that doesn't concern us
     6.9 +        String sourceClassName = record.getSourceClassName();
    6.10 +        if (sourceClassName == null ||
    6.11 +            !(sourceClassName.startsWith("sun.net.www.protocol.http") ||
    6.12 +              sourceClassName.startsWith("sun.net.www.http"))) {
    6.13              return super.format(record);
    6.14          }
    6.15          String src = record.getMessage();
     7.1 --- a/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java	Tue Sep 22 17:01:08 2009 +0100
     7.2 +++ b/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java	Tue Sep 22 17:16:30 2009 +0100
     7.3 @@ -57,7 +57,7 @@
     7.4  import sun.net.www.http.PosterOutputStream;
     7.5  import sun.net.www.http.ChunkedInputStream;
     7.6  import sun.net.www.http.ChunkedOutputStream;
     7.7 -import sun.net.www.http.HttpCapture;
     7.8 +import sun.util.logging.PlatformLogger;
     7.9  import java.text.SimpleDateFormat;
    7.10  import java.util.TimeZone;
    7.11  import java.net.MalformedURLException;
    7.12 @@ -292,6 +292,10 @@
    7.13      private int connectTimeout = -1;
    7.14      private int readTimeout = -1;
    7.15  
    7.16 +    /* Logging support */
    7.17 +    private static final PlatformLogger logger =
    7.18 +            PlatformLogger.getLogger("sun.net.www.protocol.http.HttpURLConnection");
    7.19 +
    7.20      /*
    7.21       * privileged request password authentication
    7.22       *
    7.23 @@ -309,20 +313,25 @@
    7.24          return java.security.AccessController.doPrivileged(
    7.25              new java.security.PrivilegedAction<PasswordAuthentication>() {
    7.26                  public PasswordAuthentication run() {
    7.27 -                    if (HttpCapture.isLoggable("FINEST")) {
    7.28 -                        HttpCapture.finest("Requesting Authentication: host =" + host + " url = " + url);
    7.29 +                    if (logger.isLoggable(PlatformLogger.FINEST)) {
    7.30 +                        logger.finest("Requesting Authentication: host =" + host + " url = " + url);
    7.31                      }
    7.32                      PasswordAuthentication pass = Authenticator.requestPasswordAuthentication(
    7.33                          host, addr, port, protocol,
    7.34                          prompt, scheme, url, authType);
    7.35 -                    if (HttpCapture.isLoggable("FINEST")) {
    7.36 -                        HttpCapture.finest("Authentication returned: " + (pass != null ? pass.toString() : "null"));
    7.37 +                    if (logger.isLoggable(PlatformLogger.FINEST)) {
    7.38 +                        logger.finest("Authentication returned: " + (pass != null ? pass.toString() : "null"));
    7.39                      }
    7.40                      return pass;
    7.41                  }
    7.42              });
    7.43      }
    7.44  
    7.45 +    /* Logging support */
    7.46 +    public static PlatformLogger getHttpLogger() {
    7.47 +        return logger;
    7.48 +    }
    7.49 +
    7.50      /*
    7.51       * checks the validity of http message header and throws
    7.52       * IllegalArgumentException if invalid.
    7.53 @@ -471,8 +480,8 @@
    7.54  
    7.55              setRequests=true;
    7.56          }
    7.57 -        if (HttpCapture.isLoggable("FINE")) {
    7.58 -            HttpCapture.fine(requests.toString());
    7.59 +        if (logger.isLoggable(PlatformLogger.FINE)) {
    7.60 +            logger.fine(requests.toString());
    7.61          }
    7.62          http.writeRequests(requests, poster);
    7.63          if (ps.checkError()) {
    7.64 @@ -736,9 +745,9 @@
    7.65                          && !(cachedResponse instanceof SecureCacheResponse)) {
    7.66                          cachedResponse = null;
    7.67                      }
    7.68 -                    if (HttpCapture.isLoggable("FINEST")) {
    7.69 -                        HttpCapture.finest("Cache Request for " + uri + " / " + getRequestMethod());
    7.70 -                        HttpCapture.finest("From cache: " + (cachedResponse != null ? cachedResponse.toString() : "null"));
    7.71 +                    if (logger.isLoggable(PlatformLogger.FINEST)) {
    7.72 +                        logger.finest("Cache Request for " + uri + " / " + getRequestMethod());
    7.73 +                        logger.finest("From cache: " + (cachedResponse != null ? cachedResponse.toString() : "null"));
    7.74                      }
    7.75                      if (cachedResponse != null) {
    7.76                          cachedHeaders = mapToMessageHeader(cachedResponse.getHeaders());
    7.77 @@ -777,8 +786,8 @@
    7.78                               });
    7.79                  if (sel != null) {
    7.80                      URI uri = sun.net.www.ParseUtil.toURI(url);
    7.81 -                    if (HttpCapture.isLoggable("FINEST")) {
    7.82 -                        HttpCapture.finest("ProxySelector Request for " + uri);
    7.83 +                    if (logger.isLoggable(PlatformLogger.FINEST)) {
    7.84 +                        logger.finest("ProxySelector Request for " + uri);
    7.85                      }
    7.86                      Iterator<Proxy> it = sel.select(uri).iterator();
    7.87                      Proxy p;
    7.88 @@ -794,9 +803,9 @@
    7.89                                  http = getNewHttpClient(url, p, connectTimeout, false);
    7.90                                  http.setReadTimeout(readTimeout);
    7.91                              }
    7.92 -                            if (HttpCapture.isLoggable("FINEST")) {
    7.93 +                            if (logger.isLoggable(PlatformLogger.FINEST)) {
    7.94                                  if (p != null) {
    7.95 -                                    HttpCapture.finest("Proxy used: " + p.toString());
    7.96 +                                    logger.finest("Proxy used: " + p.toString());
    7.97                                  }
    7.98                              }
    7.99                              break;
   7.100 @@ -1026,15 +1035,15 @@
   7.101  
   7.102              URI uri = ParseUtil.toURI(url);
   7.103              if (uri != null) {
   7.104 -                if (HttpCapture.isLoggable("FINEST")) {
   7.105 -                    HttpCapture.finest("CookieHandler request for " + uri);
   7.106 +                if (logger.isLoggable(PlatformLogger.FINEST)) {
   7.107 +                    logger.finest("CookieHandler request for " + uri);
   7.108                  }
   7.109                  Map<String, List<String>> cookies
   7.110                      = cookieHandler.get(
   7.111                          uri, requests.getHeaders(EXCLUDE_HEADERS));
   7.112                  if (!cookies.isEmpty()) {
   7.113 -                    if (HttpCapture.isLoggable("FINEST")) {
   7.114 -                        HttpCapture.finest("Cookies retrieved: " + cookies.toString());
   7.115 +                    if (logger.isLoggable(PlatformLogger.FINEST)) {
   7.116 +                        logger.finest("Cookies retrieved: " + cookies.toString());
   7.117                      }
   7.118                      for (Map.Entry<String, List<String>> entry :
   7.119                               cookies.entrySet()) {
   7.120 @@ -1165,8 +1174,8 @@
   7.121                      writeRequests();
   7.122                  }
   7.123                  http.parseHTTP(responses, pi, this);
   7.124 -                if (HttpCapture.isLoggable("FINE")) {
   7.125 -                    HttpCapture.fine(responses.toString());
   7.126 +                if (logger.isLoggable(PlatformLogger.FINE)) {
   7.127 +                    logger.fine(responses.toString());
   7.128                  }
   7.129                  inputStream = http.getInputStream();
   7.130  
   7.131 @@ -1610,8 +1619,8 @@
   7.132                  http.parseHTTP(responses, null, this);
   7.133  
   7.134                  /* Log the response to the CONNECT */
   7.135 -                if (HttpCapture.isLoggable("FINE")) {
   7.136 -                    HttpCapture.fine(responses.toString());
   7.137 +                if (logger.isLoggable(PlatformLogger.FINE)) {
   7.138 +                    logger.fine(responses.toString());
   7.139                  }
   7.140  
   7.141                  statusLine = responses.getValue(0);
   7.142 @@ -1738,8 +1747,8 @@
   7.143          setPreemptiveProxyAuthentication(requests);
   7.144  
   7.145           /* Log the CONNECT request */
   7.146 -        if (HttpCapture.isLoggable("FINE")) {
   7.147 -            HttpCapture.fine(requests.toString());
   7.148 +        if (logger.isLoggable(PlatformLogger.FINE)) {
   7.149 +            logger.fine(requests.toString());
   7.150          }
   7.151  
   7.152          http.writeRequests(requests, null);
   7.153 @@ -1852,7 +1861,7 @@
   7.154                          }
   7.155                          a = null;
   7.156                          if (tryTransparentNTLMProxy) {
   7.157 -                            HttpCapture.finest("Trying Transparent NTLM authentication");
   7.158 +                            logger.finest("Trying Transparent NTLM authentication");
   7.159                          } else {
   7.160                              a = privilegedRequestPasswordAuthentication(
   7.161                                                  host, null, port, url.getProtocol(),
   7.162 @@ -1880,7 +1889,7 @@
   7.163                      ret = new NegotiateAuthentication(new HttpCallerInfo(authhdr.getHttpCallerInfo(), "Kerberos"));
   7.164                      break;
   7.165                  case UNKNOWN:
   7.166 -                    HttpCapture.finest("Unknown/Unsupported authentication scheme: " + scheme);
   7.167 +                    logger.finest("Unknown/Unsupported authentication scheme: " + scheme);
   7.168                  default:
   7.169                      throw new AssertionError("should not reach here");
   7.170                  }
   7.171 @@ -1906,8 +1915,8 @@
   7.172                  }
   7.173              }
   7.174          }
   7.175 -        if (HttpCapture.isLoggable("FINER")) {
   7.176 -            HttpCapture.finer("Proxy Authentication for " + authhdr.toString() +" returned " + (ret != null ? ret.toString() : "null"));
   7.177 +        if (logger.isLoggable(PlatformLogger.FINER)) {
   7.178 +            logger.finer("Proxy Authentication for " + authhdr.toString() +" returned " + (ret != null ? ret.toString() : "null"));
   7.179          }
   7.180          return ret;
   7.181      }
   7.182 @@ -2004,7 +2013,7 @@
   7.183                          }
   7.184                          a = null;
   7.185                          if (tryTransparentNTLMServer) {
   7.186 -                            HttpCapture.finest("Trying Transparent NTLM authentication");
   7.187 +                            logger.finest("Trying Transparent NTLM authentication");
   7.188                          } else {
   7.189                              a = privilegedRequestPasswordAuthentication(
   7.190                                  url.getHost(), addr, port, url.getProtocol(),
   7.191 @@ -2027,7 +2036,7 @@
   7.192                      }
   7.193                      break;
   7.194                  case UNKNOWN:
   7.195 -                    HttpCapture.finest("Unknown/Unsupported authentication scheme: " + scheme);
   7.196 +                    logger.finest("Unknown/Unsupported authentication scheme: " + scheme);
   7.197                  default:
   7.198                      throw new AssertionError("should not reach here");
   7.199                  }
   7.200 @@ -2051,8 +2060,8 @@
   7.201                  }
   7.202              }
   7.203          }
   7.204 -        if (HttpCapture.isLoggable("FINER")) {
   7.205 -            HttpCapture.finer("Server Authentication for " + authhdr.toString() +" returned " + (ret != null ? ret.toString() : "null"));
   7.206 +        if (logger.isLoggable(PlatformLogger.FINER)) {
   7.207 +            logger.finer("Server Authentication for " + authhdr.toString() +" returned " + (ret != null ? ret.toString() : "null"));
   7.208          }
   7.209          return ret;
   7.210      }
   7.211 @@ -2127,8 +2136,8 @@
   7.212          if (streaming()) {
   7.213              throw new HttpRetryException (RETRY_MSG3, stat, loc);
   7.214          }
   7.215 -        if (HttpCapture.isLoggable("FINE")) {
   7.216 -            HttpCapture.fine("Redirected from " + url + " to " + locUrl);
   7.217 +        if (logger.isLoggable(PlatformLogger.FINE)) {
   7.218 +            logger.fine("Redirected from " + url + " to " + locUrl);
   7.219          }
   7.220  
   7.221          // clear out old response headers!!!!
     8.1 --- a/src/share/classes/sun/net/www/protocol/http/NTLMAuthenticationProxy.java	Tue Sep 22 17:01:08 2009 +0100
     8.2 +++ b/src/share/classes/sun/net/www/protocol/http/NTLMAuthenticationProxy.java	Tue Sep 22 17:16:30 2009 +0100
     8.3 @@ -28,7 +28,7 @@
     8.4  import java.net.PasswordAuthentication;
     8.5  import java.lang.reflect.Constructor;
     8.6  import java.lang.reflect.Method;
     8.7 -import sun.net.www.http.HttpCapture;
     8.8 +import sun.util.logging.PlatformLogger;
     8.9  
    8.10  /**
    8.11   * Proxy class for loading NTLMAuthentication, so as to remove static
    8.12 @@ -59,7 +59,7 @@
    8.13          try {
    8.14              return threeArgCtr.newInstance(isProxy, url, pw);
    8.15          } catch (ReflectiveOperationException roe) {
    8.16 -            log(roe);
    8.17 +            finest(roe);
    8.18          }
    8.19  
    8.20          return null;
    8.21 @@ -72,7 +72,7 @@
    8.22          try {
    8.23              return fiveArgCtr.newInstance(isProxy, host, port, pw);
    8.24          } catch (ReflectiveOperationException roe) {
    8.25 -            log(roe);
    8.26 +            finest(roe);
    8.27          }
    8.28  
    8.29          return null;
    8.30 @@ -86,7 +86,7 @@
    8.31          try {
    8.32              return (Boolean)method.invoke(null);
    8.33          } catch (ReflectiveOperationException roe) {
    8.34 -            log(roe);
    8.35 +            finest(roe);
    8.36          }
    8.37  
    8.38          return false;
    8.39 @@ -116,7 +116,7 @@
    8.40                                                     fiveArg);
    8.41              }
    8.42          } catch (ClassNotFoundException cnfe) {
    8.43 -            log(cnfe);
    8.44 +            finest(cnfe);
    8.45          } catch (ReflectiveOperationException roe) {
    8.46              throw new AssertionError(roe);
    8.47          }
    8.48 @@ -124,9 +124,8 @@
    8.49          return null;
    8.50      }
    8.51  
    8.52 -    static void log(Exception e) {
    8.53 -        if (HttpCapture.isLoggable("FINEST")) {
    8.54 -            HttpCapture.finest("NTLMAuthenticationProxy: " + e);
    8.55 -        }
    8.56 +    static void finest(Exception e) {
    8.57 +        PlatformLogger logger = HttpURLConnection.getHttpLogger();
    8.58 +        logger.finest("NTLMAuthenticationProxy: " + e);
    8.59      }
    8.60  }
     9.1 --- a/src/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java	Tue Sep 22 17:01:08 2009 +0100
     9.2 +++ b/src/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java	Tue Sep 22 17:16:30 2009 +0100
     9.3 @@ -30,12 +30,12 @@
     9.4  import sun.net.www.HeaderParser;
     9.5  import sun.misc.BASE64Decoder;
     9.6  import sun.misc.BASE64Encoder;
     9.7 +import sun.util.logging.PlatformLogger;
     9.8  
     9.9  import java.net.URL;
    9.10  import java.io.IOException;
    9.11  import java.net.Authenticator.RequestorType;
    9.12  import java.lang.reflect.Constructor;
    9.13 -import sun.net.www.http.HttpCapture;
    9.14  import static sun.net.www.protocol.http.AuthScheme.NEGOTIATE;
    9.15  import static sun.net.www.protocol.http.AuthScheme.KERBEROS;
    9.16  
    9.17 @@ -258,7 +258,7 @@
    9.18              clazz = Class.forName("sun.net.www.protocol.http.NegotiatorImpl", true, null);
    9.19              c = clazz.getConstructor(HttpCallerInfo.class);
    9.20          } catch (ClassNotFoundException cnfe) {
    9.21 -            log(cnfe);
    9.22 +            finest(cnfe);
    9.23              throw cnfe;
    9.24          } catch (ReflectiveOperationException roe) {
    9.25              // if the class is there then something seriously wrong if
    9.26 @@ -269,10 +269,10 @@
    9.27          try {
    9.28              return (Negotiator) (c.newInstance(hci));
    9.29          } catch (ReflectiveOperationException roe) {
    9.30 -            log(roe);
    9.31 +            finest(roe);
    9.32              Throwable t = roe.getCause();
    9.33              if (t != null && t instanceof Exception)
    9.34 -                log((Exception)t);
    9.35 +                finest((Exception)t);
    9.36              throw roe;
    9.37          }
    9.38      }
    9.39 @@ -281,9 +281,8 @@
    9.40  
    9.41      abstract byte[] nextToken(byte[] in) throws IOException;
    9.42  
    9.43 -    static void log(Exception e) {
    9.44 -        if (HttpCapture.isLoggable("FINEST")) {
    9.45 -            HttpCapture.finest("NegotiateAuthentication: " + e);
    9.46 -        }
    9.47 +    static void finest(Exception e) {
    9.48 +        PlatformLogger logger = HttpURLConnection.getHttpLogger();
    9.49 +        logger.finest("NegotiateAuthentication: " + e);
    9.50      }
    9.51  }
    10.1 --- a/src/share/classes/sun/util/logging/PlatformLogger.java	Tue Sep 22 17:01:08 2009 +0100
    10.2 +++ b/src/share/classes/sun/util/logging/PlatformLogger.java	Tue Sep 22 17:16:30 2009 +0100
    10.3 @@ -29,15 +29,15 @@
    10.4  import java.lang.ref.WeakReference;
    10.5  import java.lang.reflect.InvocationTargetException;
    10.6  import java.lang.reflect.Method;
    10.7 -import java.io.File;
    10.8  import java.io.PrintStream;
    10.9  import java.io.PrintWriter;
   10.10  import java.io.StringWriter;
   10.11  import java.security.AccessController;
   10.12  import java.security.PrivilegedAction;
   10.13  import java.text.MessageFormat;
   10.14 -import java.util.logging.Logger;
   10.15 -import java.util.*;
   10.16 +import java.util.Date;
   10.17 +import java.util.HashMap;
   10.18 +import java.util.Map;
   10.19  import sun.misc.JavaLangAccess;
   10.20  import sun.misc.SharedSecrets;
   10.21  
   10.22 @@ -493,6 +493,7 @@
   10.23          private static final Method getLoggerMethod;
   10.24          private static final Method setLevelMethod;
   10.25          private static final Method getLevelMethod;
   10.26 +        private static final Method isLoggableMethod;
   10.27          private static final Method logMethod;
   10.28          private static final Method logThrowMethod;
   10.29          private static final Method logParamsMethod;
   10.30 @@ -505,6 +506,7 @@
   10.31              getLoggerMethod = getMethod(loggerClass, "getLogger", String.class);
   10.32              setLevelMethod = getMethod(loggerClass, "setLevel", levelClass);
   10.33              getLevelMethod = getMethod(loggerClass, "getLevel");
   10.34 +            isLoggableMethod = getMethod(loggerClass, "isLoggable", levelClass);
   10.35              logMethod = getMethod(loggerClass, "log", levelClass, String.class);
   10.36              logThrowMethod = getMethod(loggerClass, "log", levelClass, String.class, Throwable.class);
   10.37              logParamsMethod = getMethod(loggerClass, "log", levelClass, String.class, Object[].class);
   10.38 @@ -608,6 +610,10 @@
   10.39              levelValue = newLevel;
   10.40              invoke(setLevelMethod, javaLogger, levelObjects.get(newLevel));
   10.41          }
   10.42 +
   10.43 +        public boolean isLoggable(int level) {
   10.44 +            return (Boolean) invoke(isLoggableMethod, javaLogger, levelObjects.get(level));
   10.45 +        }
   10.46      }
   10.47  
   10.48