Polishing

This commit is contained in:
Juergen Hoeller 2017-09-08 16:56:22 +02:00
parent aa4ae7a750
commit fd0132c7e6
4 changed files with 15 additions and 9 deletions

View File

@ -49,20 +49,22 @@ public class MockPart implements Part {
/** /**
* Constructor for a part with byte[] content only. * Constructor for a part with byte[] content only.
* @see #getHeaders()
*/ */
public MockPart(String name, byte[] content) { public MockPart(String name, @Nullable byte[] content) {
this(name, null, content); this(name, null, content);
} }
/** /**
* Constructor for a part with a filename. * Constructor for a part with a filename and streamed content.
* @see #getHeaders()
*/ */
public MockPart(String name, @Nullable String filename, InputStream content) throws IOException { public MockPart(String name, @Nullable String filename, InputStream content) throws IOException {
this(name, filename, FileCopyUtils.copyToByteArray(content)); this(name, filename, FileCopyUtils.copyToByteArray(content));
} }
/** /**
* Constructor for a part with byte[] content only. * Constructor for a part with a filename and byte[] content.
* @see #getHeaders() * @see #getHeaders()
*/ */
private MockPart(String name, @Nullable String filename, @Nullable byte[] content) { private MockPart(String name, @Nullable String filename, @Nullable byte[] content) {

View File

@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import javax.servlet.http.Part; import javax.servlet.http.Part;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
@ -27,7 +28,6 @@ import org.springframework.http.MediaType;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
/** /**
* Mock implementation of {@code javax.servlet.http.Part}. * Mock implementation of {@code javax.servlet.http.Part}.
* *
@ -47,20 +47,22 @@ public class MockPart implements Part {
/** /**
* Constructor for a part with byte[] content only. * Constructor for a part with byte[] content only.
* @see #getHeaders()
*/ */
public MockPart(String name, byte[] content) { public MockPart(String name, byte[] content) {
this(name, null, content); this(name, null, content);
} }
/** /**
* Constructor for a part with a filename. * Constructor for a part with a filename and streamed content.
* @see #getHeaders()
*/ */
public MockPart(String name, String filename, InputStream content) throws IOException { public MockPart(String name, String filename, InputStream content) throws IOException {
this(name, filename, FileCopyUtils.copyToByteArray(content)); this(name, filename, FileCopyUtils.copyToByteArray(content));
} }
/** /**
* Constructor for a part with byte[] content only. * Constructor for a part with a filename and byte[] content.
* @see #getHeaders() * @see #getHeaders()
*/ */
private MockPart(String name, String filename, byte[] content) { private MockPart(String name, String filename, byte[] content) {
@ -105,7 +107,8 @@ public class MockPart implements Part {
@Override @Override
public Collection<String> getHeaders(String name) { public Collection<String> getHeaders(String name) {
return this.headers.get(name); Collection<String> headerValues = this.headers.get(name);
return (headerValues != null ? headerValues : Collections.emptyList());
} }
@Override @Override

View File

@ -146,6 +146,7 @@ public interface ClientResponse extends Closeable {
@Override @Override
void close(); void close();
/** /**
* Represents the headers of the HTTP response. * Represents the headers of the HTTP response.
* @see ClientResponse#headers() * @see ClientResponse#headers()
@ -175,6 +176,6 @@ public interface ClientResponse extends Closeable {
* Return the headers as a {@link HttpHeaders} instance. * Return the headers as a {@link HttpHeaders} instance.
*/ */
HttpHeaders asHttpHeaders(); HttpHeaders asHttpHeaders();
} }
} }

View File

@ -295,7 +295,7 @@ public abstract class AbstractHttpSockJsSession extends AbstractSockJsSession {
synchronized (this.responseLock) { synchronized (this.responseLock) {
this.messageCache.add(message); this.messageCache.add(message);
if (logger.isTraceEnabled()) { if (logger.isTraceEnabled()) {
logger.trace(this.messageCache.size() + " message(s) to flush in session " + this.getId()); logger.trace(this.messageCache.size() + " message(s) to flush in session " + getId());
} }
if (isActive() && this.readyToSend) { if (isActive() && this.readyToSend) {
if (logger.isTraceEnabled()) { if (logger.isTraceEnabled()) {