From 1f1d429752fd3ace6bc62f1aabea83e56e5818e4 Mon Sep 17 00:00:00 2001 From: KimmingLau <294001791@qq.com> Date: Wed, 28 Feb 2024 11:50:59 +0800 Subject: Improved fix for #285 1. Write SAME_BYTES to cacheMap when woven bytes are null 2. Fix TODO in SimpleCache::getAndInitialize, using Optional to help indicate cache hit for unwoven class 3. Improve test coverage (cache miss, cache hit for unwoven class) Relates to #285. Co-authored-by: Alexander Kriegisch Signed-off-by: KimmingLau <294001791@qq.com> Signed-off-by: Alexander Kriegisch --- loadtime/src/main/java/org/aspectj/weaver/loadtime/Aj.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'loadtime') diff --git a/loadtime/src/main/java/org/aspectj/weaver/loadtime/Aj.java b/loadtime/src/main/java/org/aspectj/weaver/loadtime/Aj.java index 4dbda9023..58fd3c557 100644 --- a/loadtime/src/main/java/org/aspectj/weaver/loadtime/Aj.java +++ b/loadtime/src/main/java/org/aspectj/weaver/loadtime/Aj.java @@ -20,6 +20,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.StringTokenizer; @@ -104,9 +105,9 @@ public class Aj implements ClassPreProcessor { synchronized (classLoader) { if (SimpleCacheFactory.isEnabled()) { - byte[] cacheBytes= laCache.getAndInitialize(className, bytes, classLoader, protectionDomain); - if (cacheBytes!=null){ - return cacheBytes; + Optional cacheBytes = laCache.getAndInitialize(className, bytes, classLoader, protectionDomain); + if (cacheBytes != null){ + return cacheBytes.orElse(null); } } -- cgit v1.2.3