synchronized getAutosensData

This commit is contained in:
Milos Kozak 2017-08-08 15:55:31 +02:00
parent 2f8ca8bb04
commit bbc68b2266

View file

@ -522,20 +522,22 @@ public class IobCobCalculatorPlugin implements PluginBase {
@Nullable @Nullable
public static AutosensData getAutosensData(long time) { public static AutosensData getAutosensData(long time) {
long now = System.currentTimeMillis(); synchronized (dataLock) {
if (time > now) long now = System.currentTimeMillis();
return null; if (time > now)
Long previous = findPreviousTimeFromBucketedData(time); return null;
if (previous == null) Long previous = findPreviousTimeFromBucketedData(time);
return null; if (previous == null)
time = roundUpTime(previous); return null;
AutosensData data = autosensDataTable.get(time); time = roundUpTime(previous);
if (data != null) { AutosensData data = autosensDataTable.get(time);
//log.debug(">>> getAutosensData Cache hit " + data.log(time)); if (data != null) {
return data; //log.debug(">>> getAutosensData Cache hit " + data.log(time));
} else { return data;
//log.debug(">>> getAutosensData Cache miss " + new Date(time).toLocaleString()); } else {
return null; //log.debug(">>> getAutosensData Cache miss " + new Date(time).toLocaleString());
return null;
}
} }
} }