Code Review Request JDK-8215443: The use of TransportContext.fatal() leads to bad coding style

Xue-Lei Fan xuelei.fan at oracle.com
Sat Dec 15 15:51:37 UTC 2018


Hi,

Could I have the update reviewed?
    http://cr.openjdk.java.net/~xuelei/8215443/webrev.00/

The TransportContext.fatal() methods always throw exception. While the 
compiler does not aware of it, and may not happy without following a 
return statement.  Currently, a lot never executable return statements 
are inserted.  As make the code hard to read (thanks for Jamil and 
Tony's points).  For example:

     shc.conContext.fatal(Alert.UNEXPECTED_MESSAGE, ...);
     return null;    // fatal() always throws, make the compiler happy.

In this update, I changed the fatal() method with a return value:

-    void fatal(Alert alert, ...
+    SSLException fatal(Alert alert, ...

Then we can change the use of method as:

-    shc.conContext.fatal(Alert.UNEXPECTED_MESSAGE, ...);
-    return null;    // fatal() always throws, make the compiler happy.
+    throw shc.conContext.fatal(Alert.UNEXPECTED_MESSAGE, ...);

The changeset is mostly about removing the never executed return 
statements and add the 'throw' keyword to lines that use the fatal() 
methods.

Thanks,
Xuelei


More information about the security-dev mailing list