diff --git a/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/LicenseInfoHandler.java b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/LicenseInfoHandler.java index 9d0a2028b1..d874c5ef9b 100644 --- a/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/LicenseInfoHandler.java +++ b/backend/licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/LicenseInfoHandler.java @@ -75,7 +75,7 @@ public class LicenseInfoHandler implements LicenseInfoService.Iface { protected List> outputGenerators; protected ComponentDatabaseHandler componentDatabaseHandler; protected ProjectDatabaseHandler projectDatabaseHandler; - protected Cache> licenseInfoCache; + protected Cache> licenseInfoCache; protected Cache licenseInfoCacheForEvaluation; protected Cache> obligationCache; protected Cache> obligationCacheForEvaluation; @@ -576,13 +576,10 @@ public List getLicenseInfoForAttachment(Release releas } if (licenseInfoCache != null) { - for (Entry> entry : licenseInfoCache.asMap().entrySet()) { - Object[] key = entry.getKey(); - List cachedValue = entry.getValue(); - if (attachmentContentId.equals(key[0].toString()) && includeConcludedLicense == (boolean) key[1] - && cachedValue != null) { - return cachedValue; - } + String cacheKey = attachmentContentId + ":" + includeConcludedLicense; + List cachedResult = licenseInfoCache.getIfPresent(cacheKey); + if (cachedResult != null) { + return cachedResult; } } @@ -621,7 +618,7 @@ public List getLicenseInfoForAttachment(Release releas results = assignReleaseToLicenseInfoParsingResults(results, release); results = assignComponentToLicenseInfoParsingResults(results, release, user); - Object[] cacheKey = new Object[] { attachmentContentId, includeConcludedLicense }; + String cacheKey = attachmentContentId + ":" + includeConcludedLicense; licenseInfoCache.put(cacheKey, results); return results; } catch (WrappedTException exception) {