Commit 1fa4aff5dc8373a17857e50d0a5dba81fe648b53

Authored by Andrii Shvaika
1 parent 3e39791e

Bug fix in Cache Cleanup Service

@@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
15 */ 15 */
16 package org.thingsboard.server.service.install.update; 16 package org.thingsboard.server.service.install.update;
17 17
  18 +import lombok.RequiredArgsConstructor;
18 import lombok.extern.slf4j.Slf4j; 19 import lombok.extern.slf4j.Slf4j;
19 import org.springframework.beans.factory.annotation.Autowired; 20 import org.springframework.beans.factory.annotation.Autowired;
20 import org.springframework.cache.Cache; 21 import org.springframework.cache.Cache;
@@ -24,13 +25,13 @@ import org.springframework.stereotype.Service; @@ -24,13 +25,13 @@ import org.springframework.stereotype.Service;
24 25
25 import java.util.Objects; 26 import java.util.Objects;
26 27
  28 +@RequiredArgsConstructor
27 @Service 29 @Service
28 @Profile("install") 30 @Profile("install")
29 @Slf4j 31 @Slf4j
30 public class DefaultCacheCleanupService implements CacheCleanupService { 32 public class DefaultCacheCleanupService implements CacheCleanupService {
31 33
32 - @Autowired  
33 - CacheManager cacheManager; 34 + private final CacheManager cacheManager;
34 35
35 /** 36 /**
36 * Cleanup caches that can not deserialize anymore due to schema upgrade or data update using sql scripts. 37 * Cleanup caches that can not deserialize anymore due to schema upgrade or data update using sql scripts.
@@ -43,7 +44,7 @@ public class DefaultCacheCleanupService implements CacheCleanupService { @@ -43,7 +44,7 @@ public class DefaultCacheCleanupService implements CacheCleanupService {
43 case "3.0.1": 44 case "3.0.1":
44 log.info("Clear cache to upgrade from version 3.0.1 to 3.1.0 ..."); 45 log.info("Clear cache to upgrade from version 3.0.1 to 3.1.0 ...");
45 clearAllCaches(); 46 clearAllCaches();
46 - //do not break to show explicit calls for next versions 47 + break;
47 case "3.1.1": 48 case "3.1.1":
48 log.info("Clear cache to upgrade from version 3.1.1 to 3.2.0 ..."); 49 log.info("Clear cache to upgrade from version 3.1.1 to 3.2.0 ...");
49 clearCacheByName("devices"); 50 clearCacheByName("devices");
@@ -55,10 +56,9 @@ public class DefaultCacheCleanupService implements CacheCleanupService { @@ -55,10 +56,9 @@ public class DefaultCacheCleanupService implements CacheCleanupService {
55 clearCacheByName("deviceProfiles"); 56 clearCacheByName("deviceProfiles");
56 clearCacheByName("tenantProfiles"); 57 clearCacheByName("tenantProfiles");
57 clearCacheByName("relations"); 58 clearCacheByName("relations");
58 -  
59 break; 59 break;
60 default: 60 default:
61 - throw new RuntimeException("Unable to update cache, unsupported fromVersion: " + fromVersion); 61 + //Do nothing, since cache cleanup is optional.
62 } 62 }
63 } 63 }
64 64