shashank created CAMEL-26714:
--------------------------------

             Summary: camel-sanitizer - exchange sanitizer module with rule R1 
(the callback of a step is called exactly once) and a JUnit extension
                 Key: CAMEL-26714
                 URL: https://issues.apache.org/jira/browse/CAMEL-26714
             Project: Camel
          Issue Type: Improvement
          Components: camel-core
            Reporter: shashank
            Assignee: shashank


Step 2 of the order of work of the exchange sanitizer design 
({{design/exchange-sanitizer.adoc}}, CAMEL-26630), built on the step listener 
SPI of step 1 (CAMEL-26688).

*What it adds*
* A new module {{camel-sanitizer}} (next to {{camel-chaos}}) with a 
{{ContextServicePlugin}}, as chaos has. It installs only with profile {{dev}}, 
{{camel.sanitizer.enabled=true}}, or for a context built by a test marked by 
the JUnit extension, and never with profile {{prod}} (checked first). When it 
installs it logs a WARN that it is on.
* Rule R1: each time the processor of a step is called (each attempt, also each 
redelivery), its callback must be called exactly once, and {{process}} must not 
throw. R1 reports, at the moment it happens:
** *completed twice*: the callback of a call is called a second time, with the 
stack and thread of the first and the second call;
** *threw before calling the callback*: {{process(exchange, callback)}} throws 
and the callback has not been called (also a processor that throws after it 
called its callback);
** *callback after the processor threw*.
* The report in the log at WARN (ids, route, step, processor, threads and 
stacks; never bodies or headers), and a report when the context stops.
* The options of the design that apply to R1 ({{camel.sanitizer.enabled}}, 
{{checks}}, {{stackDepth}}, {{reportOnShutdown}}).
* A JUnit extension, {{@CamelSanitizer}}, that turns the sanitizer on for the 
contexts a test builds and fails the test with the first violation and the full 
report, plus {{@ExpectSanitizerViolation}} for tests that break a rule on 
purpose. It uses only the JUnit Jupiter extension API, so it works with 
camel-test-junit5, camel-test-junit6 and plain camel-core tests, and lets users 
check their own processors and components.
* The CI switch of the design.

*Validation in the pull request, as the design asks:* R1 reports the bugs it 
was derived from (CAMEL-25095 and CAMEL-25122 as completed twice; CAMEL-26430, 
CAMEL-26445, CAMEL-26446, CAMEL-26461 and CAMEL-26464 as threw before calling 
the callback, and CAMEL-26446 also as a callback after the throw) when their 
fixes are reverted on main; tests with user processors that break the contract 
fail with a report naming their class; it reports nothing on the camel-core 
test suite of main; and a small TLA+ model of the sanitizer's own records shows 
no false report and no missed violation.

Not in this issue (later steps of CAMEL-26630): R1 "still pending", the on 
completion listener and R2, R3, R4, the dev console and {{camel get sanitizer}}.

_Filed with Claude Code on behalf of allthingssecurity._



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to