Skip to content

Commit 091ed78

Browse files
committed
Add back logging
1 parent bbcdf8d commit 091ed78

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/main/java/com/microsoft/sqlserver/jdbc/ConfigurableRetryLogic.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import java.util.HashMap;
1919
import java.util.LinkedList;
2020
import java.util.Map;
21+
import java.util.concurrent.locks.Lock;
22+
import java.util.concurrent.locks.ReentrantLock;
2123

2224

2325
/**
@@ -28,9 +30,10 @@
2830
public class ConfigurableRetryLogic {
2931
private final static int INTERVAL_BETWEEN_READS_IN_MS = 30000;
3032
private final static String DEFAULT_PROPS_FILE = "mssql-jdbc.properties";
33+
private static final Lock CRL_LOCK = new ReentrantLock();
3134
private static final java.util.logging.Logger CONFIGURABLE_RETRY_LOGGER = java.util.logging.Logger
3235
.getLogger("com.microsoft.sqlserver.jdbc.ConfigurableRetryLogic");
33-
private static ConfigurableRetryLogic singleInstance = null;
36+
private static ConfigurableRetryLogic singleInstance;
3437
private static long timeLastModified;
3538
private static long timeLastRead;
3639
private static String lastQuery = ""; // The last query executed (used when rule is process-dependent)
@@ -56,12 +59,22 @@ private ConfigurableRetryLogic() throws SQLServerException {
5659
* an exception
5760
*/
5861
public static ConfigurableRetryLogic getInstance() throws SQLServerException {
59-
// No need for lock; static initializer singleInstance is thread-safe
62+
// No need for lock; static initializer singleInstance is thread-safe]
6063
if (singleInstance == null) {
61-
singleInstance = new ConfigurableRetryLogic();
64+
CRL_LOCK.lock();
65+
try {
66+
if (singleInstance == null) {
67+
singleInstance = new ConfigurableRetryLogic();
68+
} else {
69+
refreshRuleSet();
70+
}
71+
} finally {
72+
CRL_LOCK.unlock();
73+
}
6274
} else {
6375
refreshRuleSet();
6476
}
77+
6578
return singleInstance;
6679
}
6780

0 commit comments

Comments
 (0)