From e2514454df2a413057bac59419c92248e51797c9 Mon Sep 17 00:00:00 2001 From: Piyal Ahmed Date: Fri, 4 Jul 2025 22:20:06 +0800 Subject: [PATCH 1/3] Simplify if statement Signed-off-by: Piyal Ahmed --- .../boot/actuate/management/HeapDumpWebEndpoint.java | 5 +---- .../springframework/boot/loader/net/util/UrlDecoder.java | 7 ++----- .../boot/convert/CharSequenceToObjectConverter.java | 9 +++------ 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java index e252c12b8429..5cb9ec355833 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java @@ -126,10 +126,7 @@ private boolean isRunningOnOpenJ9() { return true; } String vmVendor = System.getProperty("java.vm.vendor"); - if (StringUtils.hasLength(vmVendor) && vmVendor.toLowerCase(Locale.ROOT).contains("openj9")) { - return true; - } - return false; + return StringUtils.hasLength(vmVendor) && vmVendor.toLowerCase(Locale.ROOT).contains("openj9"); } /** diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/net/util/UrlDecoder.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/net/util/UrlDecoder.java index 575a30f8548d..ba4699b0224f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/net/util/UrlDecoder.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/net/util/UrlDecoder.java @@ -73,13 +73,10 @@ public static String decode(String string) { private static int fillByteBuffer(ByteBuffer byteBuffer, String string, int index, int length) { byteBuffer.clear(); - while (true) { + do { byteBuffer.put(unescape(string, index)); index += 3; - if (index >= length || string.charAt(index) != '%') { - break; - } - } + } while (index < length && string.charAt(index) == '%'); byteBuffer.flip(); return index; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/CharSequenceToObjectConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/CharSequenceToObjectConverter.java index 9a88b4ceae1b..a59b43f3b7dc 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/CharSequenceToObjectConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/CharSequenceToObjectConverter.java @@ -87,12 +87,9 @@ private boolean isStringConversionBetter(TypeDescriptor sourceType, TypeDescript return true; } } - if ((targetType.isArray() || targetType.isCollection()) && !targetType.equals(BYTE_ARRAY)) { - // StringToArrayConverter / StringToCollectionConverter are better than - // ObjectToArrayConverter / ObjectToCollectionConverter - return true; - } - return false; + // StringToArrayConverter / StringToCollectionConverter are better than + // ObjectToArrayConverter / ObjectToCollectionConverter + return (targetType.isArray() || targetType.isCollection()) && !targetType.equals(BYTE_ARRAY); } @Override From 2724e29267ed50cf9d5cfe1cb9de3347174ea15c Mon Sep 17 00:00:00 2001 From: Piyal Ahmed Date: Fri, 4 Jul 2025 23:59:31 +0800 Subject: [PATCH 2/3] Revert changes to CharSequenceToObjectConverter Signed-off-by: Piyal Ahmed --- .../boot/convert/CharSequenceToObjectConverter.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/CharSequenceToObjectConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/CharSequenceToObjectConverter.java index a59b43f3b7dc..9a88b4ceae1b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/CharSequenceToObjectConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/CharSequenceToObjectConverter.java @@ -87,9 +87,12 @@ private boolean isStringConversionBetter(TypeDescriptor sourceType, TypeDescript return true; } } - // StringToArrayConverter / StringToCollectionConverter are better than - // ObjectToArrayConverter / ObjectToCollectionConverter - return (targetType.isArray() || targetType.isCollection()) && !targetType.equals(BYTE_ARRAY); + if ((targetType.isArray() || targetType.isCollection()) && !targetType.equals(BYTE_ARRAY)) { + // StringToArrayConverter / StringToCollectionConverter are better than + // ObjectToArrayConverter / ObjectToCollectionConverter + return true; + } + return false; } @Override From 9368164698502c0cfaee630a8a9c19c6e65a0c62 Mon Sep 17 00:00:00 2001 From: Piyal Ahmed Date: Sat, 5 Jul 2025 00:41:12 +0800 Subject: [PATCH 3/3] Fix formatting issue Signed-off-by: Piyal Ahmed --- .../org/springframework/boot/loader/net/util/UrlDecoder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/net/util/UrlDecoder.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/net/util/UrlDecoder.java index ba4699b0224f..f455a49a273e 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/net/util/UrlDecoder.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/net/util/UrlDecoder.java @@ -76,7 +76,8 @@ private static int fillByteBuffer(ByteBuffer byteBuffer, String string, int inde do { byteBuffer.put(unescape(string, index)); index += 3; - } while (index < length && string.charAt(index) == '%'); + } + while (index < length && string.charAt(index) == '%'); byteBuffer.flip(); return index; }