8261938: ASN1Formatter.annotate should not return in the finally block
Reviewed-by: rriggs
This commit is contained in:
parent
977a21add8
commit
b10376bac1
@ -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 @@ public class ASN1Formatter implements HexPrinter.Formatter {
|
||||
* 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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user