Revert double-check locking for cleaner memory-fence based code.

pull/201/head
Brett Wooldridge 10 years ago
parent 54d293ef11
commit 0999b831d5

@ -233,30 +233,22 @@ public final class PoolUtilities
*/
public static boolean isJdbc40Compliant(final Connection connection) throws SQLException
{
// See http://en.wikipedia.org/wiki/Double-checked_locking#Usage_in_Java
boolean checked = jdbc40checked;
if (!checked) {
synchronized (PoolUtilities.class) {
checked = jdbc40checked;
if (!checked) {
try {
connection.isValid(5); // This will throw AbstractMethodError or SQLException in the case of a non-JDBC 41 compliant driver
IS_JDBC40 = true;
}
catch (SQLFeatureNotSupportedException e) {
IS_JDBC40 = false;
}
catch (AbstractMethodError e) {
IS_JDBC40 = false;
}
catch (NoSuchMethodError e) {
IS_JDBC40 = false;
}
finally {
jdbc40checked = checked = true;
}
}
if (!jdbc40checked) {
try {
connection.isValid(5); // This will throw AbstractMethodError or SQLException in the case of a non-JDBC 41 compliant driver
IS_JDBC40 = true;
}
catch (SQLFeatureNotSupportedException e) {
IS_JDBC40 = false;
}
catch (AbstractMethodError e) {
IS_JDBC40 = false;
}
catch (NoSuchMethodError e) {
IS_JDBC40 = false;
}
jdbc40checked = true;
}
return IS_JDBC40;

@ -215,24 +215,16 @@ public final class PoolUtilities
*/
public static boolean isJdbc40Compliant(final Connection connection) throws SQLException
{
// See http://en.wikipedia.org/wiki/Double-checked_locking#Usage_in_Java
boolean checked = jdbc40checked;
if (!checked) {
synchronized (PoolUtilities.class) {
checked = jdbc40checked;
if (!checked) {
try {
connection.isValid(5); // This will throw AbstractMethodError or SQLException in the case of a non-JDBC 41 compliant driver
IS_JDBC40 = true;
}
catch (NoSuchMethodError | AbstractMethodError | SQLFeatureNotSupportedException e) {
IS_JDBC40 = false;
}
finally {
jdbc40checked = checked = true;
}
}
if (!jdbc40checked) {
try {
connection.isValid(5); // This will throw AbstractMethodError or SQLException in the case of a non-JDBC 41 compliant driver
IS_JDBC40 = true;
}
catch (NoSuchMethodError | AbstractMethodError | SQLFeatureNotSupportedException e) {
IS_JDBC40 = false;
}
jdbc40checked = true;
}
return IS_JDBC40;

Loading…
Cancel
Save