diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2020-10-24 21:25:52 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2020-10-24 21:25:52 +0000 |
commit | 90bfac52d607c6a8499bfefe17d12d74253e5b7a (patch) | |
tree | 5fa940937c99a62fd667f8629d384496079b67da /src/ooxml | |
parent | ebdd3c37d42166c1318f819b37af23eb1ebb6a2e (diff) | |
download | poi-90bfac52d607c6a8499bfefe17d12d74253e5b7a.tar.gz poi-90bfac52d607c6a8499bfefe17d12d74253e5b7a.zip |
Sonar fixes - a few "Try-with-resources should be used"
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1882820 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml')
-rw-r--r-- | src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java index 5e1ee2fbe4..3c70649b97 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java +++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java @@ -50,7 +50,6 @@ import javax.xml.crypto.MarshalException; import org.apache.poi.poifs.crypt.dsig.SignatureConfig; import org.apache.poi.poifs.crypt.dsig.SignatureInfo; import org.apache.poi.poifs.crypt.dsig.services.RevocationData; -import org.apache.poi.util.IOUtils; import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogger; import org.apache.xml.security.c14n.Canonicalizer; @@ -315,18 +314,12 @@ public class XAdESXLSignatureFacet implements SignatureFacet { return null; } - try { - ASN1InputStream asn1IS1 = null, asn1IS2 = null; - try { - asn1IS1 = new ASN1InputStream(crlNumberExtensionValue); - ASN1OctetString octetString = (ASN1OctetString)asn1IS1.readObject(); - byte[] octets = octetString.getOctets(); - asn1IS2 = new ASN1InputStream(octets); - ASN1Integer integer = (ASN1Integer)asn1IS2.readObject(); + try (ASN1InputStream asn1IS1 = new ASN1InputStream(crlNumberExtensionValue)) { + ASN1OctetString octetString = (ASN1OctetString)asn1IS1.readObject(); + byte[] octets = octetString.getOctets(); + try (ASN1InputStream asn1IS2 = new ASN1InputStream(octets)) { + ASN1Integer integer = (ASN1Integer) asn1IS2.readObject(); return integer.getPositiveValue(); - } finally { - IOUtils.closeQuietly(asn1IS2); - IOUtils.closeQuietly(asn1IS1); } } catch (IOException e) { throw new RuntimeException("I/O error: " + e.getMessage(), e); |