This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 145871e9c5b0 CAMEL-23912: Address review feedback on ThemeTest fix
145871e9c5b0 is described below
commit 145871e9c5b0db5a95ec2a6283520af9bc2b4c7e
Author: Guillaume Nodet <[email protected]>
AuthorDate: Tue Jul 7 07:48:08 2026 +0200
CAMEL-23912: Address review feedback on ThemeTest fix
Follow-up to PR #24475 addressing post-merge review feedback: null-check
Theme.class.getClassLoader() to avoid NPE for bootstrap-loaded classes,
soften javadoc wording to accurately describe the TCCL fallback behavior,
and revert ConcurrentHashMap to HashMap since all CACHE access is already
inside synchronized methods.
Closes #24482
Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
.../apache/camel/dsl/jbang/core/commands/tui/Theme.java | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/Theme.java
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/Theme.java
index 6b62c45fa96a..e3c666174523 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/Theme.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/Theme.java
@@ -20,10 +20,10 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
import dev.tamboui.css.Styleable;
import dev.tamboui.css.engine.StyleEngine;
@@ -73,7 +73,7 @@ final class Theme {
private static final Style FALLBACK_MCP_DOWN =
Style.EMPTY.fg(Color.LIGHT_RED);
private static final Color FALLBACK_ZEBRA = Color.rgb(0x1C, 0x1C, 0x1C);
- private static final Map<String, Style> CACHE = new ConcurrentHashMap<>();
+ private static final Map<String, Style> CACHE = new HashMap<>();
private static boolean initialized;
private static boolean fallbackLogged;
@@ -262,14 +262,19 @@ final class Theme {
}
/**
- * Reads a CSS resource from the classpath using this class's own
classloader, which is guaranteed to have access to
- * project resources regardless of classloader hierarchy.
+ * Reads a CSS resource from the classpath using this class's own
classloader, which in the normal Camel
+ * class-loading hierarchy has access to project resources. Falls back to
the thread-context classloader when the
+ * primary lookup returns null (e.g., in OSGi or custom classloader
setups) or when the class is bootstrap-loaded.
*/
private static String loadCssResource(String path) throws IOException {
- InputStream is =
Theme.class.getClassLoader().getResourceAsStream(path);
+ InputStream is = null;
+ ClassLoader cl = Theme.class.getClassLoader();
+ if (cl != null) {
+ is = cl.getResourceAsStream(path);
+ }
if (is == null) {
// Fallback to the thread context classloader in case the class's
own classloader
- // doesn't have visibility (e.g., in OSGi or custom classloader
setups).
+ // doesn't have visibility or is null (bootstrap-loaded classes).
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
if (tccl != null) {
is = tccl.getResourceAsStream(path);