Fix #199 fix possible race, while avoiding heavy weight synchronisation

pull/201/head
Brett Wooldridge 10 years ago
parent 5c46f62411
commit 7485e2dd8b

@ -234,8 +234,6 @@ public final class PoolUtilities
public static boolean isJdbc40Compliant(final Connection connection) throws SQLException
{
if (!jdbc40checked) {
jdbc40checked = true;
try {
connection.isValid(5); // This will throw AbstractMethodError or SQLException in the case of a non-JDBC 41 compliant driver
IS_JDBC40 = true;
@ -249,6 +247,9 @@ public final class PoolUtilities
catch (NoSuchMethodError e) {
IS_JDBC40 = false;
}
finally {
jdbc40checked = true;
}
}
return IS_JDBC40;
@ -293,8 +294,6 @@ public final class PoolUtilities
public static int setNetworkTimeout(final Executor executor, final Connection connection, final long timeoutMs, final boolean isUseNetworkTimeout) throws SQLException
{
if ((IS_JDBC41 || !jdbc41checked) && isUseNetworkTimeout) {
jdbc41checked = true;
try {
final int networkTimeout = connection.getNetworkTimeout();
connection.setNetworkTimeout(executor, (int) timeoutMs);
@ -310,6 +309,9 @@ public final class PoolUtilities
catch (NoSuchMethodError e) {
IS_JDBC41 = false;
}
finally {
jdbc41checked = true;
}
}
return 0;

@ -216,8 +216,6 @@ public final class PoolUtilities
public static boolean isJdbc40Compliant(final Connection connection) throws SQLException
{
if (!jdbc40checked) {
jdbc40checked = true;
try {
connection.isValid(5); // This will throw AbstractMethodError or SQLException in the case of a non-JDBC 41 compliant driver
IS_JDBC40 = true;
@ -225,6 +223,9 @@ public final class PoolUtilities
catch (NoSuchMethodError | AbstractMethodError | SQLFeatureNotSupportedException e) {
IS_JDBC40 = false;
}
finally {
jdbc40checked = true;
}
}
return IS_JDBC40;
@ -263,8 +264,6 @@ public final class PoolUtilities
public static int setNetworkTimeout(final Executor executor, final Connection connection, final long timeoutMs, final boolean isUseNetworkTimeout) throws SQLException
{
if ((IS_JDBC41 || !jdbc41checked) && isUseNetworkTimeout) {
jdbc41checked = true;
try {
final int networkTimeout = connection.getNetworkTimeout();
connection.setNetworkTimeout(executor, (int) timeoutMs);
@ -274,6 +273,9 @@ public final class PoolUtilities
catch (SQLFeatureNotSupportedException | AbstractMethodError | NoSuchMethodError e) {
IS_JDBC41 = false;
}
finally {
jdbc41checked = true;
}
}
return 0;

Loading…
Cancel
Save