Skip to content

Commit 52f5801

Browse files
committed
Polishing
1 parent 271fe4f commit 52f5801

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessagingTemplate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public long getSendTimeout() {
108108
public void send(Message<?> message) {
109109
SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(message);
110110
String destination = headers.getDestination();
111-
destination = (destination != null) ? destination : getRequiredDefaultDestination();
111+
destination = (destination != null ? destination : getRequiredDefaultDestination());
112112
doSend(destination, message);
113113
}
114114

@@ -131,7 +131,6 @@ protected void doSend(String destination, Message<?> message) {
131131
}
132132

133133

134-
135134
@Override
136135
public void convertAndSendToUser(String user, String destination, Object payload) throws MessagingException {
137136
convertAndSendToUser(user, destination, payload, (MessagePostProcessor) null);
@@ -160,6 +159,7 @@ public void convertAndSendToUser(String user, String destination, Object payload
160159
super.convertAndSend(this.userDestinationPrefix + user + destination, payload, headers, postProcessor);
161160
}
162161

162+
163163
/**
164164
* Creates a new map and puts the given headers under the key
165165
* {@link org.springframework.messaging.support.NativeMessageHeaderAccessor#NATIVE_HEADERS NATIVE_HEADERS}.

spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525

2626
import org.apache.commons.logging.Log;
2727
import org.apache.commons.logging.LogFactory;
28+
2829
import org.springframework.http.HttpHeaders;
2930
import org.springframework.http.HttpInputMessage;
3031
import org.springframework.http.HttpOutputMessage;
@@ -169,11 +170,12 @@ public final void write(final T t, MediaType contentType, HttpOutputMessage outp
169170

170171
final HttpHeaders headers = outputMessage.getHeaders();
171172
if (headers.getContentType() == null) {
173+
MediaType contentTypeToUse = contentType;
172174
if (contentType == null || contentType.isWildcardType() || contentType.isWildcardSubtype()) {
173-
contentType = getDefaultContentType(t);
175+
contentTypeToUse = getDefaultContentType(t);
174176
}
175-
if (contentType != null) {
176-
headers.setContentType(contentType);
177+
if (contentTypeToUse != null) {
178+
headers.setContentType(contentTypeToUse);
177179
}
178180
}
179181
if (headers.getContentLength() == -1) {
@@ -182,10 +184,10 @@ public final void write(final T t, MediaType contentType, HttpOutputMessage outp
182184
headers.setContentLength(contentLength);
183185
}
184186
}
187+
185188
if (outputMessage instanceof StreamingHttpOutputMessage) {
186189
StreamingHttpOutputMessage streamingOutputMessage =
187190
(StreamingHttpOutputMessage) outputMessage;
188-
189191
streamingOutputMessage.setBody(new StreamingHttpOutputMessage.Body() {
190192
@Override
191193
public void writeTo(final OutputStream outputStream) throws IOException {
@@ -194,7 +196,6 @@ public void writeTo(final OutputStream outputStream) throws IOException {
194196
public OutputStream getBody() throws IOException {
195197
return outputStream;
196198
}
197-
198199
@Override
199200
public HttpHeaders getHeaders() {
200201
return headers;
@@ -256,7 +257,7 @@ protected abstract T readInternal(Class<? extends T> clazz, HttpInputMessage inp
256257
/**
257258
* Abstract template method that writes the actual body. Invoked from {@link #write}.
258259
* @param t the object to write to the output message
259-
* @param outputMessage the message to write to
260+
* @param outputMessage the HTTP output message to write to
260261
* @throws IOException in case of I/O errors
261262
* @throws HttpMessageNotWritableException in case of conversion errors
262263
*/

0 commit comments

Comments
 (0)