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

Anthony Scarpino anthony.scarpino at oracle.com
Mon Dec 17 21:17:32 UTC 2018


It looks like in TransportContext.java:68, you had a mistype that added 
"fa" to the end of a comment.

Also in fatal():267, did you plan to return the exception and have the 
calling method throw the exception?  As is, the exception is never 
return and fatal() continues to throw the exceptions.

Tony

On 12/15/18 7:51 AM, Xue-Lei Fan wrote:
> 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