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 dc1564b54 Fix SonarQube issues.
dc1564b54 is described below
commit dc1564b541c62b01ee8e0377f6cd702ac85dafff
Author: James Bognar <[email protected]>
AuthorDate: Sun Jul 27 11:22:26 2025 -0400
Fix SonarQube issues.
---
.../apache/juneau/common/internal/ArgUtils.java | 4 +-
.../apache/juneau/common/internal/AsciiSet.java | 3 +-
.../org/apache/juneau/common/internal/IOUtils.java | 163 +++++++--------
.../juneau/common/internal/PathReaderBuilder.java | 170 ++++++++--------
.../apache/juneau/common/internal/StringUtils.java | 220 ++++++++++-----------
.../apache/juneau/common/internal/SystemUtils.java | 4 +-
.../juneau/common/internal/ThrowableUtils.java | 13 +-
.../java/org/apache/juneau/AnnotationApplier.java | 6 +-
.../src/main/java/org/apache/juneau/BeanMeta.java | 2 +-
.../java/org/apache/juneau/BeanPropertyMeta.java | 2 +-
.../main/java/org/apache/juneau/BeanSession.java | 2 +-
.../apache/juneau/csv/CsvSerializerSession.java | 2 +-
.../org/apache/juneau/html/HtmlParserSession.java | 4 +-
.../org/apache/juneau/json/JsonParserSession.java | 20 +-
.../org/apache/juneau/jsonschema/SchemaUtils.java | 2 +-
.../juneau/objecttools/NumberMatcherFactory.java | 2 +-
.../apache/juneau/objecttools/ObjectPaginator.java | 2 +-
.../org/apache/juneau/objecttools/ObjectRest.java | 3 +-
.../org/apache/juneau/reflect/ExecutableInfo.java | 4 +-
.../org/apache/juneau/uon/UonParserSession.java | 10 +-
.../urlencoding/UrlEncodingParserSession.java | 4 +-
.../java/org/apache/juneau/utils/Consumer2.java | 2 +-
.../java/org/apache/juneau/utils/Consumer3.java | 2 +-
.../java/org/apache/juneau/utils/Consumer4.java | 2 +-
juneau-doc/src/main/javadoc/overview.html | 16 +-
25 files changed, 324 insertions(+), 340 deletions(-)
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/ArgUtils.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/ArgUtils.java
index 8dcf0efb4..97fd8d3c2 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/ArgUtils.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/ArgUtils.java
@@ -19,6 +19,8 @@ import java.text.*;
*/
public class ArgUtils {
+ private ArgUtils() {}
+
/**
* Throws an {@link IllegalArgumentException} if the specified argument
is <jk>null</jk>.
*
@@ -76,12 +78,10 @@ public class ArgUtils {
* @return The value cast to the specified array type.
* @throws IllegalArgumentException Constructed exception.
*/
- @SuppressWarnings("unchecked")
public static final <E> Class<E>[] assertClassArrayArgIsType(String
name, Class<E> type, Class<?>[] value) throws IllegalArgumentException {
for (int i = 0; i < value.length; i++)
if (! type.isAssignableFrom(value[i]))
throw new IllegalArgumentException("Arg
"+name+" did not have arg of type "+type.getName()+" at index "+i+":
"+value[i].getName());
return (Class<E>[])value;
}
-
}
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/AsciiSet.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/AsciiSet.java
index 6fbb63e8d..51cdbec0a 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/AsciiSet.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/AsciiSet.java
@@ -136,8 +136,7 @@ public final class AsciiSet {
*/
public AsciiSet.Builder copy() {
Builder b = new Builder();
- for (int i = 0; i < 128; i++)
- b.store[i] = store[i];
+ System.arraycopy(store, 0, b.store, 0, 128);
return b;
}
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/IOUtils.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/IOUtils.java
index 79aea8565..0d864123a 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/IOUtils.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/IOUtils.java
@@ -24,7 +24,8 @@ import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.StringReader;
import java.io.Writer;
-import java.nio.charset.Charset;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Scanner;
@@ -36,8 +37,10 @@ import java.util.function.Consumer;
*/
public final class IOUtils {
+ private IOUtils() {}
+
/** UTF-8 charset */
- public static final Charset UTF8 = Charset.forName("UTF-8");
+ public static final Charset UTF8 = StandardCharsets.UTF_8;
/** Reusable empty input stream. */
public static final InputStream EMPTY_INPUT_STREAM = new InputStream() {
@@ -48,8 +51,8 @@ public final class IOUtils {
};
private static final int BUFF_SIZE = 1024;
- private static final ThreadLocal<byte[]> BYTE_BUFFER_CACHE =
(Boolean.getBoolean("juneau.disableIoBufferReuse") ? null : new
ThreadLocal<>());
- private static final ThreadLocal<char[]> CHAR_BUFFER_CACHE =
(Boolean.getBoolean("juneau.disableIoBufferReuse") ? null : new
ThreadLocal<>());
+ private static final ThreadLocal<byte[]> BYTE_BUFFER_CACHE =
(Boolean.getBoolean("juneau.disableIoBufferReuse") ? null : new
ThreadLocal<>()); // NOSONAR
+ private static final ThreadLocal<char[]> CHAR_BUFFER_CACHE =
(Boolean.getBoolean("juneau.disableIoBufferReuse") ? null : new
ThreadLocal<>()); // NOSONAR
static final AtomicInteger BYTE_BUFFER_CACHE_HITS = new AtomicInteger();
static final AtomicInteger BYTE_BUFFER_CACHE_MISSES = new
AtomicInteger();
@@ -72,7 +75,7 @@ public final class IOUtils {
return -1; // end of stream
}
@Override
- public void close() throws IOException {}
+ public void close() throws IOException { /* no-op */ }
};
//-----------------------------------------------------------------------------------------------------------------
@@ -436,14 +439,14 @@ public final class IOUtils {
public static String read(Object in) throws IOException {
if (in == null)
return null;
- if (in instanceof Reader)
- return read((Reader)in);
- if (in instanceof InputStream)
- return read((InputStream)in);
- if (in instanceof File)
- return read((File)in);
- if (in instanceof byte[])
- return read((byte[])in);
+ if (in instanceof Reader in2)
+ return read(in2);
+ if (in instanceof InputStream in2)
+ return read(in2);
+ if (in instanceof File in2)
+ return read(in2);
+ if (in instanceof byte[] in2)
+ return read(in2);
throw new IllegalArgumentException("Invalid type passed to
read: " + in.getClass().getName());
}
@@ -474,49 +477,49 @@ public final class IOUtils {
return new String(in, charset);
}
- /**
- * Reads the contents of a file into a string.
- *
- * <p>
- * Assumes default character encoding.
- *
- * @param in
- * The file to read.
- * <br>Can be <jk>null</jk>.
- * @return
- * The contents of the reader as a string, or <jk>null</jk> if file does
not exist.
- * @throws IOException If a problem occurred trying to read from the
reader.
- */
- public static String read(File in) throws IOException {
- if (in == null || ! in.exists())
- return null;
- try (Reader r = FileReaderBuilder.create(in).build()) {
- return read(r, in.length());
- }
- }
-
- /**
- * Reads the contents of a path into a string.
- *
- * <p>
- * Assumes default character encoding.
- *
- * @param in
- * The path to read.
- * <br>Can be <jk>null</jk>.
- * @return
- * The contents of the reader as a string, or <jk>null</jk> if path does
not exist.
- * @throws IOException If a problem occurred trying to read from the
reader.
- * @since 9.1.0
- */
- public static String read(Path in) throws IOException {
- if (in == null || !Files.exists(in)) {
- return null;
- }
- try (Reader r = PathReaderBuilder.create(in).build()) {
- return read(r, Files.size(in));
- }
- }
+ /**
+ * Reads the contents of a file into a string.
+ *
+ * <p>
+ * Assumes default character encoding.
+ *
+ * @param in
+ * The file to read.
+ * <br>Can be <jk>null</jk>.
+ * @return
+ * The contents of the reader as a string, or <jk>null</jk> if file
does not exist.
+ * @throws IOException If a problem occurred trying to read from the
reader.
+ */
+ public static String read(File in) throws IOException {
+ if (in == null || ! in.exists())
+ return null;
+ try (Reader r = FileReaderBuilder.create(in).build()) {
+ return read(r, in.length());
+ }
+ }
+
+ /**
+ * Reads the contents of a path into a string.
+ *
+ * <p>
+ * Assumes default character encoding.
+ *
+ * @param in
+ * The path to read.
+ * <br>Can be <jk>null</jk>.
+ * @return
+ * The contents of the reader as a string, or <jk>null</jk> if path
does not exist.
+ * @throws IOException If a problem occurred trying to read from the
reader.
+ * @since 9.1.0
+ */
+ public static String read(Path in) throws IOException {
+ if (in == null || !Files.exists(in)) {
+ return null;
+ }
+ try (Reader r = PathReaderBuilder.create(in).build()) {
+ return read(r, Files.size(in));
+ }
+ }
/**
* Reads the contents of a reader into a string.
@@ -822,7 +825,7 @@ public final class IOUtils {
try {
if (is != null)
is.close();
- } catch (IOException e) {}
+ } catch (IOException e) { /* ignore */ }
}
/**
@@ -837,7 +840,7 @@ public final class IOUtils {
try {
if (os != null)
os.close();
- } catch (IOException e) {}
+ } catch (IOException e) { /* ignore */ }
}
/**
@@ -852,7 +855,7 @@ public final class IOUtils {
try {
if (r != null)
r.close();
- } catch (IOException e) {}
+ } catch (IOException e) { /* ignore */ }
}
/**
@@ -867,7 +870,7 @@ public final class IOUtils {
try {
if (w != null)
w.close();
- } catch (IOException e) {}
+ } catch (IOException e) { /* ignore */ }
}
/**
@@ -877,14 +880,14 @@ public final class IOUtils {
*/
public static void closeQuietly(Object...o) {
for (Object o2 : o) {
- if (o2 instanceof InputStream)
- closeQuietly((InputStream)o2);
- if (o2 instanceof OutputStream)
- closeQuietly((OutputStream)o2);
- if (o2 instanceof Reader)
- closeQuietly((Reader)o2);
- if (o2 instanceof Writer)
- closeQuietly((Writer)o2);
+ if (o2 instanceof InputStream o3)
+ closeQuietly(o3);
+ if (o2 instanceof OutputStream o3)
+ closeQuietly(o3);
+ if (o2 instanceof Reader o3)
+ closeQuietly(o3);
+ if (o2 instanceof Writer o3)
+ closeQuietly(o3);
}
}
@@ -900,10 +903,10 @@ public final class IOUtils {
IOException ex = null;
for (Object o2 : o) {
try {
- if (o2 instanceof OutputStream)
- ((OutputStream)o2).flush();
- if (o2 instanceof Writer)
- ((Writer)o2).flush();
+ if (o2 instanceof OutputStream o3)
+ o3.flush();
+ if (o2 instanceof Writer o3)
+ o3.flush();
} catch (IOException e) {
ex = e;
}
@@ -924,14 +927,14 @@ public final class IOUtils {
IOException ex = null;
for (Object o2 : o) {
try {
- if (o2 instanceof InputStream)
- ((InputStream)o2).close();
- if (o2 instanceof OutputStream)
- ((OutputStream)o2).close();
- if (o2 instanceof Reader)
- ((Reader)o2).close();
- if (o2 instanceof Writer)
- ((Writer)o2).close();
+ if (o2 instanceof InputStream o3)
+ o3.close();
+ if (o2 instanceof OutputStream o3)
+ o3.close();
+ if (o2 instanceof Reader o3)
+ o3.close();
+ if (o2 instanceof Writer o3)
+ o3.close();
} catch (IOException e) {
ex = e;
}
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/PathReaderBuilder.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/PathReaderBuilder.java
index c2c6bcb8a..a9970a137 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/PathReaderBuilder.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/PathReaderBuilder.java
@@ -12,6 +12,8 @@
//
***************************************************************************************************************************
package org.apache.juneau.common.internal;
+import static java.util.Optional.*;
+
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
@@ -28,98 +30,98 @@ import java.nio.file.Paths;
*/
public final class PathReaderBuilder {
- /**
- * Creates a new builder.
- *
- * @return A new builder.
- */
- public static PathReaderBuilder create() {
- return new PathReaderBuilder();
- }
+ /**
+ * Creates a new builder.
+ *
+ * @return A new builder.
+ */
+ public static PathReaderBuilder create() {
+ return new PathReaderBuilder();
+ }
- /**
- * Creates a new builder initialized with the specified path.
- *
- * @param path The path being written to.
- * @return A new builder.
- */
- public static PathReaderBuilder create(final Path path) {
- return new PathReaderBuilder().path(path);
- }
+ /**
+ * Creates a new builder initialized with the specified path.
+ *
+ * @param path The path being written to.
+ * @return A new builder.
+ */
+ public static PathReaderBuilder create(final Path path) {
+ return new PathReaderBuilder().path(path);
+ }
- private Path path;
+ private Path path;
- private Charset charset = Charset.defaultCharset();
+ private Charset charset = Charset.defaultCharset();
- private boolean allowNoFile;
+ private boolean allowNoFile;
- /**
- * If called and the path is <jk>null</jk> or non-existent, then the
{@link #build()} command will return an empty reader instead of a {@link
IOException}.
- *
- * @return This object.
- */
- public PathReaderBuilder allowNoFile() {
- this.allowNoFile = true;
- return this;
- }
+ /**
+ * If called and the path is <jk>null</jk> or non-existent, then the
{@link #build()} command will return an empty reader instead of a {@link
IOException}.
+ *
+ * @return This object.
+ */
+ public PathReaderBuilder allowNoFile() {
+ this.allowNoFile = true;
+ return this;
+ }
- /**
- * Creates a new File reader.
- *
- * @return A new File reader.
- * @throws IOException if an I/O error occurs opening the path
- */
- public Reader build() throws IOException {
- if (!allowNoFile && path == null) {
- throw new IllegalStateException("No path");
- }
- if (!allowNoFile && !Files.exists(path)) {
- throw new NoSuchFileException(path.toString());
- }
- return allowNoFile ? new StringReader("") :
Files.newBufferedReader(path, charset != null ? charset :
Charset.defaultCharset());
- }
+ /**
+ * Creates a new File reader.
+ *
+ * @return A new File reader.
+ * @throws IOException if an I/O error occurs opening the path
+ */
+ public Reader build() throws IOException {
+ if (!allowNoFile && path == null) {
+ throw new IllegalStateException("No path");
+ }
+ if (!allowNoFile && !Files.exists(path)) {
+ throw new NoSuchFileException(path.toString());
+ }
+ return allowNoFile ? new StringReader("") :
Files.newBufferedReader(path,
ofNullable(charset).orElse(Charset.defaultCharset()));
+ }
- /**
- * Sets the character encoding of the path.
- *
- * @param charset The character encoding. The default is {@link
Charset#defaultCharset()}. Null resets to the default.
- * @return This object.
- */
- public PathReaderBuilder charset(final Charset charset) {
- this.charset = charset;
- return this;
- }
+ /**
+ * Sets the character encoding of the path.
+ *
+ * @param charset The character encoding. The default is {@link
Charset#defaultCharset()}. Null resets to the default.
+ * @return This object.
+ */
+ public PathReaderBuilder charset(final Charset charset) {
+ this.charset = charset;
+ return this;
+ }
- /**
- * Sets the character encoding of the path.
- *
- * @param charset The character encoding. The default is {@link
Charset#defaultCharset()}. Null resets to the default.
- * @return This object.
- */
- public PathReaderBuilder charset(final String charset) {
- this.charset = charset != null ? Charset.forName(charset) : null;
- return this;
- }
+ /**
+ * Sets the character encoding of the path.
+ *
+ * @param charset The character encoding. The default is {@link
Charset#defaultCharset()}. Null resets to the default.
+ * @return This object.
+ */
+ public PathReaderBuilder charset(final String charset) {
+ this.charset = charset != null ? Charset.forName(charset) :
null;
+ return this;
+ }
- /**
- * Sets the path being written from.
- *
- * @param path The path being written from.
- * @return This object.
- */
- public PathReaderBuilder path(final Path path) {
- this.path = path;
- return this;
- }
+ /**
+ * Sets the path being written from.
+ *
+ * @param path The path being written from.
+ * @return This object.
+ */
+ public PathReaderBuilder path(final Path path) {
+ this.path = path;
+ return this;
+ }
- /**
- * Sets the path of the path being written from.
- *
- * @param path The path of the path being written from.
- * @return This object.
- */
- public PathReaderBuilder path(final String path) {
- this.path = Paths.get(path);
- return this;
- }
+ /**
+ * Sets the path of the path being written from.
+ *
+ * @param path The path of the path being written from.
+ * @return This object.
+ */
+ public PathReaderBuilder path(final String path) {
+ this.path = Paths.get(path);
+ return this;
+ }
}
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/StringUtils.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/StringUtils.java
index c4cbe8b0c..5a64ce324 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/StringUtils.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/StringUtils.java
@@ -15,13 +15,13 @@ package org.apache.juneau.common.internal;
import static org.apache.juneau.common.internal.ArgUtils.*;
import static org.apache.juneau.common.internal.IOUtils.*;
import static org.apache.juneau.common.internal.ThrowableUtils.*;
+import static java.nio.charset.StandardCharsets.*;
import java.io.*;
import java.lang.reflect.*;
import java.math.*;
import java.net.*;
import java.nio.*;
-import java.nio.charset.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
@@ -38,6 +38,8 @@ import jakarta.xml.bind.*;
*/
public final class StringUtils {
+ private StringUtils() {}
+
/**
* Predicate check to filter out null and empty strings.
*/
@@ -75,6 +77,8 @@ public final class StringUtils {
base64m2[base64m1[i]] = (byte)i;
}
+ private static final Random RANDOM = new Random();
+
/**
* Parses a number from the specified string.
*
@@ -169,7 +173,7 @@ public final class StringUtils {
}
private static final Pattern fpRegex = Pattern.compile(
-
"[+-]?(NaN|Infinity|((((\\p{Digit}+)(\\.)?((\\p{Digit}+)?)([eE][+-]?(\\p{Digit}+))?)|(\\.((\\p{Digit}+))([eE][+-]?(\\p{Digit}+))?)|(((0[xX](\\p{XDigit}+)(\\.)?)|(0[xX](\\p{XDigit}+)?(\\.)(\\p{XDigit}+)))[pP][+-]?(\\p{Digit}+)))[fFdD]?))[\\x00-\\x20]*"
+
"[+-]?(NaN|Infinity|((((\\p{Digit}+)(\\.)?((\\p{Digit}+)?)([eE][+-]?(\\p{Digit}+))?)|(\\.((\\p{Digit}+))([eE][+-]?(\\p{Digit}+))?)|(((0[xX](\\p{XDigit}+)(\\.)?)|(0[xX](\\p{XDigit}+)?(\\.)(\\p{XDigit}+)))[pP][+-]?(\\p{Digit}+)))[fFdD]?))[\\x00-\\x20]*"
// NOSONAR
);
/**
@@ -229,7 +233,7 @@ public final class StringUtils {
i++;
if (i == length)
return false;
- c = s.charAt(i++);
+ c = s.charAt(i);
if (c == '.' || decChars.contains(c)) {
return fpRegex.matcher(s).matches();
}
@@ -384,14 +388,9 @@ public final class StringUtils {
}
private static AsciiSet getEscapeSet(char c) {
- AsciiSet s = ESCAPE_SETS.get(c);
- if (s == null) {
- s = AsciiSet.create().chars(c, '\\').build();
- ESCAPE_SETS.put(c, s);
- }
- return s;
+ return ESCAPE_SETS.computeIfAbsent(c, key ->
AsciiSet.create().chars(key, '\\').build());
}
- static Map<Character,AsciiSet> ESCAPE_SETS = new ConcurrentHashMap<>();
+ static final Map<Character,AsciiSet> ESCAPE_SETS = new
ConcurrentHashMap<>();
/**
* Join the specified tokens into a delimited string and writes the
output to the specified string builder.
@@ -570,7 +569,7 @@ public final class StringUtils {
else if (s.charAt(i)==c && escapeCount % 2 == 0) {
String s2 = s.substring(x1, i);
String s3 = unEscapeChars(s2, escapeChars);
- consumer.accept(s3.trim());
+ consumer.accept(s3.trim()); // NOSONAR - NPE
not possible.
x1 = i+1;
}
if (s.charAt(i) != '\\')
@@ -578,7 +577,7 @@ public final class StringUtils {
}
String s2 = s.substring(x1);
String s3 = unEscapeChars(s2, escapeChars);
- consumer.accept(s3.trim());
+ consumer.accept(s3.trim()); // NOSONAR - NPE not possible.
}
/**
@@ -594,7 +593,7 @@ public final class StringUtils {
AsciiSet escapeChars = getEscapeSet(c);
if (s == null)
- return null;
+ return null; // NOSONAR - Intentional.
if (isEmpty(s))
return new String[0];
if (s.indexOf(c) == -1)
@@ -629,11 +628,11 @@ public final class StringUtils {
*
* @param s The string to split. Can be <jk>null</jk>.
* @param c The character to split on.
- * @return The tokens.
+ * @return The tokens, or null if the input array was null
*/
public static String[] split(String[] s, char c) {
if (s == null)
- return null;
+ return null; // NOSONAR - Intentional.
List<String> l = new LinkedList<>();
for (String ss : s) {
if (ss == null || ss.indexOf(c) == -1)
@@ -656,18 +655,18 @@ public final class StringUtils {
*
* @param s The string to split.
* @param trim Trim strings after parsing.
- * @return The parsed map. Never <jk>null</jk>.
+ * @return The parsed map, or null if the string was null.
*/
public static Map<String,String> splitMap(String s, boolean trim) {
if (s == null)
- return null;
+ return null; // NOSONAR - Intentional.
if (isEmpty(s))
return Collections.emptyMap();
Map<String,String> m = new LinkedHashMap<>();
- int
+ final int
S1 = 1, // Found start of key, looking for equals.
S2 = 2; // Found equals, looking for delimiter (or
end).
@@ -699,7 +698,7 @@ public final class StringUtils {
x1 = i+1;
}
} else if (state == S2) {
- if (c == ',') {
+ if (c == ',') { // NOSONAR -
Intentional.
String val = s.substring(x1, i);
if (trim)
val = trim(val);
@@ -776,7 +775,7 @@ public final class StringUtils {
public static String[] splitQuoted(String s, boolean keepQuotes) {
if (s == null)
- return null;
+ return null; // NOSONAR - Intentional.
s = s.trim();
@@ -786,7 +785,7 @@ public final class StringUtils {
if (! containsAny(s, ' ', '\t', '\'', '"'))
return new String[]{s};
- int
+ final int
S1 = 1, // Looking for start of token.
S2 = 2, // Found ', looking for end '
S3 = 3, // Found ", looking for end "
@@ -819,7 +818,7 @@ public final class StringUtils {
} else if (! isInEscape) {
if (c == (state == S2 ? '\'' : '"')) {
String s2 = s.substring(mark,
keepQuotes ? i+1 : i);
- if (needsUnescape)
+ if (needsUnescape) // NOSONAR
- False positive check.
s2 = unEscapeChars(s2,
QUOTE_ESCAPE_SET);
l.add(s2);
state = S1;
@@ -828,7 +827,7 @@ public final class StringUtils {
} else {
isInEscape = false;
}
- } else if (state == S4) {
+ } else /* state == S4 */ {
if (c == ' ' || c == '\t') {
l.add(s.substring(mark, i));
state = S1;
@@ -861,7 +860,7 @@ public final class StringUtils {
* @return <jk>true</jk> if specified charsequence is <jk>null</jk> or
empty.
*/
public static boolean isEmpty(CharSequence s) {
- return s == null || s.length() == 0;
+ return s == null || s.isEmpty();
}
/**
@@ -953,13 +952,13 @@ public final class StringUtils {
char c = s.charAt(i);
if (c == '\\') {
- if (i+1 != s.length()) {
+ if (i+1 != s.length()) { // NOSONAR -
Intentional.
char c2 = s.charAt(i+1);
if (escaped.contains(c2)) {
- i++;
+ i++; // NOSONAR - Intentional.
} else if (c2 == '\\') {
sb.append('\\');
- i++;
+ i++; // NOSONAR - Intentional.
}
}
}
@@ -976,7 +975,7 @@ public final class StringUtils {
* @return The string with characters escaped, or the same string if no
escapable characters were found.
*/
public static String escapeChars(String s, AsciiSet escaped) {
- if (s == null || s.length() == 0)
+ if (s == null || s.isEmpty())
return s;
int count = 0;
@@ -1008,7 +1007,7 @@ public final class StringUtils {
StringBuilder sb = new StringBuilder();
for (char c : s.toCharArray()) {
if (c < ' ' || c > '~')
- sb.append("["+Integer.toHexString(c)+"]");
+
sb.append("[").append(Integer.toHexString(c)).append("]");
else
sb.append(c);
}
@@ -1084,7 +1083,7 @@ public final class StringUtils {
return n;
}
- private final static char[] hexArray = "0123456789ABCDEF".toCharArray();
+ private static final char[] hexArray = "0123456789ABCDEF".toCharArray();
/**
* Converts the specified byte into a 2 hexadecimal characters.
@@ -1324,13 +1323,13 @@ public final class StringUtils {
* BASE64-decodes the specified string.
*
* @param in The BASE-64 encoded string.
- * @return The decoded byte array.
+ * @return The decoded byte array, or null if the input was
<jk>null</jk>.
*/
public static byte[] base64Decode(String in) {
if (in == null)
- return null;
+ return null; // NOSONAR - Intentional.
- byte bIn[] = in.getBytes(IOUtils.UTF8);
+ byte[] bIn = in.getBytes(IOUtils.UTF8);
assertArg(bIn.length % 4 == 0, "Invalid BASE64 string length.
Must be multiple of 4.");
@@ -1387,10 +1386,9 @@ public final class StringUtils {
* @return A new random UUID.
*/
public static String random(int numchars) {
- Random r = new Random();
StringBuilder sb = new StringBuilder(numchars);
for (int i = 0; i < numchars; i++) {
- int c = r.nextInt(36) + 97;
+ int c = RANDOM.nextInt(36) + 97;
if (c > 'z')
c -= ('z'-'0'+1);
sb.append((char)c);
@@ -1436,7 +1434,7 @@ public final class StringUtils {
public static Date parseIsoDate(String date) throws
IllegalArgumentException {
if (isEmpty(date))
return null;
- return parseIsoCalendar(date).getTime();
+ return parseIsoCalendar(date).getTime(); // NOSONAR - NPE not
possible.
}
/**
@@ -1513,8 +1511,9 @@ public final class StringUtils {
if (m == null || m.isEmpty() || s.indexOf('{') == -1)
return s;
- int S1 = 1; // Not in variable, looking for {
- int S2 = 2; // Found {, Looking for }
+ final int
+ S1 = 1, // Not in variable, looking for '{'
+ S2 = 2; // Found '{', Looking for '}'
int state = S1;
boolean hasInternalVar = false;
@@ -1644,9 +1643,8 @@ public final class StringUtils {
ByteBuffer buff = ByteBuffer.allocate(hex.length()/2);
for (int i = 0; i < hex.length(); i+=2)
buff.put((byte)Integer.parseInt(hex.substring(i, i+2),
16));
- ((Buffer)buff).rewind(); // Fixes Java 11 issue.
- Charset cs = Charset.forName("UTF-8");
- return cs.decode(buff).toString();
+ buff.rewind(); // Fixes Java 11 issue.
+ return UTF_8.decode(buff).toString();
}
/**
@@ -1659,9 +1657,8 @@ public final class StringUtils {
ByteBuffer buff = ByteBuffer.allocate((hex.length()+1)/3);
for (int i = 0; i < hex.length(); i+=3)
buff.put((byte)Integer.parseInt(hex.substring(i, i+2),
16));
- ((Buffer)buff).rewind(); // Fixes Java 11 issue.
- Charset cs = Charset.forName("UTF-8");
- return cs.decode(buff).toString();
+ buff.rewind(); // Fixes Java 11 issue.
+ return UTF_8.decode(buff).toString();
}
private static final char[] HEX = "0123456789ABCDEF".toCharArray();
@@ -1708,7 +1705,7 @@ public final class StringUtils {
ByteBuffer buff = ByteBuffer.allocate(hex.length()/2);
for (int i = 0; i < hex.length(); i+=2)
buff.put((byte)Integer.parseInt(hex.substring(i, i+2),
16));
- ((Buffer)buff).rewind(); // Fixes Java 11 issue.
+ buff.rewind();
return buff.array();
}
@@ -1722,7 +1719,7 @@ public final class StringUtils {
ByteBuffer buff = ByteBuffer.allocate((hex.length()+1)/3);
for (int i = 0; i < hex.length(); i+=3)
buff.put((byte)Integer.parseInt(hex.substring(i, i+2),
16));
- ((Buffer)buff).rewind(); // Fixes Java 11 issue.
+ buff.rewind();
return buff.array();
}
@@ -1748,7 +1745,7 @@ public final class StringUtils {
*/
public static String trimStart(String s) {
if (s != null)
- while (s.length() > 0 &&
Character.isWhitespace(s.charAt(0)))
+ while (isNotEmpty(s) &&
Character.isWhitespace(s.charAt(0)))
s = s.substring(1);
return s;
}
@@ -1761,7 +1758,7 @@ public final class StringUtils {
*/
public static String trimEnd(String s) {
if (s != null)
- while (s.length() > 0 &&
Character.isWhitespace(s.charAt(s.length()-1)))
+ while (!s.isEmpty() &&
Character.isWhitespace(s.charAt(s.length()-1)))
s = s.substring(0, s.length()-1);
return s;
}
@@ -1779,7 +1776,7 @@ public final class StringUtils {
*/
public static boolean isOneOf(String s, String...values) {
for (String value : values)
- if (StringUtils.eq(s, value))
+ if (eq(s, value))
return true;
return false;
}
@@ -1797,7 +1794,7 @@ public final class StringUtils {
return s;
while (endsWith(s, '/'))
s = s.substring(0, s.length()-1);
- while (s.length() > 0 && s.charAt(0) == '/')
+ while (isNotEmpty(s) && s.charAt(0) == '/') // NOSONAR - NPE
not possible here.
s = s.substring(1);
return s;
}
@@ -1811,9 +1808,9 @@ public final class StringUtils {
public static String trimSlashesAndSpaces(String s) {
if (s == null)
return null;
- while (s.length() > 0 && (s.charAt(s.length()-1) == '/' ||
Character.isWhitespace(s.charAt(s.length()-1))))
+ while (isNotEmpty(s) && (s.charAt(s.length()-1) == '/' ||
Character.isWhitespace(s.charAt(s.length()-1))))
s = s.substring(0, s.length()-1);
- while (s.length() > 0 && (s.charAt(0) == '/' ||
Character.isWhitespace(s.charAt(0))))
+ while (isNotEmpty(s) && (s.charAt(0) == '/' ||
Character.isWhitespace(s.charAt(0))))
s = s.substring(1);
return s;
}
@@ -1841,7 +1838,7 @@ public final class StringUtils {
public static String trimLeadingSlashes(String s) {
if (s == null)
return null;
- while (s.length() > 0 && s.charAt(0) == '/')
+ while (isNotEmpty(s) && s.charAt(0) == '/')
s = s.substring(1);
return s;
}
@@ -1874,25 +1871,25 @@ public final class StringUtils {
char c = s.charAt(i);
if (URL_ENCODE_PATHINFO_VALIDCHARS.contains(c)) {
sb.append(c);
- i++;
+ i++; // NOSONAR - Intentional.
} else {
if (c == ' ') {
sb.append('+');
- i++;
+ i++; // NOSONAR - Intentional.
} else {
do {
caw.write(c);
if (c >= 0xD800 && c <= 0xDBFF)
{
- if ( (i+1) <
s.length()) {
+ if ((i+1) < s.length())
{ // NOSONAR - Intentional.
int d =
s.charAt(i+1);
if (d >= 0xDC00
&& d <= 0xDFFF) {
caw.write(d);
- i++;
+ i++;
// NOSONAR - Intentional.
}
}
}
- i++;
- } while (i < s.length() &&
!URL_ENCODE_PATHINFO_VALIDCHARS.contains((c = s.charAt(i))));
+ i++; // NOSONAR - Intentional.
+ } while (i < s.length() &&
!URL_ENCODE_PATHINFO_VALIDCHARS.contains((c = s.charAt(i)))); // NOSONAR -
Intentional.
caw.flush();
String s2 = new
String(caw.toCharArray());
@@ -2047,18 +2044,19 @@ public final class StringUtils {
* @param s The string to test.
* @return <jk>true</jk> if it's an absolute path.
*/
- public static boolean isAbsoluteUri(String s) {
+ public static boolean isAbsoluteUri(String s) { // NOSONAR - False
positive.
if (isEmpty(s))
return false;
// Use a state machine for maximum performance.
- int S1 = 1; // Looking for http
- int S2 = 2; // Found http, looking for :
- int S3 = 3; // Found :, looking for /
- int S4 = 4; // Found /, looking for /
- int S5 = 5; // Found /, looking for x
+ final int
+ S1 = 1, // Looking for http
+ S2 = 2, // Found http, looking for :
+ S3 = 3, // Found :, looking for /
+ S4 = 4, // Found /, looking for /
+ S5 = 5; // Found /, looking for x
int state = S1;
for (int i = 0; i < s.length(); i++) {
@@ -2073,7 +2071,7 @@ public final class StringUtils {
state = S3;
else if (c < 'a' || c > 'z')
return false;
- } else if (state == S3) {
+ } else if (state == S3) { // NOSONAR - False positive.
if (c == '/')
state = S4;
else
@@ -2102,18 +2100,18 @@ public final class StringUtils {
* @param s The string to test.
* @return <jk>true</jk> if it's an absolute path.
*/
- public static boolean isUri(String s) {
+ public static boolean isUri(String s) { // NOSONAR - False positive.
if (isEmpty(s))
return false;
// Use a state machine for maximum performance.
- int S1 = 1; // Looking for protocol char 1
- int S2 = 2; // Found protocol char 1, looking for protocol
char 2
- int S3 = 3; // Found protocol char 2, looking for :
- int S4 = 4; // Found :, looking for /
-
+ final int
+ S1 = 1, // Looking for protocol char 1
+ S2 = 2, // Found protocol char 1, looking for protocol
char 2
+ S3 = 3, // Found protocol char 2, looking for :
+ S4 = 4; // Found :, looking for /
int state = S1;
for (int i = 0; i < s.length(); i++) {
@@ -2128,15 +2126,13 @@ public final class StringUtils {
state = S3;
else
return false;
- } else if (state == S3) {
+ } else if (state == S3) { // NOSONAR - False positive.
if (c == ':')
state = S4;
else if (c < 'a' || c > 'z')
return false;
} else if (state == S4) {
- if (c == '/')
- return true;
- return false;
+ return c == '/';
}
}
return false;
@@ -2148,16 +2144,17 @@ public final class StringUtils {
* @param s The URI string.
* @return Just the authority portion of the URI.
*/
- public static String getAuthorityUri(String s) {
+ public static String getAuthorityUri(String s) { // NOSONAR - False
positive.
// Use a state machine for maximum performance.
- int S1 = 1; // Looking for http
- int S2 = 2; // Found http, looking for :
- int S3 = 3; // Found :, looking for /
- int S4 = 4; // Found /, looking for /
- int S5 = 5; // Found /, looking for x
- int S6 = 6; // Found x, looking for /
+ final int
+ S1 = 1, // Looking for http
+ S2 = 2, // Found http, looking for :
+ S3 = 3, // Found :, looking for /
+ S4 = 4, // Found /, looking for /
+ S5 = 5, // Found /, looking for x
+ S6 = 6; // Found x, looking for /
int state = S1;
for (int i = 0; i < s.length(); i++) {
@@ -2172,7 +2169,7 @@ public final class StringUtils {
state = S3;
else if (c < 'a' || c > 'z')
return s;
- } else if (state == S3) {
+ } else if (state == S3) { // NOSONAR - False positive.
if (c == '/')
state = S4;
else
@@ -2188,7 +2185,7 @@ public final class StringUtils {
else
return s;
} else if (state == S6) {
- if (c == '/')
+ if (c == '/') // NOSONAR - Intentional.
return s.substring(0, i);
}
}
@@ -2261,8 +2258,7 @@ public final class StringUtils {
if (c % 2 != 0)
throw new AssertionError("Dangling single quote found
in pattern: " + pattern);
- String msg = MessageFormat.format(pattern, args2);
- return msg;
+ return MessageFormat.format(pattern, args2);
}
private static String convertToReadable(Object o) {
@@ -2309,11 +2305,11 @@ public final class StringUtils {
int m = multiplier(s);
if (m == 1)
return Integer.decode(s);
- return Integer.decode(s.substring(0, s.length()-1).trim()) * m;
+ return Integer.decode(s.substring(0, s.length()-1).trim()) * m;
// NOSONAR - NPE not possible here.
}
private static int multiplier(String s) {
- char c = s.isEmpty() ? null : s.charAt(s.length()-1);
+ char c = isEmpty(s) ? null : s.charAt(s.length()-1); //
NOSONAR - NPE not possible.
if (c == 'G') return 1024*1024*1024;
if (c == 'M') return 1024*1024;
if (c == 'K') return 1024;
@@ -2349,21 +2345,21 @@ public final class StringUtils {
long m = multiplier2(s);
if (m == 1)
return Long.decode(s);
- return Long.decode(s.substring(0, s.length()-1).trim()) * m;
+ return Long.decode(s.substring(0, s.length()-1).trim()) * m;
// NOSONAR - NPE not possible here.
}
private static long multiplier2(String s) {
- char c = s.isEmpty() ? null : s.charAt(s.length()-1);
- if (c == 'P') return 1024*1024*1024*1024*1024;
- if (c == 'T') return 1024*1024*1024*1024;
- if (c == 'G') return 1024*1024*1024;
- if (c == 'M') return 1024*1024;
- if (c == 'K') return 1024;
- if (c == 'p') return 1000*1000*1000*1000*1000;
- if (c == 't') return 1000*1000*1000*1000;
- if (c == 'g') return 1000*1000*1000;
- if (c == 'm') return 1000*1000;
- if (c == 'k') return 1000;
+ char c = isEmpty(s) ? null : s.charAt(s.length()-1); //
NOSONAR - NPE not possible.
+ if (c == 'P') return 1024*1024*1024*1024*1024l;
+ if (c == 'T') return 1024*1024*1024*1024l;
+ if (c == 'G') return 1024*1024*1024l;
+ if (c == 'M') return 1024*1024l;
+ if (c == 'K') return 1024l;
+ if (c == 'p') return 1000*1000*1000*1000*1000l;
+ if (c == 't') return 1000*1000*1000*1000l;
+ if (c == 'g') return 1000*1000*1000l;
+ if (c == 'm') return 1000*1000l;
+ if (c == 'k') return 1000l;
return 1;
}
@@ -2375,7 +2371,7 @@ public final class StringUtils {
* @return <jk>true</jk> if the value contains the specified substring.
*/
public static boolean contains(String value, CharSequence substring) {
- return value == null ? false : value.contains(substring);
+ return value != null && value.contains(substring);
}
/**
@@ -2396,9 +2392,7 @@ public final class StringUtils {
if (i == -1)
return false;
s = s.substring(i+1);
- if (firstRealCharacter(s) != -1)
- return false;
- return true;
+ return firstRealCharacter(s) == -1;
}
return false;
}
@@ -2419,9 +2413,7 @@ public final class StringUtils {
char c1 = firstNonWhitespaceChar(s), c2 =
lastNonWhitespaceChar(s);
if (c1 == '{' && c2 == '}' || c1 == '[' && c2 == ']' || c1 ==
'\'' && c2 == '\'')
return true;
- if (isOneOf(s, "true","false","null") || isNumeric(s))
- return true;
- return false;
+ return (isOneOf(s, "true","false","null") || isNumeric(s));
}
/**
@@ -2442,9 +2434,7 @@ public final class StringUtils {
if (i == -1)
return false;
s = s.substring(i+1);
- if (firstRealCharacter(s) != -1)
- return false;
- return true;
+ return firstRealCharacter(s) == -1;
}
return false;
}
@@ -2472,7 +2462,7 @@ public final class StringUtils {
if (c == '*') {
while (c != -1)
if ((c = r.read()) == '*')
- if ((c = r.read()) == '/')
+ if ((c = r.read()) == '/') // NOSONAR
- Intentional.
return;
// "//" style comments
} else if (c == '/') {
@@ -2518,7 +2508,7 @@ public final class StringUtils {
end = lines.length;
StringBuilder sb = new StringBuilder();
for (String l : Arrays.asList(lines).subList(start-1, end))
- sb.append(String.format("%0"+digits+"d",
start++)).append(": ").append(l).append("\n");
+ sb.append(String.format("%0"+digits+"d",
start++)).append(": ").append(l).append("\n"); // NOSONAR - Intentional.
return sb.toString();
}
@@ -2692,11 +2682,11 @@ public final class StringUtils {
* Splits the method arguments in the signature of a method.
*
* @param s The arguments to split.
- * @return The split arguments.
+ * @return The split arguments, or null if the input string is null.
*/
public static String[] splitMethodArgs(String s) {
if (s == null)
- return null;
+ return null; // NOSONAR - Intentional.
if (isEmpty(s))
return new String[0];
if (s.indexOf(',') == -1)
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/SystemUtils.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/SystemUtils.java
index 69613ab61..83ca73d4e 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/SystemUtils.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/SystemUtils.java
@@ -21,13 +21,15 @@ import java.util.function.*;
*/
public class SystemUtils {
+ private SystemUtils() {}
+
static final List<Supplier<String>> SHUTDOWN_MESSAGES = new
CopyOnWriteArrayList<>();
static {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
if (Boolean.getBoolean("SystemUtils.verbose"))
- SHUTDOWN_MESSAGES.forEach(x ->
System.out.println(x.get()));
+ SHUTDOWN_MESSAGES.forEach(x ->
System.out.println(x.get())); // NOSONAR - System.out.println is acceptable
here for shutdown messages.
}
});
}
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/ThrowableUtils.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/ThrowableUtils.java
index bc2a0b60d..515cc9d02 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/ThrowableUtils.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/ThrowableUtils.java
@@ -85,16 +85,15 @@ public class ThrowableUtils {
/**
* Interface used with {@link #safeSupplier(SupplierWithThrowable)}.
*/
- @SuppressWarnings("javadoc")
@FunctionalInterface
public interface SupplierWithThrowable<T> {
- /**
- * Gets a result.
- *
- * @return a result
- * @throws Throwable if supplier threw an exception.
- */
+ /**
+ * Gets a result.
+ *
+ * @return a result
+ * @throws Throwable if supplier threw an exception.
+ */
T get() throws Throwable;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/AnnotationApplier.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/AnnotationApplier.java
index 2f1ca17c2..d566e3c29 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/AnnotationApplier.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/AnnotationApplier.java
@@ -170,7 +170,7 @@ public abstract class AnnotationApplier<A extends
Annotation, B> {
* @return The array wrapped in an {@link Optional}.
*/
protected Optional<String[]> strings(String[] in) {
- return optional(in.length == 0 ? null : Arrays.stream(in).map(x
-> vr.resolve(x)).filter(StringUtils::isNotEmpty).toArray(String[]::new));
+ return optional(in.length == 0 ? null :
Arrays.stream(in).map(vr::resolve).filter(StringUtils::isNotEmpty).toArray(String[]::new));
}
/**
@@ -180,7 +180,7 @@ public abstract class AnnotationApplier<A extends
Annotation, B> {
* @return An array with resolved strings.
*/
protected Stream<String> stream(String[] in) {
- return Arrays.stream(in).map(x ->
vr.resolve(x)).filter(StringUtils::isNotEmpty);
+ return
Arrays.stream(in).map(vr::resolve).filter(StringUtils::isNotEmpty);
}
/**
@@ -273,6 +273,6 @@ public abstract class AnnotationApplier<A extends
Annotation, B> {
}
@Override /* ConfigApply */
- public void apply(AnnotationInfo<Annotation> ai, Object b) {}
+ public void apply(AnnotationInfo<Annotation> ai, Object b) { /*
no-op */ }
}
}
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 f62bbc306..28a4257be 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
@@ -665,7 +665,7 @@ public class BeanMeta<T> {
List<Name> ln = list();
ctx.forEachAnnotation(Beanp.class, m.inner(), x
-> true, x -> lp.add(x));
ctx.forEachAnnotation(Name.class, m.inner(), x
-> true, x -> ln.add(x));
- if (! (m.isVisible(v) || lp.size() > 0 ||
ln.size() > 0))
+ if (! (m.isVisible(v) || isNotEmpty(lp) ||
isNotEmpty(ln)))
continue;
String n = m.getSimpleName();
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
index 419442531..971e8dd0a 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
@@ -183,7 +183,7 @@ public final class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
if (innerField != null) {
List<Beanp> lp = list();
bc.forEachAnnotation(Beanp.class, innerField, x
-> true, x -> lp.add(x));
- if (field != null || lp.size() > 0) {
+ if (field != null || isNotEmpty(lp)) {
// Only use field type if it's a bean
property or has @Beanp annotation.
// Otherwise, we want to infer the type
from the getter or setter.
rawTypeMeta =
bc.resolveClassMeta(last(lp), innerField.getGenericType(), typeVarImpls);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
index 772f3a4fe..4ebb01381 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
@@ -579,7 +579,7 @@ public class BeanSession extends ContextSession {
if (tc == Short.TYPE)
return
(T)Short.valueOf(l.shortValue());
if (tc == Long.TYPE)
- return
(T)Long.valueOf(l.longValue());
+ return (T)l;
} else {
if (tc == Integer.TYPE)
return
(T)Integer.valueOf(s);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvSerializerSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvSerializerSession.java
index b25efffd7..e43d3c20c 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvSerializerSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvSerializerSession.java
@@ -226,7 +226,7 @@ public final class CsvSerializerSession extends
WriterSerializerSession {
}
// TODO - Doesn't support DynaBeans.
- if (l.size() > 0) {
+ if (isNotEmpty(l)) {
ClassMeta<?> entryType =
getClassMetaForObject(l.iterator().next());
if (entryType.isBean()) {
BeanMeta<?> bm =
entryType.getBeanMeta();
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserSession.java
index fc9e961d6..1897d8c82 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserSession.java
@@ -740,7 +740,7 @@ public final class HtmlParserSession extends
XmlParserSession {
if (et == START_ELEMENT) {
String n2 = r.getLocalName();
if (n.equals(n2))
- depth++;
+ depth++;
} else if (et == END_ELEMENT) {
String n2 = r.getLocalName();
if (n.equals(n2))
@@ -811,7 +811,7 @@ public final class HtmlParserSession extends
XmlParserSession {
et = r.next();
if (et == CHARACTERS) {
String s = r.getText();
- if (s.length() > 0) {
+ if (isNotEmpty(s)) {
char c =
r.getText().charAt(0);
if (c == '\u2003')
c = '\t';
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java
index e46e4fd33..bd6e3f1af 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java
@@ -567,10 +567,11 @@ public final class JsonParserSession extends
ReaderParserSession {
private <E> Collection<E> parseIntoCollection2(ParserReader r,
Collection<E> l,
ClassMeta<?> type, BeanPropertyMeta pMeta) throws
IOException, ParseException, ExecutableException {
- int S0=0; // Looking for outermost [
- int S1=1; // Looking for starting [ or { or " or ' or LITERAL
or ]
- int S2=2; // Looking for , or ]
- int S3=3; // Looking for starting [ or { or " or ' or LITERAL
+ final int
+ S0=0, // Looking for outermost [
+ S1=1, // Looking for starting [ or { or " or ' or
LITERAL or ]
+ S2=2, // Looking for , or ]
+ S3=3; // Looking for starting [ or { or " or ' or
LITERAL
int argIndex = 0;
@@ -796,7 +797,7 @@ public final class JsonParserSession extends
ReaderParserSession {
if (r.peek() == '+') {
if (isStrict())
throw new ParseException(this, "String
concatenation detected.");
- r.read(); // Skip past '+'
+ r.read(); // Skip past '+', NOSONAR - Intentional.
skipCommentsAndSpace(r);
s += parseString(r);
}
@@ -846,10 +847,11 @@ public final class JsonParserSession extends
ReaderParserSession {
*/
private void skipWrapperAttrStart(ParserReader r, String wrapperAttr)
throws IOException, ParseException {
- int S0=0; // Looking for outer {
- int S1=1; // Looking for attrName start.
- int S3=3; // Found attrName end, looking for :.
- int S4=4; // Found :, looking for valStart: { [ " ' LITERAL.
+ final int
+ S0=0, // Looking for outer '{'
+ S1=1, // Looking for attrName start.
+ S3=3, // Found attrName end, looking for :.
+ S4=4; // Found :, looking for valStart: { [ " ' LITERAL.
int state = S0;
String currAttr = null;
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 2e5dbe6d3..957bae334 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
@@ -103,7 +103,7 @@ public class SchemaUtils {
public static String joinnl(String[]...s) {
for (String[] ss : s) {
if (ss.length != 0)
- return StringUtils.joinnl(ss).trim();
+ return StringUtils.joinnl(ss).trim();
}
return "";
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/NumberMatcherFactory.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/NumberMatcherFactory.java
index ecb32976f..fad3f6adb 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/NumberMatcherFactory.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/NumberMatcherFactory.java
@@ -257,7 +257,7 @@ public class NumberMatcherFactory extends MatcherFactory {
if (numberRanges.length == 0)
return true;
for (NumberRange numberRange : numberRanges)
- if (numberRange.matches(n))
+ if (numberRange.matches(n))
return true;
return false;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectPaginator.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectPaginator.java
index 93ce6b581..d60f7a598 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectPaginator.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectPaginator.java
@@ -101,7 +101,7 @@ public final class ObjectPaginator implements
ObjectTool<PageArgs> {
int end = (limit+pos >= size) ? size : limit + pos;
pos = Math.min(pos, size);
ClassMeta<?> et = type.getElementType();
- if (! et.isPrimitive())
+ if (! et.isPrimitive())
return copyOfRange((Object[])input, pos, end);
if (et.is(boolean.class))
return copyOfRange((boolean[])input, pos, end);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectRest.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectRest.java
index 4b8d65e9f..856d0ca52 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectRest.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectRest.java
@@ -13,6 +13,7 @@
package org.apache.juneau.objecttools;
import static java.net.HttpURLConnection.*;
+import static org.apache.juneau.common.internal.StringUtils.*;
import java.io.*;
import java.lang.reflect.*;
@@ -746,7 +747,7 @@ public final class ObjectRest {
url = "";
// Strip off leading slash if present.
- if (url.length() > 0 && url.charAt(0) == '/')
+ if (isNotEmpty(url) && url.charAt(0) == '/')
url = url.substring(1);
return url;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ExecutableInfo.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ExecutableInfo.java
index 46d6b538c..732f263ea 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ExecutableInfo.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ExecutableInfo.java
@@ -597,7 +597,7 @@ public abstract class ExecutableInfo {
for (ClassInfo element : pt) {
boolean matched = false;
for (Class<?> arg : args)
- if (element.isParentOfFuzzyPrimitives(arg))
+ if (element.isParentOfFuzzyPrimitives(arg))
matched = true;
if (! matched)
return false;
@@ -618,7 +618,7 @@ public abstract class ExecutableInfo {
for (ClassInfo element : pt) {
boolean matched = false;
for (ClassInfo arg : args)
- if (element.isParentOfFuzzyPrimitives(arg.inner()))
+ if
(element.isParentOfFuzzyPrimitives(arg.inner()))
matched = true;
if (! matched)
return false;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java
index 74b5633a0..7b784a3bf 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java
@@ -260,7 +260,7 @@ public class UonParserSession extends ReaderParserSession
implements HttpPartPar
public <T> T parse(HttpPartType partType, HttpPartSchema schema, String
in, ClassMeta<T> toType) throws ParseException, SchemaValidationException {
if (in == null)
return null;
- if (toType.isString() && in.length() > 0) {
+ if (toType.isString() && isNotEmpty(in)) {
// Shortcut - If we're returning a string and the value
doesn't start with "'" or is "null", then
// just return the string since it's a plain value.
// This allows us to bypass the creation of a
UonParserSession object.
@@ -433,7 +433,7 @@ public class UonParserSession extends ReaderParserSession
implements HttpPartPar
throw new ParseException(this, "Class ''{0}''
could not be instantiated. Reason: ''{1}''",
sType.getInnerClass().getName(),
sType.getNotABeanReason());
} else if (c == 'n') {
- r.read();
+ r.read(); // NOSONAR - Intentional.
parseNull(r);
} else {
throw new ParseException(this, "Class ''{0}'' could not
be instantiated. Reason: ''{1}''",
@@ -557,7 +557,7 @@ public class UonParserSession extends ReaderParserSession
implements HttpPartPar
else
throw new ParseException(this, "Could not find
'(' marking beginning of collection.");
} else {
- r.read();
+ r.read(); // NOSONAR - Intentional, we're skipping the
'@' character.
}
if (isInParens) {
@@ -573,7 +573,7 @@ public class UonParserSession extends ReaderParserSession
implements HttpPartPar
if (state == S2) {
l.add((E)parseAnything(type.isArgs() ? type.getArg(argIndex++) :
type.getElementType(),
r.unread(), l, false, pMeta));
- r.read();
+ r.read(); // NOSONAR -
Intentional, we're skipping the ')' character.
}
return l;
} else if (Character.isWhitespace(c)) {
@@ -896,7 +896,7 @@ public class UonParserSession extends ReaderParserSession
implements HttpPartPar
*/
private String parsePString(UonReader r) throws IOException,
ParseException {
- r.read(); // Skip first quote.
+ r.read(); // Skip first quote, NOSONAR - Intentional.
r.mark();
int c = 0;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParserSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParserSession.java
index b7ae72b70..a2f14798f 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParserSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParserSession.java
@@ -238,7 +238,7 @@ public class UrlEncodingParserSession extends
UonParserSession {
protected <K,V> Map<K,V> doParseIntoMap(ParserPipe pipe, Map<K,V> m,
Type keyType, Type valueType) throws Exception {
try (UonReader r = getUonReader(pipe, true)) {
if (r.peekSkipWs() == '?')
- r.read();
+ r.read(); // NOSONAR - skip leading '?'.
m = parseIntoMap2(r, m, getClassMeta(Map.class,
keyType, valueType), null);
return m;
}
@@ -263,7 +263,7 @@ public class UrlEncodingParserSession extends
UonParserSession {
int c = r.peekSkipWs();
if (c == '?')
- r.read();
+ r.read(); // NOSONAR - skip leading '?'.
Object o;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/Consumer2.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/Consumer2.java
index 3403614df..5696a366b 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/Consumer2.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/Consumer2.java
@@ -38,7 +38,7 @@ public interface Consumer2<A,B> {
* @param after The operation to perform after this operation.
* @return A composed {@link Consumer} that performs in sequence this
operation followed by the after operation.
*/
- default <V> Consumer2<A,B> andThen(Consumer2<? super A,? super B>
after) {
+ default <V> Consumer2<A,B> andThen(Consumer2<? super A,? super B>
after) { // NOSONAR - false positive on generics
return (A a, B b) -> {
apply(a, b);
after.apply(a, b);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/Consumer3.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/Consumer3.java
index 140b7d104..fafdac520 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/Consumer3.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/Consumer3.java
@@ -40,7 +40,7 @@ public interface Consumer3<A,B,C> {
* @param after The operation to perform after this operation.
* @return A composed {@link Consumer} that performs in sequence this
operation followed by the after operation.
*/
- default <V> Consumer3<A,B,C> andThen(Consumer3<? super A,? super B,?
super C> after) {
+ default <V> Consumer3<A,B,C> andThen(Consumer3<? super A,? super B,?
super C> after) { // NOSONAR - false positive on generics
return (A a, B b, C c) -> {
apply(a, b, c);
after.apply(a, b, c);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/Consumer4.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/Consumer4.java
index bcb283503..514fd710a 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/Consumer4.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/Consumer4.java
@@ -42,7 +42,7 @@ public interface Consumer4<A,B,C,D> {
* @param after The operation to perform after this operation.
* @return A composed {@link Consumer} that performs in sequence this
operation followed by the after operation.
*/
- default <V> Consumer4<A,B,C,D> andThen(Consumer4<? super A,? super B,?
super C, ? super D> after) {
+ default <V> Consumer4<A,B,C,D> andThen(Consumer4<? super A,? super B,?
super C, ? super D> after) { // NOSONAR - false positive on generics
return (A a, B b, C c, D d) -> {
apply(a, b, c, d);
after.apply(a, b, c, d);
diff --git a/juneau-doc/src/main/javadoc/overview.html
b/juneau-doc/src/main/javadoc/overview.html
index 9c8f34910..589dcbedd 100644
--- a/juneau-doc/src/main/javadoc/overview.html
+++ b/juneau-doc/src/main/javadoc/overview.html
@@ -587,7 +587,7 @@
<xt></dependency></xt>
</p>
<p>
- If you would like to work with the bleeding-edge code, you can
access the <c><juneauVersionNext>9.1.0</juneauVersionNext>-SNAPSHOT</c>
+ If you would like to work with the bleeding-edge code, you can
access the <c><juneauVersionNext>9.0.2</juneauVersionNext>-SNAPSHOT</c>
version through the following repository:
</p>
<p class='bxml'>
@@ -35442,20 +35442,6 @@
</div>
</div><!-- END: 9.0.0 -->
-<!--
====================================================================================================
-->
-
-<h3 class='topic' onclick='toggle(this)'><a href='#9.1.0' id='9.1.0'>9.1.0
(May 12, 2025)</a></h3>
-<div class='topic'><!-- START: 9.0.0 -->
-<div class='topic'>
- <p>
- Juneau 9.1.0 is a minor release with bug fixes and dependency
upgrades only.
- </p>
- <p>
- This version now requires Java 17.
- </p>
-</div>
-</div><!-- END: 9.1.0 -->
-
</div>
<script>
// Overrides the javadoc javascript behavior that forces the page to
show the search element.