File tree Expand file tree Collapse file tree 1 file changed +2
-11
lines changed
pdfbox/src/test/java/org/apache/pdfbox/encryption Expand file tree Collapse file tree 1 file changed +2
-11
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments