mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-07 12:51:02 +00:00
second part of fix for bug 3330: ensure that only one thread tries to load persistent declination values at a time
This commit is contained in:
1 parent
1386e76341
commit
63ae032bfd
1 file changed
+9
-3
+9
-3
@@ -101,9 +101,15 @@ public class DeclinationServiceImpl implements DeclinationService {
|
||||
private QuadTree<Declination> getYearStore(int year) throws IOException, ParseException {
|
||||
QuadTree<Declination> result = yearStore.get(year);
|
||||
if (result == null) {
|
||||
result = persistentStore.getStoredDeclinations(year);
|
||||
if (result != null) {
|
||||
yearStore.put(year, result);
|
||||
synchronized (this) {
|
||||
// make sure we only trigger one invocation of persistentStore.getStoredDeclinations(year) even for multiple threads
|
||||
result = yearStore.get(year);
|
||||
if (result == null) {
|
||||
result = persistentStore.getStoredDeclinations(year);
|
||||
if (result != null) {
|
||||
yearStore.put(year, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in new issue
Block a user