http-client-branch: relax server side exception handling in CancelledResponse test http-client-branch
authordfuchs
Fri, 24 Nov 2017 12:10:19 +0000
branchhttp-client-branch
changeset 55866 93e8ef0ff08e
parent 55865 dcd1cd2019e8
child 55867 1b8734a5c696
http-client-branch: relax server side exception handling in CancelledResponse test
src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Exchange.java
test/jdk/java/net/httpclient/CancelledResponse.java
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Exchange.java	Thu Nov 23 19:08:06 2017 +0000
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Exchange.java	Fri Nov 24 12:10:19 2017 +0000
@@ -475,42 +475,10 @@
         return null;
     }
 
-//    HttpClient.Redirect followRedirects() {
-//        return client.followRedirects();
-//    }
-
     HttpClient.Version version() {
         return multi.version();
     }
 
-//    private static SocketPermission getSocketPermissionFor(URI url) {
-//        if (System.getSecurityManager() == null) {
-//            return null;
-//        }
-//
-//        StringBuilder sb = new StringBuilder();
-//        String host = url.getHost();
-//        sb.append(host);
-//        int port = url.getPort();
-//        if (port == -1) {
-//            String scheme = url.getScheme();
-//            if ("http".equals(scheme)) {
-//                sb.append(":80");
-//            } else { // scheme must be https
-//                sb.append(":443");
-//            }
-//        } else {
-//            sb.append(':')
-//              .append(Integer.toString(port));
-//        }
-//        String target = sb.toString();
-//        return new SocketPermission(target, "connect");
-//    }
-
-//    AccessControlContext getAccessControlContext() {
-//        return acc;
-//    }
-
     String dbgString() {
         return dbgTag;
     }
--- a/test/jdk/java/net/httpclient/CancelledResponse.java	Thu Nov 23 19:08:06 2017 +0000
+++ b/test/jdk/java/net/httpclient/CancelledResponse.java	Fri Nov 24 12:10:19 2017 +0000
@@ -319,20 +319,17 @@
                 }
                 out.println("sent " + s);
             } catch (SSLException | SocketException x) {
-                if (x instanceof SocketException
-                        || x.getCause() instanceof SocketException) {
-                    // if SSL then we might get a "Broken Pipe", otherwise
-                    // a "Socket closed".
-                    boolean expected = cancelled.get();
-                    if (sent > 0 && expected) {
-                        System.out.println("Connection closed by peer as expected: " + x);
-                        return;
-                    } else {
-                        System.out.println("Unexpected exception (sent="
+                // if SSL then we might get a "Broken Pipe", otherwise
+                // a "Socket closed".
+                boolean expected = cancelled.get();
+                if (sent > 0 && expected) {
+                    System.out.println("Connection closed by peer as expected: " + x);
+                    return;
+                } else {
+                    System.out.println("Unexpected exception (sent="
                             + sent + ", cancelled=" + expected + "): " + x);
-                    }
+                    throw new RuntimeException(x);
                 }
-                throw new RuntimeException(x);
             } catch (IOException | InterruptedException e) {
                 throw new RuntimeException(e);
             }