This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new 2b6ea03543 SonarQube bug fixes
2b6ea03543 is described below
commit 2b6ea03543ed5038138f65b31dfa4a9761f21387
Author: James Bognar <[email protected]>
AuthorDate: Tue Feb 3 20:14:34 2026 -0500
SonarQube bug fixes
---
.../apache/juneau/commons/utils/StringUtils.java | 24 +++++++++++-----------
.../org/apache/juneau/httppart/HttpPartSchema.java | 2 +-
.../java/org/apache/juneau/swap/AutoListSwap.java | 4 ++--
.../java/org/apache/juneau/swap/AutoMapSwap.java | 4 ++--
.../org/apache/juneau/swap/AutoNumberSwap.java | 4 ++--
.../org/apache/juneau/swap/AutoObjectSwap.java | 4 ++--
.../java/org/apache/juneau/http/part/PartList.java | 2 +-
.../java/org/apache/juneau/rest/RestResponse.java | 2 +-
.../juneau/rest/httppart/RequestQueryParams.java | 2 +-
9 files changed, 24 insertions(+), 24 deletions(-)
diff --git
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/StringUtils.java
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/StringUtils.java
index 37734e577c..61483d1b53 100644
---
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/StringUtils.java
+++
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/StringUtils.java
@@ -302,7 +302,7 @@ public class StringUtils {
if (str != null) {
if (sb == null)
sb = new StringBuilder();
- else if (sb.length() > 0 && separator != null)
+ else if (!sb.isEmpty() && separator != null)
sb.append(separator);
sb.append(str);
}
@@ -4476,7 +4476,7 @@ public class StringUtils {
i++;
}
- return result.length() > 0 ? result.toString() :
upper.substring(0, Math.min(1, upper.length()));
+ return !result.isEmpty() ? result.toString() :
upper.substring(0, Math.min(1, upper.length()));
}
/**
@@ -7793,7 +7793,7 @@ public class StringUtils {
// (single long words should not be
broken for readability)
if (wordLength > wrapLength &&
words.length > 1) {
// Word is too long and there
are other words, break it
- if (result.length() > 0)
+ if (!result.isEmpty())
result.append(newline);
var wordPos = 0;
while (wordPos < wordLength) {
@@ -7819,7 +7819,7 @@ public class StringUtils {
currentLine.append('
').append(word);
} else {
// Doesn't fit or fits exactly
- start new line
- if (result.length() > 0)
+ if (!result.isEmpty())
result.append(newline);
result.append(currentLine);
currentLine.setLength(0);
@@ -7846,8 +7846,8 @@ public class StringUtils {
}
// Append any remaining line
- if (currentLine.length() > 0) {
- if (result.length() > 0)
+ if (!currentLine.isEmpty()) {
+ if (!result.isEmpty())
result.append(newline);
result.append(currentLine);
}
@@ -8273,7 +8273,7 @@ public class StringUtils {
var isLetter = LETTER.contains(c);
if (isSeparator) {
- if (sb.length() > 0) {
+ if (!sb.isEmpty()) {
words.add(sb.toString());
sb.setLength(0);
}
@@ -8285,7 +8285,7 @@ public class StringUtils {
// 1. Uppercase after lowercase (e.g.,
"helloWorld" → "hello", "World")
// 2. Uppercase after consecutive uppercase
when next is lowercase (e.g., "XMLHttp" → "XML", "Http")
// 3. Lowercase after 2+ consecutive uppercase
(e.g., "XMLHttp" → "XML", "Http")
- if (sb.length() > 0) {
+ if (!sb.isEmpty()) {
if (isUpperCase && wasLowerCase) {
// Case 1: uppercase after
lowercase (e.g., "helloWorld" → "hello", "World")
words.add(sb.toString());
@@ -8328,12 +8328,12 @@ public class StringUtils {
sb.append(c);
wasLowerCase = false;
wasUpperCase = false;
- consecutiveUpperCount = 0;
- }
+ consecutiveUpperCount = 0;
}
+ }
- if (sb.length() > 0)
- words.add(sb.toString());
+ if (!sb.isEmpty())
+ words.add(sb.toString());
return words;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
index 6351017fb1..1b2b651484 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
@@ -4422,7 +4422,7 @@ public class HttpPartSchema {
private static boolean isValidIriReference(String x) {
// RFC 3987 IRI reference (allows international characters)
- return x.length() > 0;
+ return !x.isEmpty();
}
private static boolean isValidJsonPointer(String x) {
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoListSwap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoListSwap.java
index b944fc8828..ac7b2b5f68 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoListSwap.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoListSwap.java
@@ -133,7 +133,7 @@ public class AutoListSwap<T> extends ObjectSwap<T,List<?>> {
&& mi.hasAnyName(SWAP_METHOD_NAMES)
&& mi.hasReturnTypeParent(List.class)
&& mi.hasParameterTypesLenient(BeanSession.class)
- && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().has(BeanIgnore.class, m2));
+ && mi.getMatchingMethods().stream().noneMatch(m2 ->
bc.getAnnotationProvider().has(BeanIgnore.class, m2));
// @formatter:on
}
@@ -156,7 +156,7 @@ public class AutoListSwap<T> extends ObjectSwap<T,List<?>> {
&& mi.hasAnyName(UNSWAP_METHOD_NAMES)
&& mi.hasParameterTypesLenient(BeanSession.class,
rt.inner())
&& mi.hasReturnTypeParent(ci)
- && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().has(BeanIgnore.class, m2));
+ && mi.getMatchingMethods().stream().noneMatch(m2 ->
bc.getAnnotationProvider().has(BeanIgnore.class, m2));
// @formatter:on
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoMapSwap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoMapSwap.java
index 3f74d3919d..03641ff09f 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoMapSwap.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoMapSwap.java
@@ -133,7 +133,7 @@ public class AutoMapSwap<T> extends ObjectSwap<T,Map<?,?>> {
&& mi.hasAnyName(SWAP_METHOD_NAMES)
&& mi.hasReturnTypeParent(Map.class)
&& mi.hasParameterTypesLenient(BeanSession.class)
- && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().has(BeanIgnore.class, m2));
+ && mi.getMatchingMethods().stream().noneMatch(m2 ->
bc.getAnnotationProvider().has(BeanIgnore.class, m2));
// @formatter:on
}
@@ -156,7 +156,7 @@ public class AutoMapSwap<T> extends ObjectSwap<T,Map<?,?>> {
&& mi.hasAnyName(UNSWAP_METHOD_NAMES)
&& mi.hasParameterTypesLenient(BeanSession.class,
rt.inner())
&& mi.hasReturnTypeParent(ci)
- && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().has(BeanIgnore.class, m2));
+ && mi.getMatchingMethods().stream().noneMatch(m2 ->
bc.getAnnotationProvider().has(BeanIgnore.class, m2));
// @formatter:on
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoNumberSwap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoNumberSwap.java
index b26226693d..f1fdfd394c 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoNumberSwap.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoNumberSwap.java
@@ -158,7 +158,7 @@ public class AutoNumberSwap<T> extends ObjectSwap<T,Number>
{
&& (rt.isAssignableTo(Number.class) ||
(rt.isPrimitive() && rt.isAny(int.class, short.class, long.class, float.class,
double.class, byte.class)))
&& mi.hasAnyName(SWAP_METHOD_NAMES)
&& mi.hasParameterTypesLenient(BeanSession.class)
- && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().has(BeanIgnore.class, m2));
+ && mi.getMatchingMethods().stream().noneMatch(m2 ->
bc.getAnnotationProvider().has(BeanIgnore.class, m2));
// @formatter:on
}
@@ -181,7 +181,7 @@ public class AutoNumberSwap<T> extends ObjectSwap<T,Number>
{
&& mi.hasAnyName(UNSWAP_METHOD_NAMES)
&& mi.hasParameterTypesLenient(BeanSession.class,
rt.inner())
&& mi.hasReturnTypeParent(ci)
- && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().has(BeanIgnore.class, m2));
+ && mi.getMatchingMethods().stream().noneMatch(m2 ->
bc.getAnnotationProvider().has(BeanIgnore.class, m2));
// @formatter:on
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoObjectSwap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoObjectSwap.java
index d006e60c72..1b1f4ffa7c 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoObjectSwap.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoObjectSwap.java
@@ -134,7 +134,7 @@ public class AutoObjectSwap<T> extends ObjectSwap<T,Object>
{
&& mi.isVisible(bc.getBeanMethodVisibility())
&& mi.hasAnyName(SWAP_METHOD_NAMES)
&& mi.hasParameterTypesLenient(BeanSession.class)
- && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().has(BeanIgnore.class, m2));
+ && mi.getMatchingMethods().stream().noneMatch(m2 ->
bc.getAnnotationProvider().has(BeanIgnore.class, m2));
// @formatter:on
}
@@ -157,7 +157,7 @@ public class AutoObjectSwap<T> extends ObjectSwap<T,Object>
{
&& mi.hasAnyName(UNSWAP_METHOD_NAMES)
&& mi.hasParameterTypesLenient(BeanSession.class,
rt.inner())
&& mi.hasReturnTypeParent(ci)
- && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().has(BeanIgnore.class, m2));
+ && mi.getMatchingMethods().stream().noneMatch(m2 ->
bc.getAnnotationProvider().has(BeanIgnore.class, m2));
// @formatter:on
}
diff --git
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/part/PartList.java
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/part/PartList.java
index 6f2cbdd0b0..a85fb3b705 100644
---
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/part/PartList.java
+++
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/part/PartList.java
@@ -877,7 +877,7 @@ public class PartList extends
ControlledArrayList<NameValuePair> {
if (nn(p)) {
var v = p.getValue();
if (nn(v)) {
- if (sb.length() > 0)
+ if (!sb.isEmpty())
sb.append("&");
sb.append(urlEncode(p.getName())).append('=').append(urlEncode(p.getValue()));
}
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java
index 98e59f85fe..d449e8b0a7 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java
@@ -535,7 +535,7 @@ public class RestResponse extends
HttpServletResponseWrapper {
*/
@Override
public void sendRedirect(String uri) throws IOException {
- var c = (uri.length() > 0 ? uri.charAt(0) : 0);
+ var c = (!uri.isEmpty() ? uri.charAt(0) : 0);
if (c != '/' && uri.indexOf("://") == -1)
uri = request.getContextPath() + '/' + uri;
inner.sendRedirect(uri);
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestQueryParams.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestQueryParams.java
index 8f14941d58..c0e751c84d 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestQueryParams.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestQueryParams.java
@@ -281,7 +281,7 @@ public class RequestQueryParams extends
ArrayList<RequestQueryParam> {
public String asQueryString() {
var sb = new StringBuilder();
for (var e : this) {
- if (sb.length() > 0)
+ if (!sb.isEmpty())
sb.append("&");
sb.append(urlEncode(e.getName())).append('=').append(urlEncode(e.getValue()));
}