diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..bb138d1f --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,45 @@ +library "vertx-shared-library@master" +pipeline { + agent any + tools { + maven 'Maven' + } + environment { + MAVEN_SETTINGS_PATH = credentials("jenkins-sonatype-snapshot-repo-settings") + } + stages { + stage ('OracleJDK 8') { + tools { + jdk 'OracleJDK 8' + } + steps { + sh 'mvn -U -B -Dsurefire.reportNameSuffix=OracleJDK_8 -DskipTests clean deploy -s $MAVEN_SETTINGS_PATH' + triggerWorkflow() + } + post { + // always { + // junit '**/target/surefire-reports/*.xml' + // } + failure { + mail to:'vertx3-ci@googlegroups.com', subject:"Job '${env.JOB_NAME}' (${env.BUILD_NUMBER})", body: "Please go to ${env.BUILD_URL}." + } + } + } + stage ('OracleJDK latest') { + tools { + jdk 'OracleJDK latest' + } + when { + branch 'master' + } + steps { + sh 'mvn -U -B -fn -Dsurefire.reportNameSuffix=OracleJDK_latest -DskipTests clean test' + } + // post { + // always { + // junit '**/target/surefire-reports/*.xml' + // } + // } + } + } +} diff --git a/pom.xml b/pom.xml index 92d7ec99..9c3d0454 100644 --- a/pom.xml +++ b/pom.xml @@ -9,12 +9,12 @@ 4.0.0 vertx-mysql-postgresql-client - 3.5.1 + 3.5.5-SNAPSHOT Vert.x MySQL/PostgreSQL Client - 3.5.1 + 3.5.5-SNAPSHOT 2.12.4 0.2.21 true diff --git a/src/main/asciidoc/groovy/index.adoc b/src/main/asciidoc/groovy/index.adoc index 4dcc1b18..50a63f86 100644 --- a/src/main/asciidoc/groovy/index.adoc +++ b/src/main/asciidoc/groovy/index.adoc @@ -15,7 +15,7 @@ application. To use this client, you need to add the following jar to your `CLASSPATH`: -* vertx-mysql-postgresql-client 3.5.1 (the client) +* vertx-mysql-postgresql-client 3.5.4 (the client) * scala-library 2.11.4 * the postgress-async-2.11 and mysdql-async-2.11 from https://github.com/mauricio/postgresql-async * joda time @@ -33,7 +33,7 @@ If you are building a _Fat-jar_ using Maven or Gradle, just add the following de io.vertx vertx-mysql-postgresql-client - 3.5.1 + 3.5.4 ---- @@ -41,7 +41,7 @@ If you are building a _Fat-jar_ using Maven or Gradle, just add the following de [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-mysql-postgresql-client:3.5.1' +compile 'io.vertx:vertx-mysql-postgresql-client:3.5.4' ---- === In an application using a vert.x distributions diff --git a/src/main/asciidoc/java/index.adoc b/src/main/asciidoc/java/index.adoc index 987ae47e..79dde254 100644 --- a/src/main/asciidoc/java/index.adoc +++ b/src/main/asciidoc/java/index.adoc @@ -15,7 +15,7 @@ application. To use this client, you need to add the following jar to your `CLASSPATH`: -* vertx-mysql-postgresql-client 3.5.1 (the client) +* vertx-mysql-postgresql-client 3.5.4 (the client) * scala-library 2.11.4 * the postgress-async-2.11 and mysdql-async-2.11 from https://github.com/mauricio/postgresql-async * joda time @@ -33,7 +33,7 @@ If you are building a _Fat-jar_ using Maven or Gradle, just add the following de io.vertx vertx-mysql-postgresql-client - 3.5.1 + 3.5.4 ---- @@ -41,7 +41,7 @@ If you are building a _Fat-jar_ using Maven or Gradle, just add the following de [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-mysql-postgresql-client:3.5.1' +compile 'io.vertx:vertx-mysql-postgresql-client:3.5.4' ---- === In an application using a vert.x distributions diff --git a/src/main/asciidoc/js/index.adoc b/src/main/asciidoc/js/index.adoc index d141e76c..a83eac21 100644 --- a/src/main/asciidoc/js/index.adoc +++ b/src/main/asciidoc/js/index.adoc @@ -15,7 +15,7 @@ application. To use this client, you need to add the following jar to your `CLASSPATH`: -* vertx-mysql-postgresql-client 3.5.1 (the client) +* vertx-mysql-postgresql-client 3.5.4 (the client) * scala-library 2.11.4 * the postgress-async-2.11 and mysdql-async-2.11 from https://github.com/mauricio/postgresql-async * joda time @@ -33,7 +33,7 @@ If you are building a _Fat-jar_ using Maven or Gradle, just add the following de io.vertx vertx-mysql-postgresql-client - 3.5.1 + 3.5.4 ---- @@ -41,7 +41,7 @@ If you are building a _Fat-jar_ using Maven or Gradle, just add the following de [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-mysql-postgresql-client:3.5.1' +compile 'io.vertx:vertx-mysql-postgresql-client:3.5.4' ---- === In an application using a vert.x distributions diff --git a/src/main/asciidoc/kotlin/index.adoc b/src/main/asciidoc/kotlin/index.adoc index 3ba8f47f..7f3bad62 100644 --- a/src/main/asciidoc/kotlin/index.adoc +++ b/src/main/asciidoc/kotlin/index.adoc @@ -15,7 +15,7 @@ application. To use this client, you need to add the following jar to your `CLASSPATH`: -* vertx-mysql-postgresql-client 3.5.1 (the client) +* vertx-mysql-postgresql-client 3.5.4 (the client) * scala-library 2.11.4 * the postgress-async-2.11 and mysdql-async-2.11 from https://github.com/mauricio/postgresql-async * joda time @@ -33,7 +33,7 @@ If you are building a _Fat-jar_ using Maven or Gradle, just add the following de io.vertx vertx-mysql-postgresql-client - 3.5.1 + 3.5.4 ---- @@ -41,7 +41,7 @@ If you are building a _Fat-jar_ using Maven or Gradle, just add the following de [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-mysql-postgresql-client:3.5.1' +compile 'io.vertx:vertx-mysql-postgresql-client:3.5.4' ---- === In an application using a vert.x distributions diff --git a/src/main/asciidoc/ruby/index.adoc b/src/main/asciidoc/ruby/index.adoc index 8245675e..f6c76764 100644 --- a/src/main/asciidoc/ruby/index.adoc +++ b/src/main/asciidoc/ruby/index.adoc @@ -15,7 +15,7 @@ application. To use this client, you need to add the following jar to your `CLASSPATH`: -* vertx-mysql-postgresql-client 3.5.1 (the client) +* vertx-mysql-postgresql-client 3.5.4 (the client) * scala-library 2.11.4 * the postgress-async-2.11 and mysdql-async-2.11 from https://github.com/mauricio/postgresql-async * joda time @@ -33,7 +33,7 @@ If you are building a _Fat-jar_ using Maven or Gradle, just add the following de io.vertx vertx-mysql-postgresql-client - 3.5.1 + 3.5.4 ---- @@ -41,7 +41,7 @@ If you are building a _Fat-jar_ using Maven or Gradle, just add the following de [source,groovy,subs="+attributes"] ---- -compile 'io.vertx:vertx-mysql-postgresql-client:3.5.1' +compile 'io.vertx:vertx-mysql-postgresql-client:3.5.4' ---- === In an application using a vert.x distributions diff --git a/src/main/java/io/vertx/ext/asyncsql/impl/AsyncSQLConnectionImpl.java b/src/main/java/io/vertx/ext/asyncsql/impl/AsyncSQLConnectionImpl.java index b5bc0db9..1802df30 100644 --- a/src/main/java/io/vertx/ext/asyncsql/impl/AsyncSQLConnectionImpl.java +++ b/src/main/java/io/vertx/ext/asyncsql/impl/AsyncSQLConnectionImpl.java @@ -24,12 +24,19 @@ import io.vertx.core.Handler; import io.vertx.core.json.JsonArray; import io.vertx.ext.asyncsql.impl.pool.AsyncConnectionPool; -import io.vertx.ext.sql.*; +import io.vertx.ext.sql.ResultSet; +import io.vertx.ext.sql.SQLConnection; +import io.vertx.ext.sql.SQLOptions; +import io.vertx.ext.sql.SQLRowStream; +import io.vertx.ext.sql.TransactionIsolation; +import io.vertx.ext.sql.UpdateResult; import scala.Option; import scala.concurrent.ExecutionContext; import scala.runtime.AbstractFunction1; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; /** * Implementation of {@link SQLConnection} using the {@link AsyncConnectionPool}. @@ -302,11 +309,14 @@ private synchronized void beginTransactionIfNeeded(Handler> ac private Handler> handleAsyncQueryResultToResultSet(Handler> handler) { return ar -> { if (ar.succeeded()) { + ResultSet result; try { - handler.handle(Future.succeededFuture(queryResultToResultSet(ar.result()))); + result = queryResultToResultSet(ar.result()); } catch (Throwable e) { handler.handle(Future.failedFuture(e)); + return; } + handler.handle(Future.succeededFuture(result)); } else { handler.handle(Future.failedFuture(ar.cause())); } @@ -316,11 +326,14 @@ private Handler> handleAsyncQueryResultToResultSet(Hand private Handler> handleAsyncQueryResultToRowStream(Handler> handler) { return ar -> { if (ar.succeeded()) { + AsyncSQLRowStream rowStream; try { - handler.handle(Future.succeededFuture(new AsyncSQLRowStream(ar.result()))); + rowStream = new AsyncSQLRowStream(ar.result()); } catch (Throwable e) { handler.handle(Future.failedFuture(e)); + return; } + handler.handle(Future.succeededFuture(rowStream)); } else { handler.handle(Future.failedFuture(ar.cause())); } @@ -341,11 +354,14 @@ private ResultSet queryResultToResultSet(QueryResult qr) { private Handler> handleAsyncUpdateResultToResultSet(Handler> handler) { return ar -> { if (ar.succeeded()) { + UpdateResult result; try { - handler.handle(Future.succeededFuture(queryResultToUpdateResult(ar.result()))); + result = queryResultToUpdateResult(ar.result()); } catch (Throwable e) { handler.handle(Future.failedFuture(e)); + return; } + handler.handle(Future.succeededFuture(result)); } else { handler.handle(Future.failedFuture(ar.cause())); } diff --git a/src/test/java/io/vertx/ext/asyncsql/SQLTestBase.java b/src/test/java/io/vertx/ext/asyncsql/SQLTestBase.java index 216ca5c6..25c81553 100644 --- a/src/test/java/io/vertx/ext/asyncsql/SQLTestBase.java +++ b/src/test/java/io/vertx/ext/asyncsql/SQLTestBase.java @@ -37,8 +37,10 @@ import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.BiConsumer; import java.util.function.Supplier; +import static java.util.concurrent.TimeUnit.*; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; @@ -857,4 +859,44 @@ public void handle(AsyncResult sqlConnectionAsyncResult) { clientNoDatabase.getConnection(handler); } + @Test + public void testUnhandledExceptionInHandlerResultSet(TestContext testContext) { + this.testUnhandledExceptionInHandler(testContext, (sqlConnection, handler) -> { + sqlConnection.query("SELECT name FROM test_table", handler); + }); + } + + @Test + public void testUnhandledExceptionInHandlerRowStream(TestContext testContext) { + this.testUnhandledExceptionInHandler(testContext, (sqlConnection, handler) -> { + sqlConnection.queryStream("SELECT name FROM test_table", handler); + }); + } + + @Test + public void testUnhandledExceptionInHandlerUpdateResult(TestContext testContext) { + this.testUnhandledExceptionInHandler(testContext, (sqlConnection, handler) -> { + sqlConnection.update("INSERT INTO test_table (name) VALUES ('pimpo')", handler); + }); + } + + private void testUnhandledExceptionInHandler(TestContext testContext, BiConsumer>> testMethod) { + AtomicInteger count = new AtomicInteger(); + Async async = testContext.async(); + Context context = vertx.getOrCreateContext(); + context.exceptionHandler(t -> { + async.complete(); + }).runOnContext(v -> { + client.getConnection(testContext.asyncAssertSuccess(connection -> { + setupSimpleTable(connection, testContext.asyncAssertSuccess(st -> { + testMethod.accept(connection, ar -> { + count.incrementAndGet(); + throw new IndexOutOfBoundsException(); + }); + })); + })); + }); + async.await(MILLISECONDS.convert(5, SECONDS)); + assertEquals(1, count.get()); + } }