Skip to content

Commit 2ef672d

Browse files
committed
PDFBOX-5660: close input, as suggested by Valery Bokov; closes #343
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1929856 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3db0267 commit 2ef672d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

xmpbox/src/test/java/org/apache/xmpbox/TestXMPWithUndefinedSchemas.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@
2525
import static org.junit.jupiter.api.Assertions.assertFalse;
2626
import static org.junit.jupiter.api.Assertions.assertEquals;
2727

28-
28+
import java.io.IOException;
2929
import java.io.InputStream;
3030
import java.util.stream.Stream;
31-
import org.apache.xmpbox.type.BadFieldValueException;
32-
3331

32+
import org.apache.xmpbox.type.BadFieldValueException;
3433
import org.apache.xmpbox.xml.DomXmpParser;
3534
import org.apache.xmpbox.xml.XmpParsingException;
3635
import org.junit.jupiter.params.ParameterizedTest;
@@ -49,13 +48,15 @@ static Stream<Arguments> initializeParameters()
4948
@ParameterizedTest
5049
@MethodSource("initializeParameters")
5150
void main(String path, String namespace, String propertyName, String propertyValue)
52-
throws XmpParsingException, BadFieldValueException
51+
throws XmpParsingException, BadFieldValueException, IOException
5352
{
54-
InputStream is = this.getClass().getResourceAsStream(path);
55-
5653
DomXmpParser builder = new DomXmpParser();
5754
builder.setStrictParsing(false);
58-
XMPMetadata rxmp = builder.parse(is);
55+
XMPMetadata rxmp;
56+
try (InputStream is = this.getClass().getResourceAsStream(path))
57+
{
58+
rxmp = builder.parse(is);
59+
}
5960
// ensure basic parsing was OK
6061
assertFalse(rxmp.getAllSchemas().isEmpty(), "There should be a least one schema");
6162
assertNotNull(rxmp.getSchema(namespace), "The schema for {" + namespace + "} should be available");

0 commit comments

Comments
 (0)