Skip to content

Commit

Permalink
diamond
Browse files Browse the repository at this point in the history
  • Loading branch information
slandelle committed Feb 21, 2015
1 parent 5c6fa8e commit 706cd8e
Show file tree
Hide file tree
Showing 65 changed files with 235 additions and 235 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,9 @@ public static class Builder {
private String userAgent = defaultUserAgent();
private ExecutorService applicationThreadPool;
private Realm realm;
private final List<RequestFilter> requestFilters = new LinkedList<RequestFilter>();
private final List<ResponseFilter> responseFilters = new LinkedList<ResponseFilter>();
private final List<IOExceptionFilter> ioExceptionFilters = new LinkedList<IOExceptionFilter>();
private final List<RequestFilter> requestFilters = new LinkedList<>();
private final List<ResponseFilter> responseFilters = new LinkedList<>();
private final List<IOExceptionFilter> ioExceptionFilters = new LinkedList<>();
private int maxRequestRetry = defaultMaxRequestRetry();
private boolean disableUrlEncodingForBoundRequests = defaultDisableUrlEncodingForBoundRequests();
private int ioThreadMultiplier = defaultIoThreadMultiplier();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public AsyncHttpClientConfigBean() {
}

void configureFilters() {
requestFilters = new LinkedList<RequestFilter>();
responseFilters = new LinkedList<ResponseFilter>();
ioExceptionFilters = new LinkedList<IOExceptionFilter>();
requestFilters = new LinkedList<>();
responseFilters = new LinkedList<>();
ioExceptionFilters = new LinkedList<>();
}

void configureDefaults() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,12 @@ public <T> ListenableFuture<T> executeRequest(Request request, AsyncHandler<T> h
return httpProvider.execute(request, handler);

} else {
FilterContext<T> fc = new FilterContext.FilterContextBuilder<T>().asyncHandler(handler).request(request).build();
FilterContext<T> fc = new FilterContext.FilterContextBuilder<>().asyncHandler(handler).request(request).build();
try {
fc = preProcessRequest(fc);
} catch (Exception e) {
handler.onThrowable(e);
return new ListenableFuture.CompletedFailure<T>("preProcessRequest failed", e);
return new ListenableFuture.CompletedFailure<>("preProcessRequest failed", e);
}

return httpProvider.execute(fc.getRequest(), fc.getAsyncHandler());
Expand Down Expand Up @@ -273,7 +273,7 @@ private <T> FilterContext<T> preProcessRequest(FilterContext<T> fc) throws Filte
builder.setHeader("Range", "bytes=" + request.getRangeOffset() + "-");
request = builder.build();
}
fc = new FilterContext.FilterContextBuilder<T>(fc).request(request).build();
fc = new FilterContext.FilterContextBuilder<>(fc).request(request).build();
return fc;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
* original case in the appropriate methods (e.g. {@link FluentCaseInsensitiveStringsMap#keySet()}).
*/
public class FluentCaseInsensitiveStringsMap implements Map<String, List<String>>, Iterable<Map.Entry<String, List<String>>> {
private final Map<String, List<String>> values = new LinkedHashMap<String, List<String>>();
private final Map<String, String> keyLookup = new LinkedHashMap<String, String>();
private final Map<String, List<String>> values = new LinkedHashMap<>();
private final Map<String, String> keyLookup = new LinkedHashMap<>();

public FluentCaseInsensitiveStringsMap() {
}
Expand Down Expand Up @@ -68,7 +68,7 @@ public FluentCaseInsensitiveStringsMap add(String key, String value) {
List<String> curValues = null;
if (realKey == null) {
keyLookup.put(lcKey, key);
curValues = new ArrayList<String>();
curValues = new ArrayList<>();
values.put(key, curValues);
} else {
curValues = values.get(realKey);
Expand Down Expand Up @@ -104,7 +104,7 @@ private List<String> fetchValues(Collection<String> values) {
}
if (result == null) {
// lazy initialization
result = new ArrayList<String>();
result = new ArrayList<>();
}
result.add(value);
}
Expand Down Expand Up @@ -137,7 +137,7 @@ public FluentCaseInsensitiveStringsMap add(String key, Collection<String> values
}

if (curValues == null) {
curValues = new ArrayList<String>();
curValues = new ArrayList<>();
this.values.put(realKey, curValues);
}
curValues.addAll(nonNullValues);
Expand Down Expand Up @@ -356,7 +356,7 @@ public Iterator<Map.Entry<String, List<String>>> iterator() {
*/
@Override
public Set<String> keySet() {
return new LinkedHashSet<String>(keyLookup.values());
return new LinkedHashSet<>(keyLookup.values());
}

/**
Expand Down
10 changes: 5 additions & 5 deletions api/src/main/java/org/asynchttpclient/FluentStringsMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* return this instance.
*/
public class FluentStringsMap implements Map<String, List<String>>, Iterable<Map.Entry<String, List<String>>> {
private final Map<String, List<String>> values = new LinkedHashMap<String, List<String>>();
private final Map<String, List<String>> values = new LinkedHashMap<>();

public FluentStringsMap() {
}
Expand All @@ -59,7 +59,7 @@ public FluentStringsMap add(String key, String value) {
List<String> curValues = values.get(key);

if (curValues == null) {
curValues = new ArrayList<String>(1);
curValues = new ArrayList<>(1);
values.put(key, curValues);
}
curValues.add(value);
Expand Down Expand Up @@ -93,7 +93,7 @@ public FluentStringsMap add(String key, Collection<String> values) {
List<String> curValues = this.values.get(key);

if (curValues == null) {
this.values.put(key, new ArrayList<String>(values));
this.values.put(key, new ArrayList<>(values));
} else {
curValues.addAll(values);
}
Expand Down Expand Up @@ -154,7 +154,7 @@ public FluentStringsMap replaceWith(final String key, final Collection<String> v
if (values == null) {
this.values.remove(key);
} else {
this.values.put(key, new ArrayList<String>(values));
this.values.put(key, new ArrayList<>(values));
}
}
return this;
Expand Down Expand Up @@ -404,7 +404,7 @@ public List<Param> toParams() {
if (values.isEmpty())
return Collections.emptyList();
else {
List<Param> params = new ArrayList<Param>(values.size());
List<Param> params = new ArrayList<>(values.size());
for (Map.Entry<String, List<String>> entry : values.entrySet()) {
String name = entry.getKey();
for (String value: entry.getValue())
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/org/asynchttpclient/ProxyServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public String toString() {
}
}

private final List<String> nonProxyHosts = new ArrayList<String>();
private final List<String> nonProxyHosts = new ArrayList<>();
private final Protocol protocol;
private final String host;
private final String principal;
Expand Down
20 changes: 10 additions & 10 deletions api/src/main/java/org/asynchttpclient/RequestBuilderBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ public RequestImpl(Request prototype) {
this.address = prototype.getInetAddress();
this.localAddress = prototype.getLocalAddress();
this.headers = new FluentCaseInsensitiveStringsMap(prototype.getHeaders());
this.cookies = new ArrayList<Cookie>(prototype.getCookies());
this.cookies = new ArrayList<>(prototype.getCookies());
this.byteData = prototype.getByteData();
this.compositeByteData = prototype.getCompositeByteData();
this.stringData = prototype.getStringData();
this.streamData = prototype.getStreamData();
this.bodyGenerator = prototype.getBodyGenerator();
this.formParams = prototype.getFormParams() == null ? null : new ArrayList<Param>(prototype.getFormParams());
this.parts = prototype.getParts() == null ? null : new ArrayList<Part>(prototype.getParts());
this.formParams = prototype.getFormParams() == null ? null : new ArrayList<>(prototype.getFormParams());
this.parts = prototype.getParts() == null ? null : new ArrayList<>(prototype.getParts());
this.virtualHost = prototype.getVirtualHost();
this.length = prototype.getContentLength();
this.proxyServer = prototype.getProxyServer();
Expand Down Expand Up @@ -227,7 +227,7 @@ public List<Param> getQueryParams() {
if (queryParams == null)
// lazy load
if (isNonEmpty(uri.getQuery())) {
queryParams = new ArrayList<Param>(1);
queryParams = new ArrayList<>(1);
for (String queryStringParam : uri.getQuery().split("&")) {
int pos = queryStringParam.indexOf('=');
if (pos <= 0)
Expand Down Expand Up @@ -352,11 +352,11 @@ public T setContentLength(int length) {

private void lazyInitCookies() {
if (request.cookies == null)
request.cookies = new ArrayList<Cookie>(3);
request.cookies = new ArrayList<>(3);
}

public T setCookies(Collection<Cookie> cookies) {
request.cookies = new ArrayList<Cookie>(cookies);
request.cookies = new ArrayList<>(cookies);
return derived.cast(this);
}

Expand Down Expand Up @@ -457,7 +457,7 @@ public T setBody(BodyGenerator bodyGenerator) {

public T addQueryParam(String name, String value) {
if (queryParams == null)
queryParams = new ArrayList<Param>(1);
queryParams = new ArrayList<>(1);
queryParams.add(new Param(name, value));
return derived.cast(this);
}
Expand All @@ -474,7 +474,7 @@ private List<Param> map2ParamList(Map<String, List<String>> map) {
if (map == null)
return null;

List<Param> params = new ArrayList<Param>(map.size());
List<Param> params = new ArrayList<>(map.size());
for (Map.Entry<String, List<String>> entries : map.entrySet()) {
String name = entries.getKey();
for (String value : entries.getValue())
Expand All @@ -499,7 +499,7 @@ public T addFormParam(String name, String value) {
resetNonMultipartData();
resetMultipartData();
if (request.formParams == null)
request.formParams = new ArrayList<Param>(1);
request.formParams = new ArrayList<>(1);
request.formParams.add(new Param(name, value));
return derived.cast(this);
}
Expand All @@ -518,7 +518,7 @@ public T addBodyPart(Part part) {
resetFormParams();
resetNonMultipartData();
if (request.parts == null)
request.parts = new ArrayList<Part>();
request.parts = new ArrayList<>();
request.parts.add(part);
return derived.cast(this);
}
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/org/asynchttpclient/Response.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public interface Response {
boolean hasResponseBody();

public static class ResponseBuilder {
private final List<HttpResponseBodyPart> bodyParts = new ArrayList<HttpResponseBodyPart>();
private final List<HttpResponseBodyPart> bodyParts = new ArrayList<>();
private HttpResponseStatus status;
private HttpResponseHeaders headers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public <T> FilterContext<T> filter(FilterContext<T> ctx) throws FilterException
throw new FilterException(String.format("Interrupted Request %s with AsyncHandler %s", ctx.getRequest(), ctx.getAsyncHandler()));
}

return new FilterContext.FilterContextBuilder<T>(ctx).asyncHandler(new AsyncHandlerWrapper<T>(ctx.getAsyncHandler(), available))
return new FilterContext.FilterContextBuilder<>(ctx).asyncHandler(new AsyncHandlerWrapper<>(ctx.getAsyncHandler(), available))
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public FilterContextBuilder<T> ioException(IOException ioException) {
}

public FilterContext<T> build() {
return new FilterContext<T>(this);
return new FilterContext<>(this);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public final class ExecutionList implements Runnable {
private static final Logger log = Logger.getLogger(ExecutionList.class.getName());

// The runnable,executor pairs to execute.
private final Queue<RunnableExecutorPair> runnables = new LinkedBlockingQueue<RunnableExecutorPair>();
private final Queue<RunnableExecutorPair> runnables = new LinkedBlockingQueue<>();

// Boolean we use mark when execution has started. Only accessed from within
// synchronized blocks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
*/
public class TransferCompletionHandler extends AsyncCompletionHandlerBase {
private final static Logger logger = LoggerFactory.getLogger(TransferCompletionHandler.class);
private final ConcurrentLinkedQueue<TransferListener> listeners = new ConcurrentLinkedQueue<TransferListener>();
private final ConcurrentLinkedQueue<TransferListener> listeners = new ConcurrentLinkedQueue<>();
private final boolean accumulateResponseBytes;
private FluentCaseInsensitiveStringsMap headers;
// Netty 3 bug hack: last chunk is not notified, fixed in Netty 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class MultipartBody implements RandomAccessBody {
private final long contentLength;
private final String contentType;
private final List<Part> parts;
private final List<RandomAccessFile> pendingOpenFiles = new ArrayList<RandomAccessFile>();
private final List<RandomAccessFile> pendingOpenFiles = new ArrayList<>();

private boolean transfertDone = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private synchronized String generateNonce() {
* when it would occur it'd be harder to track down.
*/
final static class OAuthParameterSet {
final private ArrayList<Parameter> allParameters = new ArrayList<Parameter>();
final private ArrayList<Parameter> allParameters = new ArrayList<>();

public OAuthParameterSet() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class PropertiesBasedResumableProcessor implements ResumableAsyncHandler.
private final static Logger log = LoggerFactory.getLogger(PropertiesBasedResumableProcessor.class);
private final static File TMP = new File(System.getProperty("java.io.tmpdir"), "ahc");
private final static String storeName = "ResumableAsyncHandler.properties";
private final ConcurrentHashMap<String, Long> properties = new ConcurrentHashMap<String, Long>();
private final ConcurrentHashMap<String, Long> properties = new ConcurrentHashMap<>();

/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public ResumableAsyncHandler setResumableListener(ResumableListener resumableLis

private static class ResumableIndexThread extends Thread {

public final ConcurrentLinkedQueue<ResumableProcessor> resumableProcessors = new ConcurrentLinkedQueue<ResumableProcessor>();
public final ConcurrentLinkedQueue<ResumableProcessor> resumableProcessors = new ConcurrentLinkedQueue<>();

public ResumableIndexThread() {
Runtime.getRuntime().addShutdownHook(this);
Expand Down Expand Up @@ -293,7 +293,7 @@ public void save(Map<String, Long> map) {
}

public Map<String, Long> load() {
return new HashMap<String, Long>();
return new HashMap<>();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public <T> FilterContext<T> filter(FilterContext<T> ctx) throws FilterException

Request request = ResumableAsyncHandler.class.cast(ctx.getAsyncHandler()).adjustRequestRange(ctx.getRequest());

return new FilterContext.FilterContextBuilder<T>(ctx).request(request).replayRequest(true).build();
return new FilterContext.FilterContextBuilder<>(ctx).request(request).replayRequest(true).build();
}
return ctx;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public final void onClose(WebSocket webSocket, int status, String reasonPhrase)
*/
public final static class Builder {

private List<WebSocketListener> listeners = new ArrayList<WebSocketListener>();
private List<WebSocketListener> listeners = new ArrayList<>();

/**
* Add a {@link WebSocketListener} that will be added to the {@link WebSocket}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public void asyncParamPOSTTest() throws Exception {
FluentCaseInsensitiveStringsMap h = new FluentCaseInsensitiveStringsMap();
h.add("Content-Type", "application/x-www-form-urlencoded");

Map<String, List<String>> m = new HashMap<String, List<String>>();
Map<String, List<String>> m = new HashMap<>();
for (int i = 0; i < 5; i++) {
m.put("param_" + i, Arrays.asList("value_" + i));
}
Expand Down Expand Up @@ -690,7 +690,7 @@ public void asyncRequestVirtualServerPOSTTest() throws Exception {
FluentCaseInsensitiveStringsMap h = new FluentCaseInsensitiveStringsMap();
h.add("Content-Type", "application/x-www-form-urlencoded");

Map<String, List<String>> m = new HashMap<String, List<String>>();
Map<String, List<String>> m = new HashMap<>();
for (int i = 0; i < 5; i++) {
m.put("param_" + i, Arrays.asList("value_" + i));
}
Expand Down Expand Up @@ -1360,7 +1360,7 @@ public void asyncDoPostCancelTest() throws Exception {
StringBuilder sb = new StringBuilder();
sb.append("LockThread=true");

final AtomicReference<CancellationException> ex = new AtomicReference<CancellationException>();
final AtomicReference<CancellationException> ex = new AtomicReference<>();
ex.set(null);
try {
Future<Response> future = client.preparePost(getTargetUrl()).setHeaders(h).setBody(sb.toString()).execute(new AsyncCompletionHandlerAdapter() {
Expand Down
Loading

0 comments on commit 706cd8e

Please sign in to comment.