Skip to content

MessageHeaderAccessor.getContentType() should get deal with String value too, rather than rely only casting to MimeType [SPR-12730] #17327

@spring-projects-issues

Description

@spring-projects-issues

Artem Bilan opened SPR-12730 and commented

See the issue in the linked SO question.

Spring Integration AMQP populates content-type headers from AMQP Message headers as String. There are other components in Spring Integration which do the same, e.g. ObjectToJsonTransformer.

From other side AmqpMessageHeaderAccessor has this code:

@Override
public MimeType getContentType() {
	Object value = getHeader(AmqpHeaders.CONTENT_TYPE);
	if (value != null && value instanceof String) {
	return MimeType.valueOf((String) value);
	}
	else {
	return super.getContentType();
        }
}

Looks like would be better to move this code to the core MessageHeaderAccessor and allow for end-application to avoid this transformation:

.setHeader(MessageHeaders.CONTENT_TYPE, amqpMessageHeaderAccessor.getContentType())

Or manual MimeType.valueOf() invocation.

For me this is minor change, so can be backported.


Affects: 4.1.4

Reference URL: http://stackoverflow.com/questions/28587286/having-trouble-with-contenttype-going-from-amqp-to-stomp-message

Referenced from: commits dbd353b, 55a14eb

Metadata

Metadata

Assignees

Labels

in: messagingIssues in messaging modules (jms, messaging)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions