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 819d62997fb9 CAMEL-27769: fix ListProperties KEY column truncating
property names with ELLIPSIS_RIGHT (#31131)
819d62997fb9 is described below
commit 819d62997fb9bf30a127fbaf545cc7d5a85acf72
Author: Guillaume Nodet <[email protected]>
AuthorDate: Mon Nov 30 22:13:20 2026 +0100
CAMEL-27769: fix ListProperties KEY column truncating property names with
ELLIPSIS_RIGHT (#31131)
Size the KEY column of `camel get properties` from the longest property key
(15 to 50 characters) instead of from the
terminal budget. With the default width of 120 columns, used when the
output is not a terminal, the column was 15
characters, so any longer key was cut with an ellipsis. LOCATION and VALUE,
and in verbose mode FUNCTION and
ORIGINAL VALUE, get the space that remains. A unit test pins the 120-column
case.
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
---
.../core/commands/process/ListProperties.java | 16 +++++----
.../core/commands/process/ListPropertiesTest.java | 39 ++++++++++++++++++++--
2 files changed, 46 insertions(+), 9 deletions(-)
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListProperties.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListProperties.java
index 2183779081a2..c9fc071c77de 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListProperties.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/ListProperties.java
@@ -151,15 +151,19 @@ public class ListProperties extends ProcessWatchCommand {
return jo;
}).collect(Collectors.toList())));
} else {
- // Flexible columns: LOCATION (80), KEY (50), VALUE (80),
FUNCTION (50), ORIGINAL VALUE (80)
+ // KEY is sized from actual content (clamped 15..50) so
property names are never truncated unless
+ // genuinely longer than 48 characters (maxWidth 50 includes 2
chars of column padding, so content
+ // area is 48). LOCATION and VALUE get whatever terminal space
remains.
// Fixed columns: PID(8)+NAME(30) ~= 38
int tw = terminalWidth();
- int locW = TerminalWidthHelper.flexWidth(tw, 38 + 50 + 80,
TerminalWidthHelper.noBorderOverhead(7), 20, 80);
- int keyW = TerminalWidthHelper.flexWidth(tw, 38 + 80 + 80,
TerminalWidthHelper.noBorderOverhead(7), 15, 50);
- int valW = TerminalWidthHelper.flexWidth(tw, 38 + 80 + 50,
TerminalWidthHelper.noBorderOverhead(7), 20, 80);
- int funcW = TerminalWidthHelper.flexWidth(tw, 38 + 80 + 50 +
80 + 80, TerminalWidthHelper.noBorderOverhead(7),
+ // +2 because ascii-table's maxWidth includes the 2-char
column padding
+ int keyLen = rows.stream().mapToInt(r -> r.key != null ?
r.key.length() : 0).max().orElse(0);
+ int keyW = Math.max(15, Math.min(50, keyLen + 2));
+ int locW = TerminalWidthHelper.flexWidth(tw, 38 + keyW + 80,
TerminalWidthHelper.noBorderOverhead(7), 20, 80);
+ int valW = TerminalWidthHelper.flexWidth(tw, 38 + 80 + keyW,
TerminalWidthHelper.noBorderOverhead(7), 20, 80);
+ int funcW = TerminalWidthHelper.flexWidth(tw, 38 + 80 + keyW +
80 + 80, TerminalWidthHelper.noBorderOverhead(7),
15, 50);
- int origW = TerminalWidthHelper.flexWidth(tw, 38 + 80 + 50 +
80 + 50, TerminalWidthHelper.noBorderOverhead(7),
+ int origW = TerminalWidthHelper.flexWidth(tw, 38 + 80 + keyW +
80 + 50, TerminalWidthHelper.noBorderOverhead(7),
20, 80);
printer().println(AsciiTable.getTable(AsciiTable.NO_BORDERS,
rows, Arrays.asList(
new
Column().header("PID").headerAlign(HorizontalAlign.CENTER).with(r -> r.pid),
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/process/ListPropertiesTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/process/ListPropertiesTest.java
index 54d68276fed4..b1826e4ca9fe 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/process/ListPropertiesTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/process/ListPropertiesTest.java
@@ -79,9 +79,9 @@ class ListPropertiesTest extends ProcessCommandTestSupport {
assertEquals(0, exit);
String output = printer.getOutput();
- // "camel.password" is 14 chars; the KEY column minimum is 15 but
may truncate with ellipsis
- // in narrow terminal environments — check the prefix that always
survives truncation
- assertTrue(output.contains("camel.pass"), "Should show sensitive
property key (possibly truncated)");
+ // "camel.password" is 14 chars; KEY is now sized from content
(clamped 15..50),
+ // so the full key always appears (no truncation)
+ assertTrue(output.contains("camel.pass"), "Should show sensitive
property key");
assertTrue(output.contains("xxxxxx"), "Sensitive value should be
masked");
assertFalse(output.contains("secret"), "Raw sensitive value should
not be printed");
}
@@ -145,6 +145,39 @@ class ListPropertiesTest extends ProcessCommandTestSupport
{
}
}
+ @Test
+ void testKeyNotTruncatedAtDefaultTerminalWidth() throws Exception {
+ // CAMEL-27769: at terminal width 120 (the no-terminal default) the
KEY column was sized to 15 by the old
+ // budget math, causing property names longer than ~13 chars to be
cut. The fix sizes KEY from content.
+ JsonObject root = new JsonObject();
+ root.put("context", contextObj());
+ root.put("properties", propertyContainer("properties",
+ property("test.jbang.marker", "value1", "value1", false,
"properties:app", "application.properties")));
+ writeStatusFile(TEST_PID, root);
+
+ // anonymous subclass that simulates a 120-column terminal (the
no-terminal fallback width)
+ ListProperties command = new
CamelJBangMain().withPrinter(printer).command(new ListProperties() {
+ @Override
+ protected int terminalWidth() {
+ return 120;
+ }
+ });
+ command.sort = "pid";
+
+ try (MockedStatic<ProcessHandle> mocked =
mockStatic(ProcessHandle.class)) {
+ ProcessHandle ph = mockProcessHandle(TEST_PID);
+ ProcessHandle currentHandle = mockCurrentHandle();
+ mocked.when(ProcessHandle::current).thenReturn(currentHandle);
+ mocked.when(ProcessHandle::allProcesses).thenAnswer(inv ->
Stream.of(ph));
+
+ int exit = command.doCall();
+
+ assertEquals(0, exit);
+ assertTrue(printer.getOutput().contains("test.jbang.marker"),
+ "Full property key must appear; got: " +
printer.getOutput());
+ }
+ }
+
@Test
void testPropertiesFileLocationShown() throws Exception {
JsonObject root = new JsonObject();