Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning "Input stream has been finalized or forced closed without being explicitly closed" #2031

pzygielo opened this issue May 28, 2018 · 8 comments


Copy link

Which version and edition of Flyway are you using?

5.1.1 - with the issue reported
5.0.7 - without the issue reported

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

Integration test executed under maven with glassfish-embed.

Which database are you using (type & version)?

Apache Derby

Which operating system are you using?


What did you do? (Please include the content causing the issue, any relevant configuration settings, the SQL statement that failed (if relevant) and the command you ran.)

Upgraded dependency to flyway from 5.0.7 to 5.1.1, and went with mvn verify on my project as before.

What did you expect to see?

No warning quoted below.

What did you see instead?

May 28, 2018 10:59:25 PM com.sun.enterprise.loader.ASURLClassLoader$SentinelInputStream report
WARNING: Input stream has been finalized or forced closed without being explicitly closed; stream instantiation reported in following stack trace
at com.sun.enterprise.loader.ASURLClassLoader$SentinelInputStream.(
at com.sun.enterprise.loader.ASURLClassLoader.getResourceAsStream(
at org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource.loadAsString(
at org.flywaydb.core.internal.database.ExecutableSqlScript.(
at org.flywaydb.core.internal.database.derby.DerbySqlScript.(
at org.flywaydb.core.internal.database.derby.DerbyDatabase.doCreateSqlScript(
at org.flywaydb.core.internal.database.Database.createSqlScript(
at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.getSqlScript(
at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.executeInTransaction(
at org.flywaydb.core.internal.command.DbMigrate.isExecuteGroupInTransaction(
at org.flywaydb.core.internal.command.DbMigrate.applyMigrations(
at org.flywaydb.core.internal.command.DbMigrate.migrateGroup(
at org.flywaydb.core.internal.command.DbMigrate.access$100(
at org.flywaydb.core.internal.command.DbMigrate$
at org.flywaydb.core.internal.command.DbMigrate$
at org.flywaydb.core.internal.database.Connection$
at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute(
at org.flywaydb.core.internal.database.Connection.lock(
at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock(
at org.flywaydb.core.internal.command.DbMigrate.migrateAll(
at org.flywaydb.core.internal.command.DbMigrate.migrate(
at org.flywaydb.core.Flyway$1.execute(
at org.flywaydb.core.Flyway$1.execute(
at org.flywaydb.core.Flyway.execute(
at org.flywaydb.core.Flyway.migrate(

Copy link

Bisected it to this change 1692dce.

Copy link

Which JVM are you using here? That line in question

InputStream inputStream = classLoader.getResourceAsStream(location);

is really harmless, so I suspect an issue in the version you are using. What is the result with the latest Oracle 8, 9 or 10 JRE?

Copy link

  1. Java used in both (5.0.7, 5.1.1) cases: OpenJDK Runtime Environment (build 1.8.0_171-b10), haven't tried others yet.

  2. Agreed about InputStream inputStream = classLoader.getResourceAsStream(location); - it is present in both versions, so it is not that call causing warning. But now, reader is wrapped in BomStrippingReader and DefaultLineReader, and is sold out of loadAsString, unlike before.

  3. so I suspect an issue in the version you are using

Please note, that the only changing element/version in my env is flyway 5.0.7 -> 5.1.1.

Copy link

axelfontaine commented May 29, 2018

But now, reader is wrapped in BomStrippingReader and DefaultLineReader, and is sold out of loadAsString, unlike before.

Agreed, but that happens much later though. The stack trace is quite clear about where this is triggered.

Could you provide a small repo that reliably reproduces the issue so we can debug it?

Copy link

I'll try to prepare repro, but can't commit to the nearest future. Will let you know once ready.

Copy link

Here is maven project with flyway 5.1.1, that upon mvn verify reports mentioned warning. (And the same project but with 5.0.7).

Details of env used:

Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T20:49:05+01:00)
Java version: 1.8.0_171, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-
OS name: "linux", version: "4.16.11-300.fc28.x86_64", arch: "amd64", family: "unix"

@axelfontaine axelfontaine added this to the Flyway 5.1.2 milestone May 30, 2018
axelfontaine pushed a commit to flyway/ that referenced this issue May 30, 2018
Copy link

Thanks for the repo. This was very useful as it appears this only happens under GlassFish. If you run the same code from your repo in a regular JUnit test, no such warning is issued.

It was a potential resource leak nonetheless and it has now been fixed.

Copy link

Thank you for fix.

@axelfontaine axelfontaine modified the milestones: Flyway 5.1.2, Flyway 5.2.0, Flyway 5.1.3 Jun 19, 2018
dohrayme pushed a commit to dohrayme/flyway that referenced this issue Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants