8261938: ASN1Formatter.annotate should not return in the finally block #2620
Conversation
/issue add JDK-8261938 |
|
@DamonFool This issue is referenced in the PR title - it will now be updated. |
@DamonFool |
@DamonFool The |
Webrevs
|
An EOFException can occur during the call to annotate() and must return the accumulated contents of the StringBuffer. Otherwise it is discarded. |
Thanks @RogerRiggs for your review. Just want to make sure:
Thanks. |
The formattters are a test component used both standalone and in the context of the HexPrinter test utilities. Formatters are designed to be nested, where one formatter can call another and the valuable output If an exception was thrown, it would still return useful information about the stream to that point. |
Got it. Updated. |
Catching and ignoring the exception has the same behavior as handling it with finally. |
@DamonFool This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 26 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.
|
Thanks @RogerRiggs . |
@DamonFool Since your change was applied there have been 33 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit b10376b. |
Hi all,
ASN1Formatter.annotate should be able to throw an IOException according to this comment [1].
But it fails to do so due to the return [2] in the finally block, which would swallow the IOException.
Generally, it seems not good to put a return statement in a finally block because it would overwrite other return-statements or Exceptions [3].
Thanks.
Best regards,
Jie
[1] https://github.com/openjdk/jdk/blob/master/test/lib/jdk/test/lib/hexdump/ASN1Formatter.java#L113
[2] https://github.com/openjdk/jdk/blob/master/test/lib/jdk/test/lib/hexdump/ASN1Formatter.java#L120
[3] https://stackoverflow.com/questions/17481251/finally-block-does-not-complete-normally-eclipse-warning
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/2620/head:pull/2620
$ git checkout pull/2620