Skip to content

Commit

Permalink
AbstractErrorSqlConnection: Silently ignore state set requests
Browse files Browse the repository at this point in the history
Since this state wont have any effect until the connection is used, we can just safely ignore the requests.
This will help hide potential server instability longer if possible, making the AuroraArc connections be more reliable.

This is in effect an extension of the previous changes to this class.
  • Loading branch information
jentfoo committed Dec 3, 2019
1 parent 79e2b24 commit 2e75083
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 87 deletions.
8 changes: 4 additions & 4 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
<classpathentry kind="lib" path="arcCommon/build/dependencies/logback-core-1.2.3.jar"/>
<classpathentry kind="lib" path="arcCommon/build/dependencies/objenesis-2.6.jar"/>
<classpathentry kind="lib" path="arcCommon/build/dependencies/slf4j-api-1.7.25.jar"/>
<classpathentry kind="lib" path="arcCommon/build/dependencies/HikariCP-3.3.1.jar"/>
<classpathentry kind="lib" path="arcCommon/build/dependencies/jdbi-2.78.jar"/>
<classpathentry kind="lib" path="psqlAuroraArc/build/dependencies/postgresql-42.2.7.jar"/>
<classpathentry kind="lib" path="arcCommon/build/dependencies/byte-buddy-1.9.10.jar"/>
<classpathentry kind="lib" path="arcCommon/build/dependencies/byte-buddy-agent-1.9.10.jar"/>
<classpathentry kind="lib" path="arcCommon/build/dependencies/mockito-core-3.1.0.jar"/>
<classpathentry kind="lib" path="mysqlAuroraArc/build/dependencies/mysql-connector-java-8.0.18.jar"/>
<classpathentry kind="lib" path="arcCommon/build/dependencies/byte-buddy-1.10.3.jar"/>
<classpathentry kind="lib" path="arcCommon/build/dependencies/byte-buddy-agent-1.10.3.jar"/>
<classpathentry kind="lib" path="arcCommon/build/dependencies/HikariCP-3.4.1.jar"/>
<classpathentry kind="lib" path="arcCommon/build/dependencies/mockito-core-3.2.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,52 @@ public void setClientInfo(String arg0, String arg1) throws SQLClientInfoExceptio
public void clearWarnings() throws SQLException {
// ignored
}

// set operations ignored as the state of this connection does not matter


@Override
public void setAutoCommit(boolean arg0) throws SQLException {
// ignored
}

@Override
public void setCatalog(String arg0) throws SQLException {
// ignored
}

@Override
public void setHoldability(int arg0) throws SQLException {
// ignored
}

@Override
public void setNetworkTimeout(Executor arg0, int arg1) throws SQLException {
// ignored
}

@Override
public void setReadOnly(boolean arg0) throws SQLException {
// ignored
}

@Override
public void setSchema(String arg0) throws SQLException {
// ignored
}

@Override
public void setTransactionIsolation(int arg0) throws SQLException {
// ignored
}

@Override
public void setTypeMap(Map<String, Class<?>> arg0) throws SQLException {
// ignored
}

// other operations expose the error

@Override
public boolean isWrapperFor(Class<?> arg0) throws SQLException {
throw error();
Expand Down Expand Up @@ -300,31 +345,6 @@ public void rollback(Savepoint arg0) throws SQLException {
throw error();
}

@Override
public void setAutoCommit(boolean arg0) throws SQLException {
throw error();
}

@Override
public void setCatalog(String arg0) throws SQLException {
throw error();
}

@Override
public void setHoldability(int arg0) throws SQLException {
throw error();
}

@Override
public void setNetworkTimeout(Executor arg0, int arg1) throws SQLException {
throw error();
}

@Override
public void setReadOnly(boolean arg0) throws SQLException {
throw error();
}

@Override
public Savepoint setSavepoint() throws SQLException {
throw error();
Expand All @@ -334,19 +354,4 @@ public Savepoint setSavepoint() throws SQLException {
public Savepoint setSavepoint(String arg0) throws SQLException {
throw error();
}

@Override
public void setSchema(String arg0) throws SQLException {
throw error();
}

@Override
public void setTransactionIsolation(int arg0) throws SQLException {
throw error();
}

@Override
public void setTypeMap(Map<String, Class<?>> arg0) throws SQLException {
throw error();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,54 @@ public void setClientInfoTest() throws SQLException {
connection.setClientInfo("key", "value");
// nothing should throw
}

@Test
public void setAutoCommitTest() throws SQLException {
connection.setAutoCommit(true);
// nothing should throw
}

@Test
public void setCatalogTest() throws SQLException {
connection.setCatalog(null);
// nothing should throw
}

@Test
public void setHoldabilityTest() throws SQLException {
connection.setHoldability(-1);
// nothing should throw
}

@Test
public void setNetworkTimeoutTest() throws SQLException {
connection.setNetworkTimeout(null, -1);
// nothing should throw
}

@Test
public void setReadOnlyTest() throws SQLException {
connection.setReadOnly(true);
// nothing should throw
}

@Test
public void setSchemaTest() throws SQLException {
connection.setSchema(null);
// nothing should throw
}

@Test
public void setTransactionIsolationTest() throws SQLException {
connection.setTransactionIsolation(-1);
// nothing should throw
}

@Test
public void setTypeMapTest() throws SQLException {
connection.setTypeMap(Collections.emptyMap());
// nothing should throw
}

protected void verifyAction(Callable<?> operation) {
try {
Expand Down Expand Up @@ -200,48 +248,8 @@ public void rollbackTest() {
verifyAction(() -> { connection.rollback(); return null; });
}

@Test
public void setAutoCommitTest() {
verifyAction(() -> { connection.setAutoCommit(true); return null; });
}

@Test
public void setCatalogTest() {
verifyAction(() -> { connection.setCatalog(null); return null; });
}

@Test
public void setHoldabilityTest() {
verifyAction(() -> { connection.setHoldability(-1); return null; });
}

@Test
public void setNetworkTimeoutTest() {
verifyAction(() -> { connection.setNetworkTimeout(null, -1); return null; });
}

@Test
public void setReadOnlyTest() {
verifyAction(() -> { connection.setReadOnly(true); return null; });
}

@Test
public void setSavepointTest() {
verifyAction(connection::setSavepoint);
}

@Test
public void setSchemaTest() {
verifyAction(() -> { connection.setSchema(null); return null; });
}

@Test
public void setTransactionIsolationTest() {
verifyAction(() -> { connection.setTransactionIsolation(-1); return null; });
}

@Test
public void setTypeMapTest() {
verifyAction(() -> { connection.setTypeMap(Collections.emptyMap()); return null; });
}
}
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
group = org.threadly
version = 0.12
version = 0.13-SNAPSHOT

threadlyVersion = 5.41
mysqlVersion = 8.0.18
psqlVersion = 42.2.7

jdbiVersion = 2.78
hikariVersion = 3.3.1
hikariVersion = 3.4.1
logbackVersion = 1.2.3
junitVersion = 4.12
mockitoVersion = 3.1.0
mockitoVersion = 3.2.0

0 comments on commit 2e75083

Please sign in to comment.