24
24
import java .util .Map ;
25
25
import java .util .Set ;
26
26
import java .util .TreeSet ;
27
+ import java .util .concurrent .atomic .AtomicBoolean ;
27
28
import java .util .concurrent .locks .Lock ;
28
29
import java .util .concurrent .locks .ReentrantLock ;
29
30
import java .util .stream .Collectors ;
@@ -72,7 +73,7 @@ public class FileReftableDatabase extends RefDatabase {
72
73
73
74
private final FileReftableStack reftableStack ;
74
75
75
- private boolean autoRefresh ;
76
+ private final AtomicBoolean autoRefresh ;
76
77
77
78
FileReftableDatabase (FileRepository repo ) throws IOException {
78
79
this (repo , new File (new File (repo .getCommonDirectory (), Constants .REFTABLE ),
@@ -81,9 +82,9 @@ public class FileReftableDatabase extends RefDatabase {
81
82
82
83
FileReftableDatabase (FileRepository repo , File refstackName ) throws IOException {
83
84
this .fileRepository = repo ;
84
- this .autoRefresh = repo .getConfig ().getBoolean (
85
+ this .autoRefresh = new AtomicBoolean ( repo .getConfig ().getBoolean (
85
86
ConfigConstants .CONFIG_REFTABLE_SECTION ,
86
- ConfigConstants .CONFIG_KEY_AUTOREFRESH , false );
87
+ ConfigConstants .CONFIG_KEY_AUTOREFRESH , false )) ;
87
88
this .reftableStack = new FileReftableStack (refstackName ,
88
89
new File (fileRepository .getCommonDirectory (), Constants .REFTABLE ),
89
90
() -> fileRepository .fireEvent (new RefsChangedEvent ()),
@@ -241,7 +242,7 @@ public Ref peel(Ref ref) throws IOException {
241
242
* date.
242
243
*/
243
244
public void setAutoRefresh (boolean autoRefresh ) {
244
- this .autoRefresh = autoRefresh ;
245
+ this .autoRefresh . set ( autoRefresh ) ;
245
246
}
246
247
247
248
/**
@@ -251,11 +252,11 @@ public void setAutoRefresh(boolean autoRefresh) {
251
252
* date.
252
253
*/
253
254
public boolean isAutoRefresh () {
254
- return autoRefresh ;
255
+ return autoRefresh . get () ;
255
256
}
256
257
257
258
private void autoRefresh () {
258
- if (autoRefresh ) {
259
+ if (autoRefresh . get () ) {
259
260
refresh ();
260
261
}
261
262
}
0 commit comments