Polishing
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user