Skip to content

Commit 94f5a4b

Browse files
committed
PDFBOX-5660: Sonar fix
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1924905 13f79535-47bb-0310-9956-ffa450edef68
1 parent 6b772c3 commit 94f5a4b

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

pdfbox/src/test/java/org/apache/pdfbox/encryption/TestPublicKeyEncryption.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,9 @@ void testProtectionError(int keyLength) throws Exception
168168
policy.setEncryptionKeyLength(keyLength);
169169
document.protect(policy);
170170

171-
PDDocument encryptedDoc = null;
172-
try
171+
File file = save("testProtectionError");
172+
try (PDDocument encryptedDoc = reload(file, password2, getKeyStore(keyStore2)))
173173
{
174-
File file = save("testProtectionError");
175-
encryptedDoc = reload(file, password2, getKeyStore(keyStore2));
176174
assertTrue(encryptedDoc.isEncrypted());
177175
fail("No exception when using an incorrect decryption key");
178176
}
@@ -181,13 +179,6 @@ void testProtectionError(int keyLength) throws Exception
181179
String msg = ex.getMessage();
182180
assertTrue(msg.contains("serial-#: rid 2 vs. cert 3"), "not the expected exception: " + msg);
183181
}
184-
finally
185-
{
186-
if (encryptedDoc != null)
187-
{
188-
encryptedDoc.close();
189-
}
190-
}
191182
}
192183

193184

0 commit comments

Comments
 (0)