setFetchSize to a negative value breaks Oracle JDBC Driver

Description

When trying to generate changelogs for an oracle DB with:

mvn -e org.liquibase:liquibase-maven-plugin:3.3.0:generateChangeLog

I'm getting the following exception stacktrace:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.liquibase:liquibase-maven-plugin:3.3.0:generateChangeLog (default-cli) on project logiq-persistence: Error setting up or running Liquibase: liquibase.command.CommandExecutionException: liquibase.exception.UnexpectedLiquibaseException: java.sql.SQLException: Invalid argument(s) in call: setFetchSize
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error setting up or running Liquibase: liquibase.command.CommandExecutionException: liquibase.exception.UnexpectedLiquibaseException: java.sql.SQLException: Invalid argument(s) in call: setFetchSize
at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:373)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: liquibase.exception.LiquibaseException: liquibase.command.CommandExecutionException: liquibase.exception.UnexpectedLiquibaseException: java.sql.SQLException: Invalid argument(s) in call: setFetchSize
at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:140)
at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:114)
at org.liquibase.maven.plugins.LiquibaseGenerateChangeLogMojo.performLiquibaseTask(LiquibaseGenerateChangeLogMojo.java:85)
at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:369)
... 21 more
Caused by: liquibase.command.CommandExecutionException: liquibase.exception.UnexpectedLiquibaseException: java.sql.SQLException: Invalid argument(s) in call: setFetchSize
at liquibase.command.AbstractCommand.execute(AbstractCommand.java:13)
at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:138)
... 24 more
Caused by: liquibase.exception.UnexpectedLiquibaseException: java.sql.SQLException: Invalid argument(s) in call: setFetchSize
at liquibase.diff.output.changelog.core.MissingDataExternalFileChangeGenerator.fixMissing(MissingDataExternalFileChangeGenerator.java:155)
at liquibase.diff.output.changelog.ChangeGeneratorChain.fixMissing(ChangeGeneratorChain.java:44)
at liquibase.diff.output.changelog.ChangeGeneratorFactory.fixMissing(ChangeGeneratorFactory.java:99)
at liquibase.diff.output.changelog.DiffToChangeLog.generateChangeSets(DiffToChangeLog.java:145)
at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:125)
at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:81)
at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:64)
at liquibase.command.GenerateChangeLogCommand.run(GenerateChangeLogCommand.java:54)
at liquibase.command.AbstractCommand.execute(AbstractCommand.java:8)
... 25 more
Caused by: java.sql.SQLException: Invalid argument(s) in call: setFetchSize
at oracle.jdbc.driver.OracleStatement.setPrefetchInternal(OracleStatement.java:2854)
at oracle.jdbc.driver.OracleStatement.setFetchSize(OracleStatement.java:4122)
at oracle.jdbc.driver.OracleStatementWrapper.setFetchSize(OracleStatementWrapper.java:232)
at liquibase.diff.output.changelog.core.MissingDataExternalFileChangeGenerator.fixMissing(MissingDataExternalFileChangeGenerator.java:63)
... 33 more

The reason is that in MissingDataExternalFileChangGenerator lines 62 and following you do:

if (!(referenceDatabase instanceof PostgresDatabase)) {
stmt.setFetchSize(Integer.MIN_VALUE);
}

And thus try to set fetchSize to a negative value. Which apparently doesn't work with the ojdbc6 driver.

I'm using ojdbc6 version 11.2.0.2.0.

Cheers,
Thomas

Environment

OSX

Reporter

Thomas Becker

Fix versions

Affects versions

Priority

Minor
Configure