Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8215443

The use of TransportContext.fatal() leads to bad coding style

    XMLWordPrintable

    Details

      Backports

        Description

        The TransportContext.fatal() always throw exception. The code that use the method looks a little bit unusual:

             shc.conContext.fatal(Alert.UNEXPECTED_MESSAGE, "...");
             return null; // make the complier happy

        The return statement is never get executed. However, if remove the return statement, the compiler may not happy with it, or the code reader will continue read more of the code and lead to confusing logic.

        Maybe, using throw statement directly could be an alternative improvement:
        - shc.conContext.fatal(Alert.UNEXPECTED_MESSAGE, "...");
        - return null; // make the complier happy
        + throw shc.conContext.fatal(Alert.UNEXPECTED_MESSAGE, "...");

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                xuelei Xue-Lei Fan
                Reporter:
                xuelei Xue-Lei Fan
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: