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 5ba8da7deb SonarQube bug fixes
5ba8da7deb is described below
commit 5ba8da7deb3eeb64b06b67824f949e1770e2eddd
Author: James Bognar <[email protected]>
AuthorDate: Wed Feb 4 17:48:51 2026 -0500
SonarQube bug fixes
---
.../apache/juneau/commons/reflect/AnnotationProvider.java | 2 +-
.../java/org/apache/juneau/commons/utils/StringUtils.java | 2 +-
.../src/main/java/org/apache/juneau/BeanMeta.java | 2 +-
.../main/java/org/apache/juneau/jsonschema/SchemaUtils.java | 4 ++--
.../main/java/org/apache/juneau/parser/ParseException.java | 4 ++--
.../src/main/java/org/apache/juneau/parser/ParserPipe.java | 6 +++---
.../org/apache/juneau/serializer/SerializeException.java | 4 ++--
.../java/org/apache/juneau/swaps/TemporalCalendarSwap.java | 2 +-
.../src/main/java/org/apache/juneau/xml/Namespace.java | 13 ++++++-------
.../org/apache/juneau/rest/util/FinishablePrintWriter.java | 2 +-
.../juneau/rest/util/FinishableServletOutputStream.java | 4 ++--
.../java/org/apache/juneau/rest/vars/RequestSwaggerVar.java | 7 ++++---
12 files changed, 26 insertions(+), 26 deletions(-)
diff --git
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/AnnotationProvider.java
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/AnnotationProvider.java
index a9bcccb33f..20a1ba1187 100644
---
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/AnnotationProvider.java
+++
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/AnnotationProvider.java
@@ -488,7 +488,7 @@ public class AnnotationProvider {
.logOnExit(builder.logOnExit,
"AnnotationProvider.cache")
.build();
- this.annotationMap = opt(builder.runtimeAnnotations).map(x ->
x.build()).orElse(null);
+ this.annotationMap =
opt(builder.runtimeAnnotations).map(ReflectionMap.Builder::build).orElse(null);
// @formatter:on
}
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 5a07c9436b..2357d58acd 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
@@ -8092,7 +8092,7 @@ public class StringUtils {
list.add(readifier(File.class, (File x) -> safe(() ->
read(x))));
list.add(readifier(byte[].class, x -> toHex(x)));
list.add(readifier(Enum.class, x -> ((Enum<?>)x).name()));
- list.add(readifier(Class.class, x -> cns(x)));
+ list.add(readifier(Class.class, Utils::cns));
list.add(readifier(Constructor.class, x ->
ConstructorInfo.of(x).getNameFull()));
list.add(readifier(Method.class, x ->
MethodInfo.of(x).getNameFull()));
list.add(readifier(Field.class, x ->
FieldInfo.of(x).toString()));
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMeta.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMeta.java
index 6d42aaacf7..a0a226623d 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMeta.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMeta.java
@@ -410,7 +410,7 @@ public class BeanMeta<T> {
var ba = ap.find(Bean.class, cm);
var propertyNamer = opt(bf).map(x ->
x.getPropertyNamer()).orElse(beanContext.getPropertyNamer());
- this.typePropertyName = ba.stream().map(x ->
x.inner().typePropertyName()).filter(Utils::ne).findFirst().orElseGet(() ->
beanContext.getBeanTypePropertyName());
+ this.typePropertyName = ba.stream().map(x ->
x.inner().typePropertyName()).filter(Utils::ne).findFirst().orElseGet(beanContext::getBeanTypePropertyName);
// Check if constructor is required but not found
if (! beanConstructor.constructor().isPresent() && bf == null
&& beanContext.isBeansRequireDefaultConstructor())
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/SchemaUtils.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/SchemaUtils.java
index fed04290cc..5e2a20eedc 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/SchemaUtils.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/SchemaUtils.java
@@ -64,8 +64,8 @@ public class SchemaUtils {
public static JsonMap parseMap(Object o) throws ParseException {
if (o == null)
return null;
- if (o instanceof String[])
- o = joinnl((String[])o);
+ if (o instanceof String[] o2)
+ o = joinnl(o2);
if (o instanceof String o2) {
var s = o2;
if (s.isEmpty())
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParseException.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParseException.java
index 68fa5eab01..1c825c7741 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParseException.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParseException.java
@@ -162,8 +162,8 @@ public class ParseException extends BasicRuntimeException {
*/
public ParseException getRootCause() {
ParseException t = this;
- while (! (t.getCause() == null || ! (t.getCause() instanceof
ParseException)))
- t = (ParseException)t.getCause();
+ while (! (t.getCause() == null || ! (t.getCause() instanceof
ParseException t2)))
+ t = t2;
return t;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserPipe.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserPipe.java
index 8a4298ee52..f8aec00ff4 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserPipe.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserPipe.java
@@ -221,10 +221,10 @@ public class ParserPipe implements Closeable {
inputStream = input2;
doClose = autoCloseStreams;
}
- } else if (input instanceof byte[]) {
+ } else if (input instanceof byte[] input2) {
if (debug)
- inputString = toHex((byte[])input);
- inputStream = new ByteArrayInputStream((byte[])input);
+ inputString = toHex(input2);
+ inputStream = new ByteArrayInputStream(input2);
doClose = false;
} else if (input instanceof String input2) {
inputString = input2;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializeException.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializeException.java
index bae50dc0c2..3ff8eb63dc 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializeException.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializeException.java
@@ -116,8 +116,8 @@ public class SerializeException extends
BasicRuntimeException {
*/
public SerializeException getRootCause() {
SerializeException t = this;
- while (! (t.getCause() == null || ! (t.getCause() instanceof
SerializeException)))
- t = (SerializeException)t.getCause();
+ while (! (t.getCause() == null || ! (t.getCause() instanceof
SerializeException t2)))
+ t = t2;
return t;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swaps/TemporalCalendarSwap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swaps/TemporalCalendarSwap.java
index 189cea1ac3..2621d29d99 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swaps/TemporalCalendarSwap.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swaps/TemporalCalendarSwap.java
@@ -293,7 +293,7 @@ public class TemporalCalendarSwap extends
StringSwap<Calendar> {
public String swap(BeanSession session, Calendar o) throws Exception {
if (o == null)
return null;
- var t = o instanceof GregorianCalendar ?
((GregorianCalendar)o).toZonedDateTime() :
o.toInstant().atZone(session.getTimeZoneId());
+ var t = o instanceof GregorianCalendar o2 ?
o2.toZonedDateTime() : o.toInstant().atZone(session.getTimeZoneId());
return formatter.format(t);
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/Namespace.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/Namespace.java
index 3812cff5d1..b2d1c556c2 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/Namespace.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/Namespace.java
@@ -80,14 +80,13 @@ public class Namespace {
*/
public static Namespace[] createArray(Object o) {
- if (o instanceof Namespace[])
- return (Namespace[])o;
+ if (o instanceof Namespace[] o2)
+ return o2;
- if (o instanceof String[]) {
- var ss = (String[])o;
- var n = new Namespace[ss.length];
- for (var i = 0; i < ss.length; i++)
- n[i] = create(ss[i]);
+ if (o instanceof String[] o2) {
+ var n = new Namespace[o2.length];
+ for (var i = 0; i < o2.length; i++)
+ n[i] = create(o2[i]);
return n;
}
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/FinishablePrintWriter.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/FinishablePrintWriter.java
index dc50946fb9..a59ca50388 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/FinishablePrintWriter.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/FinishablePrintWriter.java
@@ -40,7 +40,7 @@ public class FinishablePrintWriter extends PrintWriter
implements Finishable {
*/
public FinishablePrintWriter(OutputStream out, String
characterEncoding, boolean autoFlush) throws IOException {
super(new OutputStreamWriter(out, characterEncoding),
autoFlush);
- f = (out instanceof Finishable ? (Finishable)out : null);
+ f = (out instanceof Finishable out2 ? out2 : null);
}
/**
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/FinishableServletOutputStream.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/FinishableServletOutputStream.java
index 1f1386d73a..a8c3b4869b 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/FinishableServletOutputStream.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/FinishableServletOutputStream.java
@@ -41,8 +41,8 @@ public class FinishableServletOutputStream extends
ServletOutputStream implement
*/
public FinishableServletOutputStream(OutputStream os) {
this.os = os;
- this.sos = (os instanceof ServletOutputStream ?
(ServletOutputStream)os : null);
- this.f = (os instanceof Finishable ? (Finishable)os : null);
+ this.sos = (os instanceof ServletOutputStream os2 ? os2 : null);
+ this.f = (os instanceof Finishable os2 ? os2 : null);
}
@Override /* Overridden from OutputStream */
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestSwaggerVar.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestSwaggerVar.java
index 06c2376c40..fde02e9687 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestSwaggerVar.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/vars/RequestSwaggerVar.java
@@ -17,7 +17,8 @@
package org.apache.juneau.rest.vars;
import static org.apache.juneau.commons.utils.StringUtils.*;
-import static org.apache.juneau.commons.utils.Utils.*;
+
+import org.apache.juneau.commons.utils.Utils;
import java.util.*;
@@ -99,7 +100,7 @@ public class RequestSwaggerVar extends MultipartResolvingVar
{
char c = charAt(key, 0);
if (c == 'c') {
if ("contact".equals(key))
- return
swagger.map(Swagger::getInfo).map(x -> x == null ? null : x.getContact()).map(x
-> s(x)).orElse(null);
+ return
swagger.map(Swagger::getInfo).map(x -> x == null ? null :
x.getContact()).map(Utils::s).orElse(null);
} else if (c == 'd') {
if ("description".equals(key))
return
swagger.map(Swagger::getInfo).map(x -> x == null ? null :
x.getDescription()).orElse(null);
@@ -108,7 +109,7 @@ public class RequestSwaggerVar extends
MultipartResolvingVar {
return
swagger.map(Swagger::getExternalDocs).map(ExternalDocumentation::toString).orElse(null);
} else if (c == 'l') {
if ("license".equals(key))
- return
swagger.map(Swagger::getInfo).map(x -> x == null ? null : x.getLicense()).map(x
-> s(x)).orElse(null);
+ return
swagger.map(Swagger::getInfo).map(x -> x == null ? null :
x.getLicense()).map(Utils::s).orElse(null);
} else if (c == 'o') {
if ("operationDescription".equals(key))
return
methodSwagger.map(Operation::getDescription).orElse(null);