-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: messagingIssues in messaging modules (jms, messaging)Issues in messaging modules (jms, messaging)type: enhancementA general enhancementA general enhancement
Milestone
Description
Luke Jackson opened SPR-11268 and commented
In the following GenericMessage constructor:
public GenericMessage(T payload, Map<String, Object> headers) {
Assert.notNull(payload, "payload must not be null");
if (headers == null) {
headers = new HashMap<String, Object>();
}
else {
headers = new HashMap<String, Object>(headers);
}
this.headers = new MessageHeaders(headers);
this.payload = payload;
}
The headers are being copied (presumably to ensure immutability).
However MessageHeaders itself copies the header map provided to it, which results in an unnecessary double copying of the headers map:
public MessageHeaders(Map<String, Object> headers) {
this.headers = (headers != null) ? new HashMap<String, Object>(headers) : new HashMap<String, Object>();
IdGenerator generatorToUse = (idGenerator != null) ? idGenerator : defaultIdGenerator;
this.headers.put(ID, generatorToUse.generateId());
this.headers.put(TIMESTAMP, new Long(System.currentTimeMillis()));
}
Affects: 4.0 GA
Referenced from: commits 3b14e97
Metadata
Metadata
Assignees
Labels
in: messagingIssues in messaging modules (jms, messaging)Issues in messaging modules (jms, messaging)type: enhancementA general enhancementA general enhancement