ammachado opened a new pull request, #28650:
URL: https://github.com/apache/camel/pull/28650

   # Description
   
   [CAMEL-26391](https://issues.apache.org/jira/browse/CAMEL-26391), tier 1 
item #3 (traits part) of 
[CAMEL-25132](https://issues.apache.org/jira/browse/CAMEL-25132).
   
   Every `MessageSupport` allocated an `EnumMap<MessageTrait, Object>` for its 
traits, and an exchange has one to three messages. Traits are only set for 
redelivery (by some consumers), data types (when `useDataType` is enabled or a 
data type is set explicitly) and attachments, so most messages never use the 
map. This change creates it when the first trait is set. The field is private 
and only used by the trait methods of `MessageSupport`.
   
   Measured locally (JDK 25 on macOS, single thread, after warm-up, 
`ThreadMXBean` allocated bytes): `new DefaultMessage` allocates 48 B instead of 
120 B.
   
   The field is no longer `final`. Messages were not thread safe before either 
(`EnumMap` is not), so this does not add a new risk.
   
   New `MessageSupportTraitsTest` (camel-support had no test for these 
methods). It covers reading and removing traits before any is set, a trait set 
with a `null` payload still counting as set, `reset`, and `copyFrom` keeping 
the data type and copying the attachments, also for a message without traits. 
These tests pass before and after the change.
   
   Verified: 10 tests in camel-support (`*Message*Test`, `*DataType*Test`) and 
279 in camel-core (`*Message*Test`, `*DataType*Test`, `*Attachment*Test`, 
`*Transformer*Test`, `*Redeliver*Test`, `*Copy*Test`, `*InputType*Test`, 
`*OutputType*Test`). The 2 skipped tests are `*ManualTest` stress tests.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
     Not from the root folder: I built and installed the changed module 
(camel-support), ran `mvn formatter:format impsort:sort` on the changed 
modules, and `git status` was clean afterwards.
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
   
   The code and this description were written with Claude Code (Claude Opus 
5.5) and reviewed by me.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code) on behalf of 
Adriano Machado (@ammachado)
   
   _This was generated by an AI agent and may contain inaccuracies. Please 
verify before relying on it._
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to