File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
src/main/java/com/microsoft/sqlserver/jdbc Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 1818import java .util .HashMap ;
1919import java .util .LinkedList ;
2020import java .util .Map ;
21+ import java .util .concurrent .locks .Lock ;
22+ import java .util .concurrent .locks .ReentrantLock ;
2123
2224
2325/**
2830public 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
You can’t perform that action at this time.
0 commit comments