diff --git a/src/main/java/io/ebeaninternal/dbmigration/migrationreader/MigrationXmlReader.java b/src/main/java/io/ebeaninternal/dbmigration/migrationreader/MigrationXmlReader.java index a5b534298..e93260ba9 100644 --- a/src/main/java/io/ebeaninternal/dbmigration/migrationreader/MigrationXmlReader.java +++ b/src/main/java/io/ebeaninternal/dbmigration/migrationreader/MigrationXmlReader.java @@ -24,12 +24,14 @@ public class MigrationXmlReader { */ public static Migration read(String resourcePath) { - InputStream is = MigrationXmlReader.class.getResourceAsStream(resourcePath); - if (is == null) { - throw new IllegalArgumentException("No resource found for path [" + resourcePath + "]"); + try (InputStream is = MigrationXmlReader.class.getResourceAsStream(resourcePath)) { + if (is == null) { + throw new IllegalArgumentException("No resource found for path [" + resourcePath + "]"); + } + return read(is); + } catch (IOException e) { + throw new IllegalArgumentException("Failed to auto close resource " + resourcePath, e); } - - return read(is); } /**