Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
8261938: ASN1Formatter.annotate should not return in the finally block
- Loading branch information
Showing
with
14 additions
and
5 deletions.
-
+14
−5
test/lib/jdk/test/lib/hexdump/ASN1Formatter.java
|
|
@@ -1,5 +1,5 @@ |
|
|
/* |
|
|
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. |
|
|
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. |
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
|
* |
|
|
* This code is free software; you can redistribute it and/or modify it |
|
@@ -110,15 +110,24 @@ private ASN1Formatter() { |
|
|
* A single well formed tagged-value is read and annotated. |
|
|
* |
|
|
* @param in a DataInputStream |
|
|
* @throws IOException if an I/O error occurs |
|
|
*/ |
|
|
public String annotate(DataInputStream in) throws IOException { |
|
|
public String annotate(DataInputStream in) { |
|
|
StringBuilder sb = new StringBuilder(); |
|
|
try { |
|
|
this.annotate(in, sb); |
|
|
} finally { |
|
|
return sb.toString(); |
|
|
} catch (IOException e) { |
|
|
/* |
|
|
* Formatters are designed to be nested, where one formatter can call another and the valuable output |
|
|
* is the formatted string that has been accumulated from the beginning of the stream. |
|
|
* |
|
|
* The choice of DataInputStream was chosen for the convenience of the methods to read different types. |
|
|
* and (declared) exceptions are an unwelcome artifact. |
|
|
* |
|
|
* If an exception was percolated up and the formatted output discarded, it would defeat the purpose. |
|
|
* So we just catch it here and still return useful information about the stream to this point. |
|
|
*/ |
|
|
} |
|
|
return sb.toString(); |
|
|
} |
|
|
|
|
|
/** |
|
|
This comment has been minimized.
b10376b
Review
Issues