Minor Improvements:
* Use Empty collections * Unnecessary toString
This commit is contained in:
parent
b71e2fcb83
commit
3c9f1f85e1
|
@ -98,7 +98,7 @@ public class CacheKeyGenerator implements Resolver<URI, String> {
|
|||
if (headers == null) {
|
||||
return "";
|
||||
}
|
||||
final StringBuilder buf = new StringBuilder("");
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
final Header hdr = headers[i];
|
||||
if (i > 0) {
|
||||
|
|
|
@ -121,7 +121,7 @@ class RequestProtocolCompliance {
|
|||
}
|
||||
|
||||
private String buildHeaderFromElements(final List<HeaderElement> outElts) {
|
||||
final StringBuilder newHdr = new StringBuilder("");
|
||||
final StringBuilder newHdr = new StringBuilder();
|
||||
boolean first = true;
|
||||
for(final HeaderElement elt : outElts) {
|
||||
if (!first) {
|
||||
|
|
|
@ -96,7 +96,7 @@ public class AsyncRandomHandler implements AsyncServerExchangeHandler {
|
|||
final String path = uri.getPath();
|
||||
final int slash = path.lastIndexOf('/');
|
||||
if (slash != -1) {
|
||||
final String payload = path.substring(slash + 1, path.length());
|
||||
final String payload = path.substring(slash + 1);
|
||||
final long n;
|
||||
if (!payload.isEmpty()) {
|
||||
try {
|
||||
|
|
|
@ -87,7 +87,7 @@ public class RandomHandler implements HttpRequestHandler {
|
|||
final String path = uri.getPath();
|
||||
final int slash = path.lastIndexOf('/');
|
||||
if (slash != -1) {
|
||||
final String payload = path.substring(slash + 1, path.length());
|
||||
final String payload = path.substring(slash + 1);
|
||||
final long n;
|
||||
if (!payload.isEmpty()) {
|
||||
try {
|
||||
|
|
|
@ -63,6 +63,11 @@ public class MultipartEntityBuilder {
|
|||
private Charset charset;
|
||||
private List<MultipartPart> multipartParts;
|
||||
|
||||
/**
|
||||
* An empty immutable {@code NameValuePair} array.
|
||||
*/
|
||||
private static final NameValuePair[] EMPTY_NAME_VALUE_ARRAY = new NameValuePair[0];
|
||||
|
||||
public static MultipartEntityBuilder create() {
|
||||
return new MultipartEntityBuilder();
|
||||
}
|
||||
|
@ -201,7 +206,7 @@ public class MultipartEntityBuilder {
|
|||
if (charsetCopy != null) {
|
||||
paramsList.add(new BasicNameValuePair("charset", charsetCopy.name()));
|
||||
}
|
||||
final NameValuePair[] params = paramsList.toArray(new NameValuePair[paramsList.size()]);
|
||||
final NameValuePair[] params = paramsList.toArray(EMPTY_NAME_VALUE_ARRAY);
|
||||
|
||||
final ContentType contentTypeCopy;
|
||||
if (contentType != null) {
|
||||
|
|
|
@ -75,13 +75,18 @@ public final class ContentCompressionExec implements ExecChainHandler {
|
|||
private final Lookup<InputStreamFactory> decoderRegistry;
|
||||
private final boolean ignoreUnknown;
|
||||
|
||||
/**
|
||||
* An empty immutable {@code String} array.
|
||||
*/
|
||||
private static final String[] EMPTY_STRING_ARRAY = new String[0];
|
||||
|
||||
public ContentCompressionExec(
|
||||
final List<String> acceptEncoding,
|
||||
final Lookup<InputStreamFactory> decoderRegistry,
|
||||
final boolean ignoreUnknown) {
|
||||
this.acceptEncoding = MessageSupport.format(HttpHeaders.ACCEPT_ENCODING,
|
||||
acceptEncoding != null ? acceptEncoding.toArray(
|
||||
new String[acceptEncoding.size()]) : new String[] {"gzip", "x-gzip", "deflate"});
|
||||
EMPTY_STRING_ARRAY) : new String[] {"gzip", "x-gzip", "deflate"});
|
||||
|
||||
this.decoderRegistry = decoderRegistry != null ? decoderRegistry :
|
||||
RegistryBuilder.<InputStreamFactory>create()
|
||||
|
|
Loading…
Reference in New Issue