< prev index next >

src/java.net.http/share/classes/jdk/internal/net/http/AuthenticationFilter.java

Print this page
rev 54081 : 8265099: Revert backport to 11u of 8236859: WebSocket over authenticating proxy fails with NPE
Summary: Revert https://hg.openjdk.java.net/jdk-updates/jdk11u-dev/rev/57e3fa3574ec
Reviewed-by:

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -238,26 +238,23 @@
         Cache cache = getCache(exchange);
         int status = r.statusCode();
         HttpHeaders hdrs = r.headers();
         HttpRequestImpl req = r.request();
 
-        if (status != PROXY_UNAUTHORIZED){
+        if (status != UNAUTHORIZED && status != PROXY_UNAUTHORIZED) {
+            // check if any authentication succeeded for first time
+            if (exchange.serverauth != null && !exchange.serverauth.fromcache) {
+                AuthInfo au = exchange.serverauth;
+                cache.store(au.scheme, req.uri(), false, au.credentials);
+            }
             if (exchange.proxyauth != null && !exchange.proxyauth.fromcache) {
                 AuthInfo au = exchange.proxyauth;
                 URI proxyURI = getProxyURI(req);
                 if (proxyURI != null) {
-                    exchange.proxyauth = null;
                     cache.store(au.scheme, proxyURI, true, au.credentials);
                 }
             }
-            if (status != UNAUTHORIZED) {
-            // check if any authentication succeeded for first time
-                if (exchange.serverauth != null && !exchange.serverauth.fromcache) {
-                    AuthInfo au = exchange.serverauth;
-                    cache.store(au.scheme, req.uri(), false, au.credentials);
-                }
-            }
             return null;
         }
 
         boolean proxy = status == PROXY_UNAUTHORIZED;
         String authname = proxy ? "Proxy-Authenticate" : "WWW-Authenticate";
< prev index next >