Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused Log object from MessageHeaderAccessor [SPR-15045] #19611

spring-issuemaster opened this issue Dec 22, 2016 · 1 comment


Copy link

commented Dec 22, 2016

Gary Russell opened SPR-15045 and commented

While investigating a Spring Integration performance issue, I found an O(n^2) search which is accessing a message header using new MessageHeaderAccessor(message).

We will fix the search, but profiling indicates the Log field initialization is very expensive (see attachment).

This test illustrates the issue:

public void test() {
	Message<?> m = MessageBuilder.withPayload("foo").setHeader("foo", "bar").build();
	Object header = null;
	StopWatch watch = new StopWatch();
	for (int i = 0; i < 10000000; i++) {
		header = new MessageHeaderAccessor(m).getHeader("foo");
	for (int i = 0; i < 10000000; i++) {
		header = m.getHeaders().get("foo");
	TaskInfo[] taskInfo = watch.getTaskInfo();
	System.out.println("accessor: " + taskInfo[0].getTimeMillis() + " raw: " + taskInfo[1].getTimeMillis());

accessor: 5019 raw: 28

Perhaps consider a static final Log field (with the loss of customization by subclasses).

With the N^2 code, 10k records were processed in 31 seconds; changing the code to access the header directly (instead of via the accessor) reduced the 31 seconds to 4 seconds.

Affects: 4.3.4, 5.0 M3


Issue Links:

  • INT-4195 O(n) Search in SequenceAwareMessageGroup Prohibitive

Referenced from: commits fa2bfdd, 5c48daa


This comment has been minimized.

Copy link
Collaborator Author

commented Dec 22, 2016

Juergen Hoeller commented

It turns out that this Log object isn't even used anywhere, not in MessageHeaderAccessor itself and not in any of our subclasses either! I'm simply going to drop it, not only in 5.0 M4 but also in 4.3.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.