From 5acce5c97bf413aba4eabbcca24f1022f6e59d27 Mon Sep 17 00:00:00 2001 From: speeddemon Date: Sat, 18 Apr 2020 21:49:36 +0300 Subject: [PATCH 1/3] Removed redundant if-statement --- .../org/springframework/core/annotation/AnnotationUtils.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java index b7f7f959fd15..e8b958118efc 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java @@ -164,9 +164,6 @@ public static boolean isCandidateClass(Class clazz, Class clazz, String annotationName) { - if (annotationName.startsWith("java.")) { - return true; - } if (AnnotationsScanner.hasPlainJavaAnnotationsOnly(clazz)) { return false; } From 508c4873f28cd2909675cafa3be18886872ba62e Mon Sep 17 00:00:00 2001 From: speeddemon Date: Sun, 19 Apr 2020 17:12:31 +0300 Subject: [PATCH 2/3] Optimized code --- .../main/java/org/springframework/cglib/proxy/Enhancer.java | 6 ++---- .../main/java/org/springframework/util/MimeTypeUtils.java | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/cglib/proxy/Enhancer.java b/spring-core/src/main/java/org/springframework/cglib/proxy/Enhancer.java index 71c6a372d5ba..bdf529db2ce8 100644 --- a/spring-core/src/main/java/org/springframework/cglib/proxy/Enhancer.java +++ b/spring-core/src/main/java/org/springframework/cglib/proxy/Enhancer.java @@ -569,8 +569,7 @@ private Object createHelper() { interceptDuringConstruction, serialVersionUID); this.currentKey = key; - Object result = super.create(key); - return result; + return super.create(key); } @Override @@ -826,8 +825,7 @@ protected Object wrapCachedClass(Class klass) { @Override protected Object unwrapCachedValue(Object cached) { if (currentKey instanceof EnhancerKey) { - EnhancerFactoryData data = ((WeakReference) cached).get(); - return data; + return ((WeakReference) cached).get(); } return super.unwrapCachedValue(cached); } diff --git a/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java b/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java index 490437d6e2b2..16ce26bf9610 100644 --- a/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java +++ b/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java @@ -219,7 +219,7 @@ private static MimeType parseMimeTypeInternal(String mimeType) { throw new InvalidMimeTypeException(mimeType, "does not contain subtype after '/'"); } String type = fullType.substring(0, subIndex); - String subtype = fullType.substring(subIndex + 1, fullType.length()); + String subtype = fullType.substring(subIndex + 1); if (MimeType.WILDCARD_TYPE.equals(type) && !MimeType.WILDCARD_TYPE.equals(subtype)) { throw new InvalidMimeTypeException(mimeType, "wildcard type is legal only in '*/*' (all mime types)"); } @@ -248,7 +248,7 @@ else if (ch == '"') { int eqIndex = parameter.indexOf('='); if (eqIndex >= 0) { String attribute = parameter.substring(0, eqIndex).trim(); - String value = parameter.substring(eqIndex + 1, parameter.length()).trim(); + String value = parameter.substring(eqIndex + 1).trim(); parameters.put(attribute, value); } } From 6b3a3025d5cf6389cce14de97a0fc514b800e39e Mon Sep 17 00:00:00 2001 From: speeddemon Date: Sun, 19 Apr 2020 18:14:16 +0300 Subject: [PATCH 3/3] Fixed code --- .../main/java/org/springframework/cglib/proxy/Enhancer.java | 6 ++++-- .../springframework/core/annotation/AnnotationUtils.java | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/cglib/proxy/Enhancer.java b/spring-core/src/main/java/org/springframework/cglib/proxy/Enhancer.java index bdf529db2ce8..71c6a372d5ba 100644 --- a/spring-core/src/main/java/org/springframework/cglib/proxy/Enhancer.java +++ b/spring-core/src/main/java/org/springframework/cglib/proxy/Enhancer.java @@ -569,7 +569,8 @@ private Object createHelper() { interceptDuringConstruction, serialVersionUID); this.currentKey = key; - return super.create(key); + Object result = super.create(key); + return result; } @Override @@ -825,7 +826,8 @@ protected Object wrapCachedClass(Class klass) { @Override protected Object unwrapCachedValue(Object cached) { if (currentKey instanceof EnhancerKey) { - return ((WeakReference) cached).get(); + EnhancerFactoryData data = ((WeakReference) cached).get(); + return data; } return super.unwrapCachedValue(cached); } diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java index e8b958118efc..b7f7f959fd15 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java @@ -164,6 +164,9 @@ public static boolean isCandidateClass(Class clazz, Class clazz, String annotationName) { + if (annotationName.startsWith("java.")) { + return true; + } if (AnnotationsScanner.hasPlainJavaAnnotationsOnly(clazz)) { return false; }