mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
[energidataservice] Fix IllegalStateException (#15693)
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
0fec7f07f5
commit
75e51119fa
@ -50,10 +50,9 @@ public class CacheManager {
|
|||||||
private final Clock clock;
|
private final Clock clock;
|
||||||
private final PriceListParser priceListParser = new PriceListParser();
|
private final PriceListParser priceListParser = new PriceListParser();
|
||||||
|
|
||||||
private Map<DatahubTariff, Collection<DatahubPricelistRecord>> datahubRecordsMap = new HashMap<>();
|
|
||||||
|
|
||||||
private Map<Instant, BigDecimal> spotPriceMap = new ConcurrentHashMap<>(SPOT_PRICE_MAX_CACHE_SIZE);
|
private Map<Instant, BigDecimal> spotPriceMap = new ConcurrentHashMap<>(SPOT_PRICE_MAX_CACHE_SIZE);
|
||||||
|
|
||||||
|
private Map<DatahubTariff, Collection<DatahubPricelistRecord>> datahubRecordsMap = new HashMap<>();
|
||||||
private Map<DatahubTariff, Map<Instant, BigDecimal>> tariffsMap = new ConcurrentHashMap<>();
|
private Map<DatahubTariff, Map<Instant, BigDecimal>> tariffsMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public CacheManager() {
|
public CacheManager() {
|
||||||
@ -63,9 +62,9 @@ public class CacheManager {
|
|||||||
public CacheManager(Clock clock) {
|
public CacheManager(Clock clock) {
|
||||||
this.clock = clock.withZone(NORD_POOL_TIMEZONE);
|
this.clock = clock.withZone(NORD_POOL_TIMEZONE);
|
||||||
|
|
||||||
for (DatahubTariff tariff : DatahubTariff.values()) {
|
for (DatahubTariff datahubTariff : DatahubTariff.values()) {
|
||||||
datahubRecordsMap.put(tariff, new ArrayList<>());
|
datahubRecordsMap.put(datahubTariff, new ArrayList<>());
|
||||||
tariffsMap.put(tariff, new ConcurrentHashMap<>(TARIFF_MAX_CACHE_SIZE));
|
tariffsMap.put(datahubTariff, new ConcurrentHashMap<>(TARIFF_MAX_CACHE_SIZE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,9 +72,19 @@ public class CacheManager {
|
|||||||
* Clear all cached data.
|
* Clear all cached data.
|
||||||
*/
|
*/
|
||||||
public void clear() {
|
public void clear() {
|
||||||
datahubRecordsMap.clear();
|
|
||||||
spotPriceMap.clear();
|
spotPriceMap.clear();
|
||||||
tariffsMap.clear();
|
|
||||||
|
for (DatahubTariff datahubTariff : DatahubTariff.values()) {
|
||||||
|
Collection<DatahubPricelistRecord> datahubRecords = datahubRecordsMap.get(datahubTariff);
|
||||||
|
if (datahubRecords != null) {
|
||||||
|
datahubRecords.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Instant, BigDecimal> tariffs = tariffsMap.get(datahubTariff);
|
||||||
|
if (tariffs != null) {
|
||||||
|
tariffs.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user