diff options
author | KimmingLau <294001791@qq.com> | 2024-02-28 11:50:59 +0800 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2024-03-04 10:15:31 +0100 |
commit | 1f1d429752fd3ace6bc62f1aabea83e56e5818e4 (patch) | |
tree | 350dd9e964bd8f9c4eb74a38a4ae423ce9a00c07 /loadtime | |
parent | 1cdf71119c5e3434772f3b51705b7bb8ba5980fe (diff) | |
download | aspectj-1f1d429752fd3ace6bc62f1aabea83e56e5818e4.tar.gz aspectj-1f1d429752fd3ace6bc62f1aabea83e56e5818e4.zip |
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 <Alexander@Kriegisch.name>
Signed-off-by: KimmingLau <294001791@qq.com>
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'loadtime')
-rw-r--r-- | loadtime/src/main/java/org/aspectj/weaver/loadtime/Aj.java | 7 |
1 files changed, 4 insertions, 3 deletions
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<byte[]> cacheBytes = laCache.getAndInitialize(className, bytes, classLoader, protectionDomain); + if (cacheBytes != null){ + return cacheBytes.orElse(null); } } |