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

Closed
pzygielo opened this issue May 28, 2018 · 8 comments

Comments

@pzygielo
Copy link

@pzygielo pzygielo commented May 28, 2018

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 10.14.2.0

Which operating system are you using?

GNU/Linux

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
java.lang.Throwable
at com.sun.enterprise.loader.ASURLClassLoader$SentinelInputStream.(ASURLClassLoader.java:1278)
at com.sun.enterprise.loader.ASURLClassLoader.getResourceAsStream(ASURLClassLoader.java:936)
at org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource.loadAsString(ClassPathResource.java:89)
at org.flywaydb.core.internal.database.ExecutableSqlScript.(ExecutableSqlScript.java:129)
at org.flywaydb.core.internal.database.derby.DerbySqlScript.(DerbySqlScript.java:38)
at org.flywaydb.core.internal.database.derby.DerbyDatabase.doCreateSqlScript(DerbyDatabase.java:89)
at org.flywaydb.core.internal.database.Database.createSqlScript(Database.java:163)
at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.getSqlScript(SqlMigrationExecutor.java:96)
at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.executeInTransaction(SqlMigrationExecutor.java:109)
at org.flywaydb.core.internal.command.DbMigrate.isExecuteGroupInTransaction(DbMigrate.java:312)
at org.flywaydb.core.internal.command.DbMigrate.applyMigrations(DbMigrate.java:275)
at org.flywaydb.core.internal.command.DbMigrate.migrateGroup(DbMigrate.java:244)
at org.flywaydb.core.internal.command.DbMigrate.access$100(DbMigrate.java:53)
at org.flywaydb.core.internal.command.DbMigrate$2.call(DbMigrate.java:163)
at org.flywaydb.core.internal.command.DbMigrate$2.call(DbMigrate.java:160)
at org.flywaydb.core.internal.database.Connection$1.call(Connection.java:145)
at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:74)
at org.flywaydb.core.internal.database.Connection.lock(Connection.java:141)
at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock(JdbcTableSchemaHistory.java:150)
at org.flywaydb.core.internal.command.DbMigrate.migrateAll(DbMigrate.java:160)
at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:138)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:947)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:910)
at org.flywaydb.core.Flyway.execute(Flyway.java:1238)
at org.flywaydb.core.Flyway.migrate(Flyway.java:910)

@pzygielo
Copy link
Author

@pzygielo pzygielo commented May 28, 2018

Bisected it to this change 1692dce.

@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented May 29, 2018

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?

@pzygielo
Copy link
Author

@pzygielo pzygielo commented May 29, 2018

  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.

@axelfontaine
Copy link
Contributor

@axelfontaine 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?

@pzygielo
Copy link
Author

@pzygielo pzygielo commented May 29, 2018

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

@pzygielo
Copy link
Author

@pzygielo pzygielo commented May 29, 2018

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-1.8.0.171-4.b10.fc28.x86_64/jre
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 added a commit to flyway/flywaydb.org that referenced this issue May 30, 2018
@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented May 30, 2018

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.

@pzygielo
Copy link
Author

@pzygielo pzygielo commented May 30, 2018

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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.