2424import java .util .Map ;
2525import java .util .Set ;
2626import java .util .TreeSet ;
27+ import java .util .concurrent .atomic .AtomicBoolean ;
2728import java .util .concurrent .locks .Lock ;
2829import java .util .concurrent .locks .ReentrantLock ;
2930import java .util .stream .Collectors ;
@@ -72,7 +73,7 @@ public class FileReftableDatabase extends RefDatabase {
7273
7374 private final FileReftableStack reftableStack ;
7475
75- private boolean autoRefresh ;
76+ private final AtomicBoolean autoRefresh ;
7677
7778 FileReftableDatabase (FileRepository repo ) throws IOException {
7879 this (repo , new File (new File (repo .getCommonDirectory (), Constants .REFTABLE ),
@@ -81,9 +82,9 @@ public class FileReftableDatabase extends RefDatabase {
8182
8283 FileReftableDatabase (FileRepository repo , File refstackName ) throws IOException {
8384 this .fileRepository = repo ;
84- this .autoRefresh = repo .getConfig ().getBoolean (
85+ this .autoRefresh = new AtomicBoolean ( repo .getConfig ().getBoolean (
8586 ConfigConstants .CONFIG_REFTABLE_SECTION ,
86- ConfigConstants .CONFIG_KEY_AUTOREFRESH , false );
87+ ConfigConstants .CONFIG_KEY_AUTOREFRESH , false )) ;
8788 this .reftableStack = new FileReftableStack (refstackName ,
8889 new File (fileRepository .getCommonDirectory (), Constants .REFTABLE ),
8990 () -> fileRepository .fireEvent (new RefsChangedEvent ()),
@@ -241,7 +242,7 @@ public Ref peel(Ref ref) throws IOException {
241242 * date.
242243 */
243244 public void setAutoRefresh (boolean autoRefresh ) {
244- this .autoRefresh = autoRefresh ;
245+ this .autoRefresh . set ( autoRefresh ) ;
245246 }
246247
247248 /**
@@ -251,11 +252,11 @@ public void setAutoRefresh(boolean autoRefresh) {
251252 * date.
252253 */
253254 public boolean isAutoRefresh () {
254- return autoRefresh ;
255+ return autoRefresh . get () ;
255256 }
256257
257258 private void autoRefresh () {
258- if (autoRefresh ) {
259+ if (autoRefresh . get () ) {
259260 refresh ();
260261 }
261262 }
0 commit comments