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
commit ed33c360d9866cf3fd9ce0af61c4bc7b67c57bd7 Author: James Bognar <[email protected]> AuthorDate: Fri Jul 24 16:52:58 2026 -0400 Resolve SonarLint findings across core, rest, and test-support modules Fixes or suppresses a batch of SonarLint issues with no behavior change except the noted ones: S8786 ReDoS regex rewrite in Config, S2259 null-guards in FileStore, S1452 CRTP-bounded return-type suppressions in jsonschema, S5778/S5976 test refactors, S110 suppressions on the HTTP-response hierarchy, S2886/S2160 dispositions in rest-server, S1135 stale-TODO rewording, and assorted S125/S112/S1659/S6201/S8924/S3415 cleanups. Co-authored-by: Cursor <[email protected]> --- .../apache/juneau/bean/jsonschema/JsonSchema.java | 39 ++++++++++++++++++++++ .../bean/jsonschema/JsonSchemaBeanGenerator.java | 12 +++++++ .../juneau/bean/jsonschema/JsonSchemaMap.java | 3 ++ .../bean/jsonschema/JsonSchemaValidator.java | 3 ++ .../juneau/bean/openapi3/SchemaInfo_Test.java | 3 +- .../juneau/commons/bean/BeanMetaInitializer.java | 6 ++-- .../apache/juneau/commons/logging/LogRecord.java | 2 -- .../juneau/commons/logging/LogRecord_Test.java | 6 ---- .../main/java/org/apache/juneau/config/Config.java | 2 +- .../org/apache/juneau/config/store/FileStore.java | 19 +++++++++-- .../juneau/marshall/hjson/HjsonParserSession.java | 2 +- .../juneau/marshall/hocon/HoconParserSession.java | 2 +- .../juneau/ParentPropertyContainer_Test.java | 2 +- .../markdown/MarkdownParserSession_Test.java | 37 +++++++++----------- .../juneau/marshall/toml/TomlTokenizer_Test.java | 31 ++++++----------- .../main/java/org/apache/juneau/BeanTester.java | 3 +- .../apache/juneau/a/rttests/RoundTrip_Tester.java | 8 +++-- .../juneau/marshall/testutils/pojos/TestURI.java | 21 +++++++++--- .../main/java/org/apache/juneau/XmlTestUtils.java | 6 ++++ .../saml/SamlAssertionValidator_Builder_Test.java | 3 +- .../apache/juneau/http/response/BadGateway.java | 3 ++ .../apache/juneau/http/response/BadRequest.java | 3 ++ .../org/apache/juneau/http/response/Conflict.java | 3 ++ .../juneau/http/response/ExpectationFailed.java | 3 ++ .../juneau/http/response/FailedDependency.java | 3 ++ .../org/apache/juneau/http/response/Forbidden.java | 3 ++ .../juneau/http/response/GatewayTimeout.java | 3 ++ .../java/org/apache/juneau/http/response/Gone.java | 3 ++ .../http/response/HttpVersionNotSupported.java | 3 ++ .../juneau/http/response/InsufficientStorage.java | 3 ++ .../juneau/http/response/InternalServerError.java | 3 ++ .../juneau/http/response/LengthRequired.java | 3 ++ .../org/apache/juneau/http/response/Locked.java | 3 ++ .../apache/juneau/http/response/LoopDetected.java | 3 ++ .../juneau/http/response/MethodNotAllowed.java | 3 ++ .../juneau/http/response/MisdirectedRequest.java | 3 ++ .../response/NetworkAuthenticationRequired.java | 3 ++ .../apache/juneau/http/response/NotAcceptable.java | 3 ++ .../apache/juneau/http/response/NotExtended.java | 3 ++ .../org/apache/juneau/http/response/NotFound.java | 3 ++ .../juneau/http/response/NotImplemented.java | 3 ++ .../juneau/http/response/PayloadTooLarge.java | 3 ++ .../juneau/http/response/PreconditionFailed.java | 3 ++ .../juneau/http/response/PreconditionRequired.java | 3 ++ .../juneau/http/response/RangeNotSatisfiable.java | 3 ++ .../http/response/RequestHeaderFieldsTooLarge.java | 3 ++ .../juneau/http/response/ServiceUnavailable.java | 3 ++ .../juneau/http/response/TooManyRequests.java | 3 ++ .../apache/juneau/http/response/Unauthorized.java | 3 ++ .../http/response/UnavailableForLegalReasons.java | 3 ++ .../juneau/http/response/UnprocessableEntity.java | 3 ++ .../juneau/http/response/UnsupportedMediaType.java | 3 ++ .../juneau/http/response/UpgradeRequired.java | 3 ++ .../apache/juneau/http/response/UriTooLong.java | 3 ++ .../http/response/VariantAlsoNegotiates.java | 3 ++ .../juneau/rest/server/servlet/RestServlet.java | 6 ++++ .../server/validation/ValidationException.java | 3 +- 57 files changed, 255 insertions(+), 69 deletions(-) diff --git a/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchema.java b/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchema.java index 39f8ad5475..0ea386f038 100644 --- a/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchema.java +++ b/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchema.java @@ -397,6 +397,9 @@ public class JsonSchema<SELF extends JsonSchema<SELF>> { * @param type The type to generate a schema for. Must not be <jk>null</jk>, or an {@link IllegalArgumentException} is thrown. * @return The generated schema bean, or <jk>null</jk> if a schema could not be generated for the type. */ + @SuppressWarnings({ + "java:S1452" // Self-bounded (CRTP) generic: the generated schema's concrete SELF subtype is not known here, so JsonSchema<?> is the only sound return type. + }) public static JsonSchema<?> of(Type type) { return JsonSchemaBeanGenerator.DEFAULT.generate(type); } @@ -407,6 +410,9 @@ public class JsonSchema<SELF extends JsonSchema<SELF>> { * @param type The class to generate a schema for. Must not be <jk>null</jk>, or an {@link IllegalArgumentException} is thrown. * @return The generated schema bean, or <jk>null</jk> if a schema could not be generated for the class. */ + @SuppressWarnings({ + "java:S1452" // Self-bounded (CRTP) generic: the generated schema's concrete SELF subtype is not known here, so JsonSchema<?> is the only sound return type. + }) public static JsonSchema<?> of(Class<?> type) { return JsonSchemaBeanGenerator.DEFAULT.generate(type); } @@ -882,6 +888,9 @@ public class JsonSchema<SELF extends JsonSchema<SELF>> { * @return The currently set value, or <jk>null</jk> if the property is not set, or is set as a {@link Boolean}. */ @BeanIgnore + @SuppressWarnings({ + "java:S1452" // Self-bounded (CRTP) generic: additionalPropertiesSchema is declared JsonSchema<?> since callers may attach any concrete SELF subtype. + }) public JsonSchema<?> getAdditionalPropertiesAsSchema() { return additionalPropertiesSchema; } /** @@ -1028,6 +1037,9 @@ public class JsonSchema<SELF extends JsonSchema<SELF>> { * @return The value of the <property>else</property> property on this bean, or <jk>null</jk> if it is not set. */ @BeanProp("else") + @SuppressWarnings({ + "java:S1452" // Self-bounded (CRTP) generic: else_ is declared JsonSchema<?> since callers may attach any concrete SELF subtype. + }) public JsonSchema<?> getElse() { return else_; } /** @@ -1113,6 +1125,9 @@ public class JsonSchema<SELF extends JsonSchema<SELF>> { * @return The value of the <property>if</property> property on this bean, or <jk>null</jk> if it is not set. */ @BeanProp("if") + @SuppressWarnings({ + "java:S1452" // Self-bounded (CRTP) generic: if_ is declared JsonSchema<?> since callers may attach any concrete SELF subtype. + }) public JsonSchema<?> getIf() { return if_; } /** @@ -1138,6 +1153,9 @@ public class JsonSchema<SELF extends JsonSchema<SELF>> { * @return The currently set value, or <jk>null</jk> if the property is not set, or is set as a {@link JsonSchemaArray}. */ @BeanIgnore + @SuppressWarnings({ + "java:S1452" // Self-bounded (CRTP) generic: itemsSchema is declared JsonSchema<?> since callers may attach any concrete SELF subtype. + }) public JsonSchema<?> getItemsAsSchema() { return itemsSchema; } /** @@ -1232,6 +1250,9 @@ public class JsonSchema<SELF extends JsonSchema<SELF>> { * * @return The value of the <property>not</property> property on this bean, or <jk>null</jk> if it is not set. */ + @SuppressWarnings({ + "java:S1452" // Self-bounded (CRTP) generic: 'not' is declared JsonSchema<?> since callers may attach any concrete SELF subtype. + }) public JsonSchema<?> getNot() { return not; } /** @@ -1283,6 +1304,9 @@ public class JsonSchema<SELF extends JsonSchema<SELF>> { * @param name The property name. Can be <jk>null</jk> (no property has a <jk>null</jk> name, so <jk>null</jk> is returned). * @return The property with the specified name, or <jk>null</jk> if no property is specified. */ + @SuppressWarnings({ + "java:S1452" // Self-bounded (CRTP) generic: 'properties' map values are declared JsonSchema<?> since callers may attach any concrete SELF subtype. + }) public JsonSchema<?> getProperty(String name) { return getProperty(name, false); } @@ -1301,6 +1325,9 @@ public class JsonSchema<SELF extends JsonSchema<SELF>> { * @param resolve If <jk>true</jk>, calls {@link #resolve()} on object before returning. * @return The property with the specified name, or <jk>null</jk> if no property is specified. */ + @SuppressWarnings({ + "java:S1452" // Self-bounded (CRTP) generic: 'properties' map values are declared JsonSchema<?> since callers may attach any concrete SELF subtype. + }) public JsonSchema<?> getProperty(String name, boolean resolve) { if (properties == null) return null; @@ -1354,6 +1381,9 @@ public class JsonSchema<SELF extends JsonSchema<SELF>> { * @return The value of the <property>then</property> property on this bean, or <jk>null</jk> if it is not set. */ @BeanProp("then") + @SuppressWarnings({ + "java:S1452" // Self-bounded (CRTP) generic: then_ is declared JsonSchema<?> since callers may attach any concrete SELF subtype. + }) public JsonSchema<?> getThen() { return then_; } /** @@ -1424,6 +1454,9 @@ public class JsonSchema<SELF extends JsonSchema<SELF>> { * * @return The value of the <property>unevaluatedItems</property> property on this bean, or <jk>null</jk> if it is not set. */ + @SuppressWarnings({ + "java:S1452" // Self-bounded (CRTP) generic: unevaluatedItems is declared JsonSchema<?> since callers may attach any concrete SELF subtype. + }) public JsonSchema<?> getUnevaluatedItems() { return unevaluatedItems; } /** @@ -1434,6 +1467,9 @@ public class JsonSchema<SELF extends JsonSchema<SELF>> { * * @return The value of the <property>unevaluatedProperties</property> property on this bean, or <jk>null</jk> if it is not set. */ + @SuppressWarnings({ + "java:S1452" // Self-bounded (CRTP) generic: unevaluatedProperties is declared JsonSchema<?> since callers may attach any concrete SELF subtype. + }) public JsonSchema<?> getUnevaluatedProperties() { return unevaluatedProperties; } /** @@ -1467,6 +1503,9 @@ public class JsonSchema<SELF extends JsonSchema<SELF>> { * * @return The referenced schema, or <jk>null</jk> if this schema is a <property>$ref</property> whose target is not found in the registered schema map. */ + @SuppressWarnings({ + "java:S1452" // Self-bounded (CRTP) generic: resolved schemas come from JsonSchemaMap's JsonSchema<?>-typed value, so no narrower type is possible. + }) public JsonSchema<?> resolve() { if (ref == null || master.schemaMap == null) return this; diff --git a/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchemaBeanGenerator.java b/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchemaBeanGenerator.java index 20a0c4780e..df995f036a 100644 --- a/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchemaBeanGenerator.java +++ b/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchemaBeanGenerator.java @@ -69,6 +69,9 @@ public final class JsonSchemaBeanGenerator { * @param type The Java type. Must not be <jk>null</jk>, or an {@link IllegalArgumentException} is thrown. * @return The generated schema bean, or <jk>null</jk> if a schema could not be generated for the type. */ + @SuppressWarnings({ + "java:S1452" // Self-bounded (CRTP) generic: the generated schema's concrete SELF subtype is not known here, so JsonSchema<?> is the only sound return type. + }) public JsonSchema<?> generate(Type type) { assertArgNotNull("type", type); try { @@ -91,6 +94,9 @@ public final class JsonSchemaBeanGenerator { * @param type The Java class. Must not be <jk>null</jk>, or an {@link IllegalArgumentException} is thrown. * @return The generated schema bean, or <jk>null</jk> if a schema could not be generated for the class. */ + @SuppressWarnings({ + "java:S1452" // Self-bounded (CRTP) generic: the generated schema's concrete SELF subtype is not known here, so JsonSchema<?> is the only sound return type. + }) public JsonSchema<?> generate(Class<?> type) { return generate((Type)type); } @@ -104,6 +110,9 @@ public final class JsonSchemaBeanGenerator { * @param o The value to infer a schema from. Must not be <jk>null</jk>, or an {@link IllegalArgumentException} is thrown. * @return The generated schema bean, or <jk>null</jk> if a schema could not be generated for the value. */ + @SuppressWarnings({ + "java:S1452" // Self-bounded (CRTP) generic: the generated schema's concrete SELF subtype is not known here, so JsonSchema<?> is the only sound return type. + }) public JsonSchema<?> generate(Object o) { assertArgNotNull("o", o); try { @@ -129,6 +138,9 @@ public final class JsonSchemaBeanGenerator { * @param schemaMap The generated schema map. Must not be <jk>null</jk>, or an {@link IllegalArgumentException} is thrown. * @return The typed schema bean. */ + @SuppressWarnings({ + "java:S1452" // Self-bounded (CRTP) generic: the parsed schema's concrete SELF subtype is not known here, so JsonSchema<?> is the only sound return type. + }) public static JsonSchema<?> toBean(JsonMap schemaMap) { assertArgNotNull("schemaMap", schemaMap); try { diff --git a/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchemaMap.java b/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchemaMap.java index d7ef75fbd7..c05abf8255 100644 --- a/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchemaMap.java +++ b/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchemaMap.java @@ -131,6 +131,9 @@ public abstract class JsonSchemaMap extends ConcurrentHashMap<URI,JsonSchema<?>> * @param uri The URI to load the schema from. * @return The parsed schema, or <jk>null</jk> if the document is unreachable. */ + @SuppressWarnings({ + "java:S1452" // Self-bounded (CRTP) generic: the loaded schema's concrete SELF subtype is not known here, so JsonSchema<?> is the only sound return type. + }) public JsonSchema<?> load(URI uri) { try (var r = getReader(uri)) { if (r == null) diff --git a/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchemaValidator.java b/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchemaValidator.java index 8aa8619d42..c8e650c912 100644 --- a/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchemaValidator.java +++ b/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchemaValidator.java @@ -148,6 +148,9 @@ public final class JsonSchemaValidator implements PropertyValidator { * * @return The schema. */ + @SuppressWarnings({ + "java:S1452" // Self-bounded (CRTP) generic: the validated schema's concrete SELF subtype is not known here, so JsonSchema<?> is the only sound return type. + }) public JsonSchema<?> getSchema() { return schema; } diff --git a/juneau-bean/juneau-bean-openapi-v3/src/test/java/org/apache/juneau/bean/openapi3/SchemaInfo_Test.java b/juneau-bean/juneau-bean-openapi-v3/src/test/java/org/apache/juneau/bean/openapi3/SchemaInfo_Test.java index 1ddc77bd1d..e0e3af78a6 100644 --- a/juneau-bean/juneau-bean-openapi-v3/src/test/java/org/apache/juneau/bean/openapi3/SchemaInfo_Test.java +++ b/juneau-bean/juneau-bean-openapi-v3/src/test/java/org/apache/juneau/bean/openapi3/SchemaInfo_Test.java @@ -130,7 +130,8 @@ class SchemaInfo_Test extends TestBase { @Test void a09b_addProperty_nullChecks() { var x = bean(); - assertThrows(IllegalArgumentException.class, () -> x.addProperty(null, schemaInfo("a"))); + var a = schemaInfo("a"); + assertThrows(IllegalArgumentException.class, () -> x.addProperty(null, a)); assertThrows(IllegalArgumentException.class, () -> x.addProperty("a", null)); } diff --git a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/bean/BeanMetaInitializer.java b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/bean/BeanMetaInitializer.java index c411c95e6e..315bfb430d 100644 --- a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/bean/BeanMetaInitializer.java +++ b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/bean/BeanMetaInitializer.java @@ -130,8 +130,8 @@ public interface BeanMetaInitializer { * Builds the bean-level {@link BeanRegistryLookup} for the supplied class. Returns <jk>null</jk> on the * commons-side path (no marshalling context). * - * @param marshallingContext The marshalling-side context (as an opaque {@link Object}). Can be <jk>null</jk>. The effect is implementation-dependent — see {@link org.apache.juneau.marshall.MarshalledBeanMetaInitializer}, the sole concrete implementer of this SPI. - * @param beanFilter The bean filter applied to this bean meta. Can be <jk>null</jk>. The effect is implementation-dependent — see {@link org.apache.juneau.marshall.MarshalledBeanMetaInitializer}. + * @param marshallingContext The marshalling-side context (as an opaque {@link Object}). Can be <jk>null</jk>. The effect is implementation-dependent — see {@code org.apache.juneau.marshall.MarshalledBeanMetaInitializer}, the sole concrete implementer of this SPI. + * @param beanFilter The bean filter applied to this bean meta. Can be <jk>null</jk>. The effect is implementation-dependent — see {@code org.apache.juneau.marshall.MarshalledBeanMetaInitializer}. * @param classInfo The class info of the bean. Must not be <jk>null</jk>. * @param config The bean-modeling configuration. Must not be <jk>null</jk>. * @return The bean-level registry, or <jk>null</jk>. @@ -152,7 +152,7 @@ public interface BeanMetaInitializer { * Walks the parent classes/interfaces of {@code classInfo} and returns the first dictionary-name mapping for * {@code rawClass} found in any parent's registry, or <jk>null</jk> if none. * - * @param marshallingContext The marshalling-side context. Can be <jk>null</jk>. The effect is implementation-dependent — see {@link org.apache.juneau.marshall.MarshalledBeanMetaInitializer}. + * @param marshallingContext The marshalling-side context. Can be <jk>null</jk>. The effect is implementation-dependent — see {@code org.apache.juneau.marshall.MarshalledBeanMetaInitializer}. * @param classInfo The bean's class info. * @param rawClass The raw class to look up. * @return The dictionary name found in a parent's registry, or <jk>null</jk>. diff --git a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/logging/LogRecord.java b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/logging/LogRecord.java index c4f67d1f49..ff87597079 100644 --- a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/logging/LogRecord.java +++ b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/logging/LogRecord.java @@ -27,8 +27,6 @@ import java.util.Formatter; import java.util.function.*; import java.util.logging.*; -import org.apache.juneau.commons.utils.*; - /** * LogRecord that supports lazy message formatting. * diff --git a/juneau-core/juneau-commons/src/test/java/org/apache/juneau/commons/logging/LogRecord_Test.java b/juneau-core/juneau-commons/src/test/java/org/apache/juneau/commons/logging/LogRecord_Test.java index 2d6dde98fc..a68fe91aff 100644 --- a/juneau-core/juneau-commons/src/test/java/org/apache/juneau/commons/logging/LogRecord_Test.java +++ b/juneau-core/juneau-commons/src/test/java/org/apache/juneau/commons/logging/LogRecord_Test.java @@ -31,12 +31,6 @@ import org.junit.jupiter.params.provider.*; */ class LogRecord_Test extends TestBase { - private static Logger getLogger(String name) { - var l = Logger.getLogger(name); - l.setLevel(Level.OFF); - return l; - } - //==================================================================================================== // Constructor and basic properties //==================================================================================================== diff --git a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/Config.java b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/Config.java index 55dc323678..c9f4cdfd44 100644 --- a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/Config.java +++ b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/Config.java @@ -522,7 +522,7 @@ public class Config extends Context implements ConfigEventListener { var cmd = env("sun.java.command", "not_found").split("\\s+")[0]; if (cmd.endsWith(".jar") && ! co(cmd, "surefirebooter")) { // HTT - not a .jar during tests - cmd = cmd.replaceAll("(?:.*[\\\\\\/])?([^\\\\\\/]+)\\.jar$", "$1"); + cmd = cmd.replaceAll("(?:[^\\\\\\/]*[\\\\\\/])*([^\\\\\\/]+)\\.jar$", "$1"); // Unrolled loop (no .* overlapping the separator class) avoids super-linear backtracking; same "strip path up to last separator" semantics. l.add(cmd + ".cfg"); cmd = cmd.replaceAll("[\\.\\_].*$", ""); // Try also without version in jar name. l.add(cmd + ".cfg"); diff --git a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/store/FileStore.java b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/store/FileStore.java index 5cab02becb..a68615b309 100644 --- a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/store/FileStore.java +++ b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/store/FileStore.java @@ -429,7 +429,10 @@ public class FileStore extends ConfigStore { name = resolveName(name); var p = resolveFile(name); - name = p.getFileName().toString(); + var pName = p.getFileName(); + if (n(pName)) + throw ioex("Could not resolve a file name from path '%s'.", p); // Real NPE guard: getFileName() can return null when p resolves to a root path (e.g. a caller-supplied absolute name). + name = pName.toString(); var s = cache.get(name); if (nn(s)) @@ -480,7 +483,10 @@ public class FileStore extends ConfigStore { dir.mkdirs(); var p = resolveFile(name); - name = p.getFileName().toString(); + var pName = p.getFileName(); + if (n(pName)) + throw ioex("Could not resolve a file name from path '%s'.", p); // Real NPE guard: getFileName() can return null when p resolves to a root path (e.g. a caller-supplied absolute name). + name = pName.toString(); var exists = Files.exists(p); @@ -526,6 +532,9 @@ public class FileStore extends ConfigStore { return null; } + @SuppressWarnings({ + "javabugs:S2259" // p.getParent() is only reached when p does not exist; p is always dir.resolve(nonEmptySegment), so the only way p could be a rootless path with a null parent is if p itself were the filesystem root, which always exists and would skip this branch. + }) private synchronized boolean isWritable(Path p) { try { if (! Files.exists(p)) { @@ -550,6 +559,9 @@ public class FileStore extends ConfigStore { * @param e The file system event. * @throws IOException Thrown by underlying stream. */ + @SuppressWarnings({ + "javabugs:S2259" // e.context() for ENTRY_CREATE/DELETE/MODIFY events (OVERFLOW is filtered out before this is called) is documented to return the single relative path segment of the changed entry, which always has a non-null file name. + }) protected synchronized void onFileEvent(WatchEvent<Path> e) throws IOException { var fn = e.context().getFileName().toString(); @@ -572,7 +584,8 @@ public class FileStore extends ConfigStore { @Override @SuppressWarnings({ - "java:S3776" // Cognitive complexity acceptable for name resolution logic + "java:S3776", // Cognitive complexity acceptable for name resolution logic + "javabugs:S2259" // nameCache.get(name) at the end is always preceded by a put for this key in this call (or the key already existed), and no code ever removes entries, so the map is guaranteed to contain it. }) protected String resolveName(String name) { if (! nameCache.containsKey(name)) { diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/hjson/HjsonParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/hjson/HjsonParserSession.java index a4ebb89eef..42273d0c8e 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/hjson/HjsonParserSession.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/hjson/HjsonParserSession.java @@ -335,7 +335,7 @@ public class HjsonParserSession extends ReaderParserSession implements RecordRea * Recursively injects @ParentProperty (and @NameProperty on map values / nested beans) into val. * Intermediate collections and maps are transparent: a collection/map element's parent is * parentBean (the nearest enclosing bean), skipping all intermediate containers. This keeps HJSON - * consistent with the streaming parsers under TODO-291 (Option A). + * consistent with the streaming parsers. */ private void injectParentAnnotations(ClassMeta<?> cm, Object val, Object node, Object parentBean) throws ExecutableException { if (val == null || cm == null) diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/hocon/HoconParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/hocon/HoconParserSession.java index 6df44d9bff..27519786e9 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/hocon/HoconParserSession.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/hocon/HoconParserSession.java @@ -520,7 +520,7 @@ public class HoconParserSession extends ReaderParserSession implements RecordRea * Recursively injects @ParentProperty (and @NameProperty on map values / nested beans) into val. * Intermediate collections and maps are transparent: a collection/map element's parent is * parentBean (the nearest enclosing bean), skipping all intermediate containers. This keeps HOCON - * consistent with the streaming parsers under TODO-291 (Option A). + * consistent with the streaming parsers. */ private void injectParentAnnotations(ClassMeta<?> cm, Object val, Object node, Object parentBean) throws ExecutableException { if (val == null || cm == null) diff --git a/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/ParentPropertyContainer_Test.java b/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/ParentPropertyContainer_Test.java index 623c64be16..3ffe79a95e 100644 --- a/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/ParentPropertyContainer_Test.java +++ b/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/ParentPropertyContainer_Test.java @@ -40,7 +40,7 @@ import org.junit.jupiter.params.*; import org.junit.jupiter.params.provider.*; /** - * Regression tests for TODO-291 / FINISHED-291. + * Regression tests for FINISHED-291. * * <p> * Verifies that a bean annotated with {@link ParentProperty} that is nested inside a collection or diff --git a/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/markdown/MarkdownParserSession_Test.java b/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/markdown/MarkdownParserSession_Test.java index 21f9ab3c2e..31f9a3fd8e 100644 --- a/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/markdown/MarkdownParserSession_Test.java +++ b/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/markdown/MarkdownParserSession_Test.java @@ -161,12 +161,23 @@ class MarkdownParserSession_Test extends TestBase { assertEquals("---", r); } - @Test void c03_keyHeaderVariant() { - // "Key"/"Value" headers should also be detected as a key/value table. - var md = "| Key | Value |\n|---|---|\n| name | Bob |\n| age | 25 |"; + @ParameterizedTest + @MethodSource("c03_keyValueTableToBeanProvider") + void c03_keyValueTableToBean(String md, String expectedName, int expectedAge) { var r = MarkdownParser.DEFAULT.read(md, MarkdownParser_Test.A.class); - assertEquals("Bob", r.name); - assertEquals(25, r.age); + assertEquals(expectedName, r.name); + assertEquals(expectedAge, r.age); + } + + static Stream<Arguments> c03_keyValueTableToBeanProvider() { + return Stream.of( + // c03: "Key"/"Value" headers should also be detected as a key/value table. + Arguments.of("| Key | Value |\n|---|---|\n| name | Bob |\n| age | 25 |", "Bob", 25), + // k02: lines not starting with | should be filtered out of the table-line collection. + Arguments.of("| Property | Value |\n|---|---|\n| name | Alice |\nthis is not a row\n| age | 30 |", "Alice", 30), + // n02: empty cell for int type -> readCellValue returns null/default-zero. + Arguments.of("| Property | Value |\n|---|---|\n| name | Alice |\n| age | |", "Alice", 0) + ); } @Test void c04_tableEmptyHeaderCells() { @@ -600,14 +611,6 @@ class MarkdownParserSession_Test extends TestBase { assertEquals("Alice", r.get("name")); } - @Test void k02_lineWithoutPipeIgnored() { - // Lines not starting with | should be filtered out of the table-line collection. - var md = "| Property | Value |\n|---|---|\n| name | Alice |\nthis is not a row\n| age | 30 |"; - var r = MarkdownParser.DEFAULT.read(md, MarkdownParser_Test.A.class); - assertEquals("Alice", r.name); - assertEquals(30, r.age); - } - //==================================================================================================== // l - Multi-column simple element type (readRow simple type fall-through) //==================================================================================================== @@ -651,14 +654,6 @@ class MarkdownParserSession_Test extends TestBase { assertEquals(30, r.age); } - @Test void n02_emptyCellForIntType() { - // Empty cell for int type → readCellValue returns null/default-zero at line 578 - var md = "| Property | Value |\n|---|---|\n| name | Alice |\n| age | |"; - var r = MarkdownParser.DEFAULT.read(md, MarkdownParser_Test.A.class); - assertEquals("Alice", r.name); - assertEquals(0, r.age); - } - @Test void n03_customNullValueMatch() { // Cell value matching custom nullValue → readCellValue returns null at line 572 var p = MarkdownParser.create().nullValue("N/A").build(); diff --git a/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/toml/TomlTokenizer_Test.java b/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/toml/TomlTokenizer_Test.java index 3ef54fb6c4..1ee80c1e72 100644 --- a/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/toml/TomlTokenizer_Test.java +++ b/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/toml/TomlTokenizer_Test.java @@ -253,28 +253,19 @@ class TomlTokenizer_Test extends TestBase { // readBasicString and escapes //----------------------------------------------------------------------------------------------------------------- - @Test - void f01_readBasicStringSimple() throws Exception { - var tok = t("\"hello\""); - assertEquals("hello", tok.readBasicString()); - } - - @Test - void f03_readBasicStringAllEscapes() throws Exception { - var tok = t("\"\\b\\t\\n\\f\\r\\\"\\\\\""); - assertEquals("\b\t\n\f\r\"\\", tok.readBasicString()); - } - - @Test - void f04_readBasicStringUnicodeShort() throws Exception { - var tok = t("\"\\u0041\""); - assertEquals("A", tok.readBasicString()); + @ParameterizedTest + @MethodSource("f01_readBasicStringValidProvider") + void f01_readBasicStringValid(String input, String expected) throws Exception { + assertEquals(expected, t(input).readBasicString()); } - @Test - void f05_readBasicStringUnicodeLong() throws Exception { - var tok = t("\"\\U00000041\""); - assertEquals("A", tok.readBasicString()); + static Stream<Arguments> f01_readBasicStringValidProvider() { + return Stream.of( + Arguments.of("\"hello\"", "hello"), // f01: simple string + Arguments.of("\"\\b\\t\\n\\f\\r\\\"\\\\\"", "\b\t\n\f\r\"\\"), // f03: all standard escapes + Arguments.of("\"\\u0041\"", "A"), // f04: short \\u unicode escape + Arguments.of("\"\\U00000041\"", "A") // f05: long \\U unicode escape + ); } @ParameterizedTest diff --git a/juneau-core/juneau-test-marshall-utils/src/main/java/org/apache/juneau/BeanTester.java b/juneau-core/juneau-test-marshall-utils/src/main/java/org/apache/juneau/BeanTester.java index bd43d585db..886742e8f0 100644 --- a/juneau-core/juneau-test-marshall-utils/src/main/java/org/apache/juneau/BeanTester.java +++ b/juneau-core/juneau-test-marshall-utils/src/main/java/org/apache/juneau/BeanTester.java @@ -58,7 +58,8 @@ import org.apache.juneau.test.bct.*; * @param <T> The type of bean being tested */ @SuppressWarnings({ - "unchecked" // Class<T> cast for generic bean type in test utility + "unchecked", // Class<T> cast for generic bean type in test utility + "java:S5960" // Test utility; JUnit assertions are its intentional purpose, not a production-code side effect. }) public class BeanTester<T> { diff --git a/juneau-core/juneau-test-marshall-utils/src/main/java/org/apache/juneau/a/rttests/RoundTrip_Tester.java b/juneau-core/juneau-test-marshall-utils/src/main/java/org/apache/juneau/a/rttests/RoundTrip_Tester.java index 86bb77b358..b619eeab06 100644 --- a/juneau-core/juneau-test-marshall-utils/src/main/java/org/apache/juneau/a/rttests/RoundTrip_Tester.java +++ b/juneau-core/juneau-test-marshall-utils/src/main/java/org/apache/juneau/a/rttests/RoundTrip_Tester.java @@ -30,7 +30,8 @@ import org.apache.juneau.marshall.serializer.*; import org.apache.juneau.marshall.xml.*; @SuppressWarnings({ - "unchecked" // Cast from Object to T in round-trip test infra + "unchecked", // Cast from Object to T in round-trip test infra + "java:S101" // Underscore test-type naming (e.g. sibling ComboRoundTrip_Tester classes) is an established Juneau convention. }) public class RoundTrip_Tester { @@ -177,6 +178,9 @@ public class RoundTrip_Tester { return skipIf != null && skipIf.test(o); } + @SuppressWarnings({ + "java:S106" // Test harness diagnostic output, gated behind the debug flag; mirrors juneau-test's Assertion.java precedent. + }) public <T> Object serialize(T object, Serializer s) throws Exception { Object out; @@ -187,7 +191,7 @@ public class RoundTrip_Tester { } if (debug) - System.err.println("Serialized contents from ["+label+"]...\n---START---\n" + (out instanceof byte[] ? toReadableBytes((byte[])out) : out) + "\n---END---\n"); // NOT DEBUG + System.err.println("Serialized contents from ["+label+"]...\n---START---\n" + (out instanceof byte[] byteArray ? toReadableBytes(byteArray) : out) + "\n---END---\n"); // NOT DEBUG if (validateXmlWhitespace) checkXmlWhitespace(out.toString()); diff --git a/juneau-core/juneau-test-marshall-utils/src/main/java/org/apache/juneau/marshall/testutils/pojos/TestURI.java b/juneau-core/juneau-test-marshall-utils/src/main/java/org/apache/juneau/marshall/testutils/pojos/TestURI.java index d52c8f25a7..c6bc183137 100755 --- a/juneau-core/juneau-test-marshall-utils/src/main/java/org/apache/juneau/marshall/testutils/pojos/TestURI.java +++ b/juneau-core/juneau-test-marshall-utils/src/main/java/org/apache/juneau/marshall/testutils/pojos/TestURI.java @@ -27,23 +27,36 @@ public class TestURI { @Xml(format=XmlFormat.ATTR) public String f0 = "f0/x0"; - public URI f1, f2, f3; + public URI f1; + public URI f2; + public URI f3; @Uri - public String f4, f5, f6; + public String f4; + @Uri + public String f5; + @Uri + public String f6; public URL f7; public TestURIb f8; - public String fa, fb, fc, fd, fe; + public String fa; + public String fb; + public String fc; + public String fd; + public String fe; @Uri public String getF9() { return "f9/x9"; } - public TestURI() throws Exception { + @SuppressWarnings({ + "java:S1075" // Test fixture; fixed round-trip URIs are the intended test data, not a configurable endpoint. + }) + public TestURI() throws URISyntaxException, MalformedURLException { f1 = new URI("f1/x1"); f2 = new URI("/f2/x2"); f3 = new URI("http://www.apache.org/f3/x3"); diff --git a/juneau-core/juneau-test-utils/src/main/java/org/apache/juneau/XmlTestUtils.java b/juneau-core/juneau-test-utils/src/main/java/org/apache/juneau/XmlTestUtils.java index 57b7a390a5..6867bca7b2 100644 --- a/juneau-core/juneau-test-utils/src/main/java/org/apache/juneau/XmlTestUtils.java +++ b/juneau-core/juneau-test-utils/src/main/java/org/apache/juneau/XmlTestUtils.java @@ -74,6 +74,9 @@ public final class XmlTestUtils { * @return The indent depth after processing this line. * @throws Exception If the line's indentation is wrong, or the line doesn't match any recognized form. */ + @SuppressWarnings({ + "java:S112" // Test utility; generic exception mirrors checkXmlWhitespace's diagnostic contract, not swallowed by callers. + }) private static int checkLineIndent(String line, int lineNum, int indent) throws Exception { var m = START_TAG.matcher(line); if (m.matches()) { @@ -117,6 +120,9 @@ public final class XmlTestUtils { * @param lineType A human-readable description of the line kind being checked (for error messages). * @throws Exception If <c>actual != expected</c>. */ + @SuppressWarnings({ + "java:S112" // Test utility; generic exception mirrors checkXmlWhitespace's diagnostic contract, not swallowed by callers. + }) private static void checkIndent(int expected, int actual, int lineNum, String lineType) throws Exception { if (actual != expected) throw new Exception("Wrong indentation detected on " + lineType + " line ''" + lineNum + "''"); diff --git a/juneau-integration-tests/src/test/java/org/apache/juneau/rest/server/auth/saml/SamlAssertionValidator_Builder_Test.java b/juneau-integration-tests/src/test/java/org/apache/juneau/rest/server/auth/saml/SamlAssertionValidator_Builder_Test.java index 328af829bf..5c2614730d 100644 --- a/juneau-integration-tests/src/test/java/org/apache/juneau/rest/server/auth/saml/SamlAssertionValidator_Builder_Test.java +++ b/juneau-integration-tests/src/test/java/org/apache/juneau/rest/server/auth/saml/SamlAssertionValidator_Builder_Test.java @@ -17,6 +17,7 @@ package org.apache.juneau.rest.server.auth.saml; import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.mock; import java.security.*; import java.time.*; @@ -120,7 +121,7 @@ class SamlAssertionValidator_Builder_Test extends TestBase { @Test void d01_credentialAndResolverMutuallyExclusive() throws Exception { var cred = dummyCredential(); - var meta = org.mockito.Mockito.mock(org.opensaml.saml.metadata.resolver.MetadataResolver.class); + var meta = mock(org.opensaml.saml.metadata.resolver.MetadataResolver.class); assertThrows(IllegalStateException.class, () -> SamlAssertionValidator.create() .spEntityId("sp").expectedIssuer("idp") .signingCredential(cred) diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/BadGateway.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/BadGateway.java index cc5aa1dca1..636c967d8e 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/BadGateway.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/BadGateway.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class BadGateway extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/BadRequest.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/BadRequest.java index ea184020d4..e58ab58c38 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/BadRequest.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/BadRequest.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class BadRequest extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Conflict.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Conflict.java index 901ae07d4f..57845cdc2d 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Conflict.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Conflict.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class Conflict extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/ExpectationFailed.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/ExpectationFailed.java index d231c5fbfc..20a6a0eec4 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/ExpectationFailed.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/ExpectationFailed.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class ExpectationFailed extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/FailedDependency.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/FailedDependency.java index d10b263e8c..59bbe55cc5 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/FailedDependency.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/FailedDependency.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class FailedDependency extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Forbidden.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Forbidden.java index 6e3a85e6f4..8b8ef643f6 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Forbidden.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Forbidden.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class Forbidden extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/GatewayTimeout.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/GatewayTimeout.java index 3018273de2..0772114c5b 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/GatewayTimeout.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/GatewayTimeout.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class GatewayTimeout extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Gone.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Gone.java index 39064c9dc8..c394b77c1b 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Gone.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Gone.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class Gone extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/HttpVersionNotSupported.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/HttpVersionNotSupported.java index cf1ee7e753..5a6a204c79 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/HttpVersionNotSupported.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/HttpVersionNotSupported.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class HttpVersionNotSupported extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/InsufficientStorage.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/InsufficientStorage.java index 89f409bf1b..a197a63f57 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/InsufficientStorage.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/InsufficientStorage.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class InsufficientStorage extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/InternalServerError.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/InternalServerError.java index 4648c900c4..f6eb667bb6 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/InternalServerError.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/InternalServerError.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class InternalServerError extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/LengthRequired.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/LengthRequired.java index 33b81fd0a9..3c54d1a7ef 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/LengthRequired.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/LengthRequired.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class LengthRequired extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Locked.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Locked.java index ab6f6b52bc..2952581744 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Locked.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Locked.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class Locked extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/LoopDetected.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/LoopDetected.java index 322da48ab7..fc2ed657cb 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/LoopDetected.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/LoopDetected.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class LoopDetected extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/MethodNotAllowed.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/MethodNotAllowed.java index 8b5b3afa34..2c21d8e3a6 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/MethodNotAllowed.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/MethodNotAllowed.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class MethodNotAllowed extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/MisdirectedRequest.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/MisdirectedRequest.java index 21fa2d928d..c8ebe1e228 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/MisdirectedRequest.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/MisdirectedRequest.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class MisdirectedRequest extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NetworkAuthenticationRequired.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NetworkAuthenticationRequired.java index 7317204dcb..75a003b7be 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NetworkAuthenticationRequired.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NetworkAuthenticationRequired.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class NetworkAuthenticationRequired extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NotAcceptable.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NotAcceptable.java index f775673a08..41f9a5a84d 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NotAcceptable.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NotAcceptable.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class NotAcceptable extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NotExtended.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NotExtended.java index 25f5570c35..4e7e588e07 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NotExtended.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NotExtended.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class NotExtended extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NotFound.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NotFound.java index b8da3fe3b1..701512d0ac 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NotFound.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NotFound.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class NotFound extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NotImplemented.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NotImplemented.java index 1dba2d97af..daff3ecbdc 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NotImplemented.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/NotImplemented.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class NotImplemented extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/PayloadTooLarge.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/PayloadTooLarge.java index 91df923d89..f27a05c383 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/PayloadTooLarge.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/PayloadTooLarge.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class PayloadTooLarge extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/PreconditionFailed.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/PreconditionFailed.java index 850e03a91e..aada77712b 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/PreconditionFailed.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/PreconditionFailed.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class PreconditionFailed extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/PreconditionRequired.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/PreconditionRequired.java index 8e59d4f1f3..8be1078aeb 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/PreconditionRequired.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/PreconditionRequired.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class PreconditionRequired extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/RangeNotSatisfiable.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/RangeNotSatisfiable.java index cb631d1ef8..0241f96ed2 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/RangeNotSatisfiable.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/RangeNotSatisfiable.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class RangeNotSatisfiable extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/RequestHeaderFieldsTooLarge.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/RequestHeaderFieldsTooLarge.java index 071a2c75c2..7c864bea8d 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/RequestHeaderFieldsTooLarge.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/RequestHeaderFieldsTooLarge.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class RequestHeaderFieldsTooLarge extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/ServiceUnavailable.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/ServiceUnavailable.java index d5796d66f1..2404e7362b 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/ServiceUnavailable.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/ServiceUnavailable.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class ServiceUnavailable extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/TooManyRequests.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/TooManyRequests.java index dbc9ad2f5c..665a6fa6e2 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/TooManyRequests.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/TooManyRequests.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class TooManyRequests extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Unauthorized.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Unauthorized.java index 53c02abf4d..48e1a402a2 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Unauthorized.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/Unauthorized.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class Unauthorized extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UnavailableForLegalReasons.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UnavailableForLegalReasons.java index 39889cc43b..081c62e882 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UnavailableForLegalReasons.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UnavailableForLegalReasons.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class UnavailableForLegalReasons extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UnprocessableEntity.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UnprocessableEntity.java index 1920154cc0..0951cb61ae 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UnprocessableEntity.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UnprocessableEntity.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class UnprocessableEntity extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UnsupportedMediaType.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UnsupportedMediaType.java index 8cfce59fc7..5dccc18bb6 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UnsupportedMediaType.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UnsupportedMediaType.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class UnsupportedMediaType extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UpgradeRequired.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UpgradeRequired.java index 583b91f881..70094acd40 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UpgradeRequired.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UpgradeRequired.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class UpgradeRequired extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UriTooLong.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UriTooLong.java index ef779e8c60..b1786c20f6 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UriTooLong.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/UriTooLong.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class UriTooLong extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/VariantAlsoNegotiates.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/VariantAlsoNegotiates.java index bbb5f62a02..c2a5d42d80 100644 --- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/VariantAlsoNegotiates.java +++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/VariantAlsoNegotiates.java @@ -38,6 +38,9 @@ import org.apache.juneau.http.*; * * @since 9.2.1 */ +@SuppressWarnings({ + "java:S110" // intentional — mirrors the HTTP status-code response hierarchy +}) public class VariantAlsoNegotiates extends BasicHttpException { private static final long serialVersionUID = 1L; diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/server/servlet/RestServlet.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/server/servlet/RestServlet.java index af09eaf577..9e16199f2b 100644 --- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/server/servlet/RestServlet.java +++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/server/servlet/RestServlet.java @@ -175,6 +175,9 @@ public abstract class RestServlet extends HttpServlet { * * @return The context information on this servlet. */ + @SuppressWarnings({ + "java:S2886" // Reads the AtomicReference 'context' field, which already guarantees atomicity and cross-thread visibility (same as a volatile read); synchronizing this single read with the setContext()/init() lock would add hot-path contention with no correctness benefit. + }) public RestContext getContext() { var rc = context.get(); if (rc == null) @@ -188,6 +191,9 @@ public abstract class RestServlet extends HttpServlet { * * @return The path defined on this servlet, or an empty string if not specified. */ + @SuppressWarnings({ + "java:S2886" // Reads the AtomicReference 'context' field, which already guarantees atomicity and cross-thread visibility (same as a volatile read); synchronizing this single read with the setContext()/init() lock would add hot-path contention with no correctness benefit. + }) public String getPath() { var context2 = this.context.get(); if (nn(context2)) diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/server/validation/ValidationException.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/server/validation/ValidationException.java index d3844cf03b..cca08db5b5 100644 --- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/server/validation/ValidationException.java +++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/server/validation/ValidationException.java @@ -53,7 +53,8 @@ import org.apache.juneau.http.response.*; * @since 10.0.0 */ @SuppressWarnings({ - "java:S110" // Deep inheritance inherent to the exception hierarchy + "java:S110", // Deep inheritance inherent to the exception hierarchy + "java:S2160" // Exceptions are compared by identity, not by their violations payload; no equals() override needed }) public class ValidationException extends BadRequest {
