test/jdk/sun/security/ssl/AppOutputStream/NoExceptionOnClose.java
changeset 50768 68fa3d4026ea
parent 47216 71c04702a3d5
equal deleted inserted replaced
50767:356eaea05bf0 50768:68fa3d4026ea
     1 /*
     1 /*
     2  * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
       
    24 //
       
    25 // SunJSSE does not support dynamic system properties, no way to re-use
       
    26 // system properties in samevm/agentvm mode.
       
    27 //
       
    28 
    24 /*
    29 /*
    25  * @test 1.3 01/03/08
    30  * @test 1.3 01/03/08
    26  * @bug 4378397
    31  * @bug 4378397
    27  * @summary  JSSE socket output stream doesn't throw after socket is closed
    32  * @summary  JSSE socket output stream doesn't throw after socket is closed
    28  * @run main/othervm NoExceptionOnClose
    33  * @run main/othervm NoExceptionOnClose
    29  *
       
    30  *     SunJSSE does not support dynamic system properties, no way to re-use
       
    31  *     system properties in samevm/agentvm mode.
       
    32  * @author Jaya Hangal
    34  * @author Jaya Hangal
    33  */
    35  */
    34 
    36 
    35 import java.io.*;
    37 import java.io.*;
    36 import java.net.*;
    38 import java.net.*;
   150          */
   152          */
   151         boolean isSocketClosedThrown = false;
   153         boolean isSocketClosedThrown = false;
   152         try {
   154         try {
   153             sslOS.write(22);
   155             sslOS.write(22);
   154             sslOS.flush();
   156             sslOS.flush();
   155         } catch (SocketException socketClosed) {
   157         } catch (SSLException | SocketException socketClosed) {
   156                 System.out.println("Received \"" + socketClosed.getMessage()
   158                 System.out.println("Received \"" + socketClosed.getMessage()
   157                         + "\" exception as expected");
   159                         + "\" exception as expected");
   158                 isSocketClosedThrown = true;
   160                 isSocketClosedThrown = true;
   159           }
   161         }
   160         if (!isSocketClosedThrown) {
   162         if (!isSocketClosedThrown) {
   161                 throw new Exception("No Exception thrown on write() after"
   163                 throw new Exception("No Exception thrown on write() after"
   162                                 + " close()");
   164                                 + " close()");
   163         }
   165         }
   164     }
   166     }