INT-2837 Fix Accept Hdr for Serializable Response
When the expected-response-type was Serializable, no Accept: header was added. The SerializingHttpMessageConverter overrides canRead() from the superclass. The superclass method allows null in the mediaType parameter to return true. RestTemplate.AcceptHeaderRequestCallback calls canRead() with null in the mediaType, preventing the Accept header from being completed. Remove the overridden method. INT-2837 Disable Java Serialization over Http Previously, Java serialization was enabled by default by adding the SerializingHttpMessageConverter to the converter lists (inbound and outbound endpoints). However, there was a problem in that the Accept header was not set properly on outbound requests. Correcting the header could cause other side effects, such as existing JSON applications using Java serialization instead. It was felt that it would be safest to disable Java serialization by default, while retaining the ability to use Java serialization by explicitly configuring the message converter. Update tests to deal with the fact the converter is not configured by default. INT-2837 Fix Schema Version in Test Inadvertently added a spring 3.1 schema version.
This commit is contained in:
committed by
Mark Fisher
parent
4ce08ad6dc
commit
7ef66e2e3f
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,8 +31,9 @@ import org.springframework.util.FileCopyUtils;
|
||||
|
||||
/**
|
||||
* An {@link HttpMessageConverter} implementation for {@link Serializable} instances.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
public class SerializingHttpMessageConverter extends AbstractHttpMessageConverter<Serializable> {
|
||||
@@ -51,11 +52,6 @@ public class SerializingHttpMessageConverter extends AbstractHttpMessageConverte
|
||||
return Serializable.class.isAssignableFrom(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRead(Class<?> clazz, MediaType mediaType) {
|
||||
return (Serializable.class.isAssignableFrom(clazz) && APPLICATION_JAVA_SERIALIZED_OBJECT.includes(mediaType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrite(Class<?> clazz, MediaType mediaType) {
|
||||
return (Serializable.class.isAssignableFrom(clazz) && APPLICATION_JAVA_SERIALIZED_OBJECT.includes(mediaType));
|
||||
|
||||
@@ -54,7 +54,6 @@ import org.springframework.integration.context.OrderlyShutdownCapable;
|
||||
import org.springframework.integration.expression.ExpressionUtils;
|
||||
import org.springframework.integration.gateway.MessagingGatewaySupport;
|
||||
import org.springframework.integration.http.converter.MultipartAwareFormHttpMessageConverter;
|
||||
import org.springframework.integration.http.converter.SerializingHttpMessageConverter;
|
||||
import org.springframework.integration.http.multipart.MultipartHttpInputMessage;
|
||||
import org.springframework.integration.http.support.DefaultHttpHeaderMapper;
|
||||
import org.springframework.integration.mapping.HeaderMapper;
|
||||
@@ -147,7 +146,6 @@ public abstract class HttpRequestHandlingEndpointSupport extends MessagingGatewa
|
||||
public HttpRequestHandlingEndpointSupport(boolean expectReply) {
|
||||
this.expectReply = expectReply;
|
||||
this.messageConverters.add(new MultipartAwareFormHttpMessageConverter());
|
||||
this.messageConverters.add(new SerializingHttpMessageConverter());
|
||||
this.messageConverters.add(new ByteArrayHttpMessageConverter());
|
||||
this.messageConverters.add(new StringHttpMessageConverter());
|
||||
this.messageConverters.add(new ResourceHttpMessageConverter());
|
||||
|
||||
@@ -51,7 +51,6 @@ import org.springframework.integration.MessageHandlingException;
|
||||
import org.springframework.integration.MessagingException;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.http.converter.SerializingHttpMessageConverter;
|
||||
import org.springframework.integration.http.support.DefaultHttpHeaderMapper;
|
||||
import org.springframework.integration.mapping.HeaderMapper;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
@@ -152,7 +151,6 @@ public class HttpRequestExecutingMessageHandler extends AbstractReplyProducingMe
|
||||
public HttpRequestExecutingMessageHandler(Expression uriExpression, RestTemplate restTemplate) {
|
||||
Assert.notNull(uriExpression, "URI Expression is required");
|
||||
this.restTemplate = (restTemplate == null ? new RestTemplate() : restTemplate);
|
||||
this.restTemplate.getMessageConverters().add(0, new SerializingHttpMessageConverter());
|
||||
this.uriExpression = uriExpression;
|
||||
StandardEvaluationContext sec = new StandardEvaluationContext();
|
||||
sec.addPropertyAccessor(new MapAccessor());
|
||||
|
||||
Reference in New Issue
Block a user