You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2026/10/18 00:12:34 UTC

(juneau) branch juneau-release-manager updated: Clear the Eclipse warnings (R0038); fix or suppress the Sonar issues (R0039); and adopt the all-language always-suppress Sonar table and NOSONAR format in CODE-CONVENTIONS.md (P0132)

This is an automated email from the ASF dual-hosted git repository.

jamesbognar pushed a commit to branch juneau-release-manager
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/juneau-release-manager by this push:
     new 822c90cd56 Clear the Eclipse warnings (R0038); fix or suppress the Sonar issues (R0039); and adopt the all-language always-suppress Sonar table and NOSONAR format in CODE-CONVENTIONS.md (P0132)
822c90cd56 is described below

commit 822c90cd56c06a18c8e54cae32dec77b94e80050
Author: James Bognar <ja...@apache.org>
AuthorDate: Sat Oct 17 20:12:28 2026 -0400

    Clear the Eclipse warnings (R0038); fix or suppress the Sonar issues (R0039); and adopt the all-language always-suppress Sonar table and NOSONAR format in CODE-CONVENTIONS.md (P0132)
---
 CODE-CONVENTIONS.md                                |  2 +-
 .../apache/juneau/releng/engine/AuditService.java  |  3 +++
 .../apache/juneau/releng/log/RunEventStore.java    | 22 ++++++++++++++--------
 .../juneau/releng/log/RunStateBroadcaster.java     |  2 +-
 .../juneau/releng/log/StepOutputSources.java       |  3 +++
 .../apache/juneau/releng/rest/ReleaseRunRest.java  |  6 ------
 .../apache/juneau/releng/log/LogBranchesTest.java  |  9 +++++++++
 .../releng/nexus/NexusStagingClientHttpTest.java   | 12 +++++++++---
 .../juneau/releng/rest/ReleaseRunRestTest.java     |  3 ++-
 9 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/CODE-CONVENTIONS.md b/CODE-CONVENTIONS.md
index 8185dc2af2..5b37e05abc 100644
--- a/CODE-CONVENTIONS.md
+++ b/CODE-CONVENTIONS.md
@@ -37,7 +37,7 @@ Each item: a one-line rule, then **Applied** or **N/A** (with rationale).
   (`NexusMockRestHttpTest` wrapping a caught `Exception`, `SseLogServletTest` simulated broken-pipe
   `IOException`, `RunStateBroadcasterTest` `"dead client"` subscriber) — constructors stay; `rex`/`ioex`
   would not be clearer there.
-- **Always-suppress Sonar rules.** JRM uses the always-suppress table in `@juneau-code-conventions` (S1192, S3776, S6539, S6541, S110, S115, S9149). When one fires, suppress it; don't refactor to satisfy it. **`java:S1192`: inline and suppress, never extract.** Do not add `private static final String PROJECT = "project";`-style constants for duplicated literals. Keep the literal inline and suppress `java:S1192` once at class level, with a rationale (James 2026-10-09).
+- **Always-suppress Sonar rules.** JRM uses the always-suppress table in `@code-conventions` (S1192, S3776, S6539, S6541, S110, S115, S9149; `java:`, `python:` and `javascript:` keys alike). When one fires, suppress it; don't refactor to satisfy it. **`java:S1192`: inline and suppress, never extract.** Do not add `private static final String PROJECT = "project";`-style constants for duplicated literals. Keep the literal inline and suppress `java:S1192` once at class level, with a rationa [...]
 - **Everyday `Shorts` idioms** — In new and touched code, use the Shorts forms from `@juneau-code-conventions` → "Shorts for everyday idioms" (`b(x)` for `Boolean.TRUE.equals(x)`, `eq`/`neq`, `ie`/`ine`, `ib`/`inb`, `sw`/`ew`/`co`, `lc`/`uc`/`tr`, `ein`/`nie`, `s`, `f`, `or`, `o`/`oo`, `u`, `cn`/`cns`, `rnn`) instead of the JDK spelling (James 2026-10-09).
 - **Collection factories (`Shorts` `l`/`m`/`tl`/`los`/`cp`)** — **Applied** at real candidates only
   (leftover pass 2026-09-13). Copy constructor → `tl` (`ReleaseListService`); empty insertion-ordered
diff --git a/src/main/java/org/apache/juneau/releng/engine/AuditService.java b/src/main/java/org/apache/juneau/releng/engine/AuditService.java
index 3892738e9f..283435724c 100644
--- a/src/main/java/org/apache/juneau/releng/engine/AuditService.java
+++ b/src/main/java/org/apache/juneau/releng/engine/AuditService.java
@@ -84,6 +84,9 @@ public class AuditService {
 		return out;
 	}
 
+	@SuppressWarnings({
+		"java:S1192" // "status" is the event wire key, repeated once per event kind; a constant would obscure the switch.
+	})
 	private static AuditEntry fromEvent(String run, int seq, String ev, Map<String,Object> e) {
 		return switch (ev) {
 			case "step" -> new AuditEntry(run, seq, ev, null, str(e.get("id")), str(e.get("status")), str(e.get("title")));
diff --git a/src/main/java/org/apache/juneau/releng/log/RunEventStore.java b/src/main/java/org/apache/juneau/releng/log/RunEventStore.java
index 5204727277..8bdd68d1f9 100644
--- a/src/main/java/org/apache/juneau/releng/log/RunEventStore.java
+++ b/src/main/java/org/apache/juneau/releng/log/RunEventStore.java
@@ -258,15 +258,9 @@ public class RunEventStore {
 				for (var line : Files.readAllLines(file, StandardCharsets.UTF_8)) {
 					if (line.isBlank())
 						continue;
-					try {
-						@SuppressWarnings({
-							"unchecked" // Json parses an object line to a Map<String,Object>.
-						})
-						Map<String,Object> m = Json.DEFAULT.read(line, Map.class);
+					var m = parseEvent(file, line);
+					if (m != null)
 						out.add(m);
-					} catch (RuntimeException e) {
-						LOG.log(Level.WARNING, "Skipped an unreadable event in " + file.getFileName() + ": " + e.getMessage());
-					}
 				}
 			} catch (IOException e) {
 				LOG.log(Level.WARNING, "Cannot read " + file.getFileName() + ": " + e.getMessage());
@@ -275,6 +269,18 @@ public class RunEventStore {
 		return out;
 	}
 
+	@SuppressWarnings({
+		"unchecked" // Json parses an object line to a Map<String,Object>.
+	})
+	private static Map<String,Object> parseEvent(Path file, String line) {
+		try {
+			return Json.DEFAULT.read(line, Map.class);
+		} catch (RuntimeException e) {
+			LOG.log(Level.WARNING, "Skipped an unreadable event in " + file.getFileName() + ": " + e.getMessage());
+			return null;
+		}
+	}
+
 	private Path file(String version) {
 		return logsDir.resolve(version + "-events.jsonl");
 	}
diff --git a/src/main/java/org/apache/juneau/releng/log/RunStateBroadcaster.java b/src/main/java/org/apache/juneau/releng/log/RunStateBroadcaster.java
index f29f335a4e..1f8b9c216a 100644
--- a/src/main/java/org/apache/juneau/releng/log/RunStateBroadcaster.java
+++ b/src/main/java/org/apache/juneau/releng/log/RunStateBroadcaster.java
@@ -22,7 +22,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.function.Consumer;
 
 /**
- * Per-run in-memory pub/sub of run/step-status snapshots, mirroring {@link LogBroadcaster}'s shape.
+ * Per-run in-memory pub/sub of run/step-status snapshots.
  * Subscribers are SSE connections to the run-state channel ({@code /events/{version}/state}); each
  * published payload is one JSON-serialized {@code RunStateSnapshot}. Publish is thread-safe since steps
  * run on a background thread while SSE connections read/write on request-handling threads.
diff --git a/src/main/java/org/apache/juneau/releng/log/StepOutputSources.java b/src/main/java/org/apache/juneau/releng/log/StepOutputSources.java
index 30e85230a6..82f625ddb0 100644
--- a/src/main/java/org/apache/juneau/releng/log/StepOutputSources.java
+++ b/src/main/java/org/apache/juneau/releng/log/StepOutputSources.java
@@ -56,6 +56,9 @@ public class StepOutputSources {
 	 * @param stepId The step id.
 	 * @return The source, or empty when there is no such run or step, or the step has not written a log yet.
 	 */
+	@SuppressWarnings({
+		"resource" // The FileTerminalSource returned is cached and managed by this class's sources map.
+	})
 	public Optional<TerminalSource> find(String version, String stepId) {
 		var step = store.load(version).map(rs -> rs.step(stepId)).orElse(null);
 		if (step == null || step.logRef == null)
diff --git a/src/main/java/org/apache/juneau/releng/rest/ReleaseRunRest.java b/src/main/java/org/apache/juneau/releng/rest/ReleaseRunRest.java
index 8a46be2599..0236012996 100644
--- a/src/main/java/org/apache/juneau/releng/rest/ReleaseRunRest.java
+++ b/src/main/java/org/apache/juneau/releng/rest/ReleaseRunRest.java
@@ -20,7 +20,6 @@ package org.apache.juneau.releng.rest;
 import static org.apache.juneau.commons.utils.Shorts.*;
 import static org.apache.juneau.commons.utils.StringUtils.escapeForScript;
 
-import java.io.IOException;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Optional;
@@ -31,12 +30,10 @@ import org.apache.juneau.http.Path;
 import org.apache.juneau.http.response.Conflict;
 import org.apache.juneau.http.response.NotFound;
 import org.apache.juneau.rest.server.Mutating;
-import org.apache.juneau.rest.server.OpSwagger;
 import org.apache.juneau.rest.server.Rest;
 import org.apache.juneau.rest.server.RestGet;
 import org.apache.juneau.rest.server.RestPost;
 import org.apache.juneau.rest.server.RestRequest;
-import org.apache.juneau.rest.server.RestResponse;
 import org.apache.juneau.rest.server.servlet.BasicRestResource;
 import org.apache.juneau.rest.server.staticfile.WebJarsMixin;
 import org.apache.juneau.rest.server.terminal.TerminalMixin;
@@ -85,9 +82,6 @@ public class ReleaseRunRest extends BasicRestResource implements RunViewMixin, T
 	 * Start key to the version of the run it started, in submission order. Kept in memory only: it exists to collapse a
 	 * double-submit of one form, not to survive a restart, so the persisted run format is unchanged.
 	 */
-	@SuppressWarnings({
-		"serial" // Anonymous LinkedHashMap subclass is never serialized.
-	})
 	private final Map<String, String> startedByKey = new LinkedHashMap<>() {
 		@Override
 		protected boolean removeEldestEntry(Map.Entry<String, String> eldest) {
diff --git a/src/test/java/org/apache/juneau/releng/log/LogBranchesTest.java b/src/test/java/org/apache/juneau/releng/log/LogBranchesTest.java
index 9af3ac980f..26eaf8c21b 100644
--- a/src/test/java/org/apache/juneau/releng/log/LogBranchesTest.java
+++ b/src/test/java/org/apache/juneau/releng/log/LogBranchesTest.java
@@ -117,6 +117,9 @@ class LogBranchesTest {
 	}
 
 	@Test
+	@SuppressWarnings({
+		"resource" // Mock HttpServletResponse objects are never closed; that responsibility is on the caller/container.
+	})
 	void b01_writerFailureEndsTheStreamQuietly() throws Exception {
 		var servlet = new RunStateSseServlet(v -> Optional.empty(), v -> Optional.empty());
 		var resp = mock(HttpServletResponse.class);
@@ -142,6 +145,9 @@ class LogBranchesTest {
 	}
 
 	@Test
+	@SuppressWarnings({
+		"resource" // Mock HttpServletResponse object is never closed; that responsibility is on the caller/container.
+	})
 	void b03_noInitialSnapshotButABroadcasterTailsUntilInterrupted() throws Exception {
 		var resp = mock(HttpServletResponse.class);
 		when(resp.getWriter()).thenReturn(new PrintWriter(new StringWriter()));
@@ -159,6 +165,9 @@ class LogBranchesTest {
 	}
 
 	@Test
+	@SuppressWarnings({
+		"resource" // Mock HttpServletResponse object is never closed; that responsibility is on the caller/container.
+	})
 	void b04_unsubscribeFailureIsSwallowed() throws Exception {
 		var capture = new StringWriter();
 		var resp = mock(HttpServletResponse.class);
diff --git a/src/test/java/org/apache/juneau/releng/nexus/NexusStagingClientHttpTest.java b/src/test/java/org/apache/juneau/releng/nexus/NexusStagingClientHttpTest.java
index 551f1d52e5..b724f88e5b 100644
--- a/src/test/java/org/apache/juneau/releng/nexus/NexusStagingClientHttpTest.java
+++ b/src/test/java/org/apache/juneau/releng/nexus/NexusStagingClientHttpTest.java
@@ -30,9 +30,6 @@ import org.junit.jupiter.api.Test;
  * Covers the real HTTP transport of {@link NexusStagingClient} against an in-process loopback server, plus
  * the JSON-shape handling in {@code findLatestRepo}/{@code getRepo}.
  */
-@SuppressWarnings({
-	"restriction" // com.sun.net.httpserver is the JDK-supported loopback test server.
-})
 class NexusStagingClientHttpTest {
 
 	private static String repos(String... items) {
@@ -40,6 +37,9 @@ class NexusStagingClientHttpTest {
 	}
 
 	@Test
+	@SuppressWarnings({
+		"resource" // HttpServer is stopped in finally block.
+	})
 	void a01_realTransportSendsAuthHeadersAndBody() throws Exception {
 		var seen = new AtomicReference<String>();
 		var server = HttpServer.create(new InetSocketAddress("127.0.0.1", 0), 0);
@@ -73,6 +73,9 @@ class NexusStagingClientHttpTest {
 	}
 
 	@Test
+	@SuppressWarnings({
+		"resource" // HttpServer is stopped in finally block.
+	})
 	void a02_nonSuccessStatusFails() throws Exception {
 		var server = HttpServer.create(new InetSocketAddress("127.0.0.1", 0), 0);
 		server.createContext("/", ex -> {
@@ -93,6 +96,9 @@ class NexusStagingClientHttpTest {
 	}
 
 	@Test
+	@SuppressWarnings({
+		"resource" // NexusStagingClient is never closed; it does not manage resources that need closing.
+	})
 	void a03_unreachableServerFails() {
 		var client = NexusStagingClient.create("http://127.0.0.1:1", "p", "u", "pw");
 		assertThrows(IllegalStateException.class, () -> client.promote("r1"));
diff --git a/src/test/java/org/apache/juneau/releng/rest/ReleaseRunRestTest.java b/src/test/java/org/apache/juneau/releng/rest/ReleaseRunRestTest.java
index 1b7600e517..c379e7fc68 100644
--- a/src/test/java/org/apache/juneau/releng/rest/ReleaseRunRestTest.java
+++ b/src/test/java/org/apache/juneau/releng/rest/ReleaseRunRestTest.java
@@ -393,7 +393,8 @@ class ReleaseRunRestTest {
 	void b07d_startsWithoutAKeyAreNeverReplays(@TempDir Path dir) {
 		var rest = rest(dir);
 		rest.start(startRequest("9.2.1"));
-		assertEquals(409, assertThrows(Conflict.class, () -> rest.start(startRequest("9.2.1"))).getStatusCode());
+		var again = startRequest("9.2.1");
+		assertEquals(409, assertThrows(Conflict.class, () -> rest.start(again)).getStatusCode());
 	}
 
 	@Test