[ 
https://issues.apache.org/jira/browse/CAMEL-24499?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andrea Cosentino updated CAMEL-24499:
-------------------------------------
    Description: 
{{RouteEndpointInfo}} annotates its properties map so the 
{{route.start.exception}} route property is not
serialized:

{code:java}
@JsonIgnoreProperties(value = {"route.start.exception"})
private final Map<String, Object> properties;
{code}

{{RouteDetailsEndpointInfo}}, which extends it, re-declares the same field 
without the annotation, plus a
{{getProperties()}} override:

{code:java}
public static class RouteDetailsEndpointInfo extends RouteEndpointInfo {
    @JsonProperty("details")
    private RouteDetails routeDetails;
    private final Map<String, Object> properties;
{code}

(CamelRoutesEndpoint:279)

The shadowing field escapes the filter, so the detail operation serializes the 
property the base view omits.
Both the annotation and the shadowing field were introduced in the same commit 
under CAMEL-20993, so the
filter was clearly intended - the subclass field simply bypasses it.

{{route.start.exception}} holds the {{Throwable}} itself 
({{InternalRouteStartupManager}} puts it there), so
Jackson serializes the whole object graph: nested causes, every stack frame 
with class/file/line, classloader
names and the JDK version.

*Proposal*

Remove the shadowing {{properties}} field and its getter from 
{{RouteDetailsEndpointInfo}} and reuse the
annotated base-class property. The public {{getProperties()}} stays available 
on the subclass by inheritance,
so this is source- and binary-compatible.

Add a regression test asserting a route with a start exception does not surface 
it through the detail
operation, establishing the asynchronous start-failure precondition with 
Awaitility first so the assertion
cannot pass vacuously.

*Scope note*

This issue originally also proposed restricting the health-check 
{{error.stacktrace}} detail to the {{full}}
exposure level. That was dropped during review of the PR: CAMEL-18832 
deliberately placed the error block
outside the exposure-level branch to align the Spring Boot output with 
camel-microprofile-health, whose
{{testExposureLevelDefault}} asserts {{error.stacktrace}} is present at the 
default level. Changing it only in
Spring Boot would diverge the two runtimes. The unauthenticated-exposure 
concern is better addressed by
CAMEL-24498, which is where the observability starter raises 
{{camel.health.exposure-level}} to {{full}} and
{{show-details}} to {{always}}. A separate defect found during the same review 
is tracked as CAMEL-24512.

----
_This issue was drafted by Claude Code on behalf of Andrea Cosentino._

  was:
Two independent spots in the actuator output emit more detail than the 
surrounding code intends.

*1. Health details always include a full stack trace*

{code:java}
result.getError().ifPresent(error -> {
    if (error.getMessage() != null) {
        builder.withDetail("error.message", error.getMessage());
    }
    final StringWriter stackTraceWriter = new StringWriter();
    try (final PrintWriter pw = new PrintWriter(stackTraceWriter, true)) {
        error.printStackTrace(pw);
        data.put("error.stacktrace", stackTraceWriter.toString());
    }
});
{code}

(CamelHealthHelper:69)

The block sits outside the {{exposureLevel.equals("full")}} branch a few lines 
above, so the stack trace is added at the {{default}} exposure level too. 
Spring Boot's own indicators expose exception class and message, not the trace.

*2. Route detail view drops the properties filter (regression from CAMEL-20993)*

{{RouteEndpointInfo}} annotates its properties map:

{code:java}
@JsonIgnoreProperties(value = {"route.start.exception"})
private final Map<String, Object> properties;
{code}

but {{RouteDetailsEndpointInfo}}, which extends it, re-declares the field 
without the annotation:

{code:java}
public static class RouteDetailsEndpointInfo extends RouteEndpointInfo {
    @JsonProperty("details")
    private RouteDetails routeDetails;
    private final Map<String, Object> properties;
{code}

(CamelRoutesEndpoint:279)

Both the annotation and the shadowing field were introduced in the same commit 
under CAMEL-20993, so the filter was clearly intended - the subclass field 
simply escapes it, and the detail operation serialises the property the base 
view filters.

*Proposal*

- Restrict {{error.stacktrace}} to the {{full}} exposure level, or replace it 
with exception class + message and keep the full trace in the server log.
- Remove the shadowing {{properties}} field and getter from 
{{RouteDetailsEndpointInfo}} and reuse the annotated base-class property.
- Add a test asserting a route with a start exception does not surface it 
through the detail operation.

----
_This issue was drafted by Claude Code on behalf of Andrea Cosentino._

        Summary: camel-spring-boot - route detail view bypasses the 
route.start.exception serialization filter  (was: camel-spring-boot - actuator 
health and route detail views emit more than the configured exposure level)

> camel-spring-boot - route detail view bypasses the route.start.exception 
> serialization filter
> ---------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-24499
>                 URL: https://issues.apache.org/jira/browse/CAMEL-24499
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-spring-boot
>            Reporter: Andrea Cosentino
>            Assignee: Andrea Cosentino
>            Priority: Minor
>             Fix For: 4.23.0
>
>
> {{RouteEndpointInfo}} annotates its properties map so the 
> {{route.start.exception}} route property is not
> serialized:
> {code:java}
> @JsonIgnoreProperties(value = {"route.start.exception"})
> private final Map<String, Object> properties;
> {code}
> {{RouteDetailsEndpointInfo}}, which extends it, re-declares the same field 
> without the annotation, plus a
> {{getProperties()}} override:
> {code:java}
> public static class RouteDetailsEndpointInfo extends RouteEndpointInfo {
>     @JsonProperty("details")
>     private RouteDetails routeDetails;
>     private final Map<String, Object> properties;
> {code}
> (CamelRoutesEndpoint:279)
> The shadowing field escapes the filter, so the detail operation serializes 
> the property the base view omits.
> Both the annotation and the shadowing field were introduced in the same 
> commit under CAMEL-20993, so the
> filter was clearly intended - the subclass field simply bypasses it.
> {{route.start.exception}} holds the {{Throwable}} itself 
> ({{InternalRouteStartupManager}} puts it there), so
> Jackson serializes the whole object graph: nested causes, every stack frame 
> with class/file/line, classloader
> names and the JDK version.
> *Proposal*
> Remove the shadowing {{properties}} field and its getter from 
> {{RouteDetailsEndpointInfo}} and reuse the
> annotated base-class property. The public {{getProperties()}} stays available 
> on the subclass by inheritance,
> so this is source- and binary-compatible.
> Add a regression test asserting a route with a start exception does not 
> surface it through the detail
> operation, establishing the asynchronous start-failure precondition with 
> Awaitility first so the assertion
> cannot pass vacuously.
> *Scope note*
> This issue originally also proposed restricting the health-check 
> {{error.stacktrace}} detail to the {{full}}
> exposure level. That was dropped during review of the PR: CAMEL-18832 
> deliberately placed the error block
> outside the exposure-level branch to align the Spring Boot output with 
> camel-microprofile-health, whose
> {{testExposureLevelDefault}} asserts {{error.stacktrace}} is present at the 
> default level. Changing it only in
> Spring Boot would diverge the two runtimes. The unauthenticated-exposure 
> concern is better addressed by
> CAMEL-24498, which is where the observability starter raises 
> {{camel.health.exposure-level}} to {{full}} and
> {{show-details}} to {{always}}. A separate defect found during the same 
> review is tracked as CAMEL-24512.
> ----
> _This issue was drafted by Claude Code on behalf of Andrea Cosentino._



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to