Skip to content
Permalink
Browse files
Minor Improvements:
* Use Empty collections
* Unnecessary toString
  • Loading branch information
arturobernalg authored and ok2c committed Jan 26, 2021
1 parent b71e2fc commit 3c9f1f85e1a17338281f97f153ca6b1804b2d664
Showing 6 changed files with 16 additions and 6 deletions.
@@ -98,7 +98,7 @@ private String getFullHeaderValue(final Header[] headers) {
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 @@ private void stripOtherFreshnessDirectivesWithNoCache(final HttpRequest request)
}

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 void handleRequest(
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 void handle(final ClassicHttpRequest request,
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 @@ MultipartFormEntity buildEntity() {
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()

0 comments on commit 3c9f1f8

Please sign in to comment.