mirror of https://github.com/grpc/grpc-java.git
all: use Java7 brackets
This commit is contained in:
parent
6cf849a7ce
commit
b0f423295b
|
@ -36,7 +36,7 @@ public final class AltsClientOptions extends AltsHandshakerOptions {
|
|||
super(builder.rpcProtocolVersions);
|
||||
targetName = builder.targetName;
|
||||
targetServiceAccounts =
|
||||
Collections.unmodifiableList(new ArrayList<String>(builder.targetServiceAccounts));
|
||||
Collections.unmodifiableList(new ArrayList<>(builder.targetServiceAccounts));
|
||||
}
|
||||
|
||||
public String getTargetName() {
|
||||
|
@ -51,7 +51,7 @@ public final class AltsClientOptions extends AltsHandshakerOptions {
|
|||
public static final class Builder {
|
||||
@Nullable private String targetName;
|
||||
@Nullable private RpcProtocolVersions rpcProtocolVersions;
|
||||
private ArrayList<String> targetServiceAccounts = new ArrayList<String>();
|
||||
private ArrayList<String> targetServiceAccounts = new ArrayList<>();
|
||||
|
||||
public Builder setTargetName(String targetName) {
|
||||
this.targetName = targetName;
|
||||
|
|
|
@ -45,7 +45,7 @@ public class AltsTsiFrameProtectorTest {
|
|||
private static final int FRAME_MIN_SIZE =
|
||||
AltsTsiFrameProtector.getHeaderTypeFieldBytes() + FakeChannelCrypter.getTagBytes();
|
||||
|
||||
private final List<ReferenceCounted> references = new ArrayList<ReferenceCounted>();
|
||||
private final List<ReferenceCounted> references = new ArrayList<>();
|
||||
private final RegisterRef ref =
|
||||
new RegisterRef() {
|
||||
@Override
|
||||
|
|
|
@ -127,7 +127,7 @@ public class InteropInstrumentationTest {
|
|||
new InteropTask(
|
||||
listener,
|
||||
TesterOkHttpChannelBuilder.build(host, port, serverHostOverride, useTls, testCa),
|
||||
new ArrayList<ClientInterceptor>(),
|
||||
new ArrayList<>(),
|
||||
testCase)
|
||||
.execute();
|
||||
String result = resultFuture.get(TIMEOUT_SECONDS, TimeUnit.SECONDS);
|
||||
|
|
|
@ -129,7 +129,7 @@ public class TesterActivity extends AppCompatActivity
|
|||
ManagedChannel channel =
|
||||
TesterOkHttpChannelBuilder.build(host, port, serverHostOverride, true, testCert);
|
||||
|
||||
List<ClientInterceptor> interceptors = new ArrayList<ClientInterceptor>();
|
||||
List<ClientInterceptor> interceptors = new ArrayList<>();
|
||||
if (getCheckBox.isChecked()) {
|
||||
interceptors.add(new SafeMethodChannelInterceptor());
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ public class GoogleAuthLibraryCallCredentialsTest {
|
|||
.set(CallCredentials.ATTR_SECURITY_LEVEL, SecurityLevel.PRIVACY_AND_INTEGRITY)
|
||||
.build();
|
||||
|
||||
private ArrayList<Runnable> pendingRunnables = new ArrayList<Runnable>();
|
||||
private ArrayList<Runnable> pendingRunnables = new ArrayList<>();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
@ -424,7 +424,7 @@ public class GoogleAuthLibraryCallCredentialsTest {
|
|||
|
||||
private int runPendingRunnables() {
|
||||
ArrayList<Runnable> savedPendingRunnables = pendingRunnables;
|
||||
pendingRunnables = new ArrayList<Runnable>();
|
||||
pendingRunnables = new ArrayList<>();
|
||||
for (Runnable r : savedPendingRunnables) {
|
||||
r.run();
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class HandlerRegistryBenchmark {
|
|||
@Setup(Level.Trial)
|
||||
public void setup() throws Exception {
|
||||
registry = new MutableHandlerRegistry();
|
||||
fullMethodNames = new ArrayList<String>(serviceCount * methodCountPerService);
|
||||
fullMethodNames = new ArrayList<>(serviceCount * methodCountPerService);
|
||||
for (int serviceIndex = 0; serviceIndex < serviceCount; ++serviceIndex) {
|
||||
String serviceName = randomString();
|
||||
ServerServiceDefinition.Builder serviceBuilder = ServerServiceDefinition.builder(serviceName);
|
||||
|
|
|
@ -149,7 +149,7 @@ public abstract class AbstractConfigurationBuilder<T extends Configuration>
|
|||
public final void printUsage() {
|
||||
System.out.println("Usage: [ARGS...]");
|
||||
int column1Width = 0;
|
||||
List<Param> params = new ArrayList<Param>();
|
||||
List<Param> params = new ArrayList<>();
|
||||
params.add(HELP);
|
||||
params.addAll(getParams());
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public class AsyncClient {
|
|||
|
||||
SimpleRequest req = newRequest();
|
||||
|
||||
List<ManagedChannel> channels = new ArrayList<ManagedChannel>(config.channels);
|
||||
List<ManagedChannel> channels = new ArrayList<>(config.channels);
|
||||
for (int i = 0; i < config.channels; i++) {
|
||||
channels.add(config.newChannel());
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ public class AsyncClient {
|
|||
}
|
||||
}
|
||||
// Wait for completion
|
||||
List<Histogram> histograms = new ArrayList<Histogram>(futures.size());
|
||||
List<Histogram> histograms = new ArrayList<>(futures.size());
|
||||
for (Future<Histogram> future : futures) {
|
||||
histograms.add(future.get());
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class ReadBenchmark {
|
|||
@State(Scope.Benchmark)
|
||||
public static class ContextState {
|
||||
List<Context.Key<Object>> keys = new ArrayList<Context.Key<Object>>();
|
||||
List<Context> contexts = new ArrayList<Context>();
|
||||
List<Context> contexts = new ArrayList<>();
|
||||
|
||||
@Setup
|
||||
public void setup() {
|
||||
|
|
|
@ -471,7 +471,7 @@ public class Context {
|
|||
if (listeners == null) {
|
||||
// Now that we have a listener we need to listen to our parent so
|
||||
// we can cascade listener notification.
|
||||
listeners = new ArrayList<ExecutableListener>();
|
||||
listeners = new ArrayList<>();
|
||||
listeners.add(executableListener);
|
||||
if (cancellableAncestor != null) {
|
||||
cancellableAncestor.addListener(parentListener, DirectExecutor.INSTANCE);
|
||||
|
|
|
@ -56,7 +56,7 @@ public class ClientInterceptors {
|
|||
*/
|
||||
public static Channel interceptForward(Channel channel,
|
||||
List<? extends ClientInterceptor> interceptors) {
|
||||
List<? extends ClientInterceptor> copy = new ArrayList<ClientInterceptor>(interceptors);
|
||||
List<? extends ClientInterceptor> copy = new ArrayList<>(interceptors);
|
||||
Collections.reverse(copy);
|
||||
return intercept(channel, copy);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public final class EquivalentAddressGroup {
|
|||
*/
|
||||
public EquivalentAddressGroup(List<SocketAddress> addrs, Attributes attrs) {
|
||||
Preconditions.checkArgument(!addrs.isEmpty(), "addrs is empty");
|
||||
this.addrs = Collections.unmodifiableList(new ArrayList<SocketAddress>(addrs));
|
||||
this.addrs = Collections.unmodifiableList(new ArrayList<>(addrs));
|
||||
this.attrs = Preconditions.checkNotNull(attrs, "attrs");
|
||||
// Attributes may contain mutable objects, which means Attributes' hashCode may change over
|
||||
// time, thus we don't cache Attributes' hashCode.
|
||||
|
|
|
@ -186,7 +186,7 @@ public final class InternalChannelz {
|
|||
if (serverSockets == null) {
|
||||
return null;
|
||||
}
|
||||
List<InternalWithLogId> socketList = new ArrayList<InternalWithLogId>(maxPageSize);
|
||||
List<InternalWithLogId> socketList = new ArrayList<>(maxPageSize);
|
||||
Iterator<InternalInstrumented<SocketStats>> iterator
|
||||
= serverSockets.tailMap(fromId).values().iterator();
|
||||
while (socketList.size() < maxPageSize && iterator.hasNext()) {
|
||||
|
@ -504,7 +504,7 @@ public final class InternalChannelz {
|
|||
}
|
||||
|
||||
public Builder setEvents(List<Event> events) {
|
||||
this.events = Collections.unmodifiableList(new ArrayList<Event>(events));
|
||||
this.events = Collections.unmodifiableList(new ArrayList<>(events));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ public abstract class NameResolverProvider extends NameResolver.Factory {
|
|||
private final List<NameResolverProvider> providers;
|
||||
|
||||
NameResolverFactory(List<NameResolverProvider> providers) {
|
||||
this.providers = Collections.unmodifiableList(new ArrayList<NameResolverProvider>(providers));
|
||||
this.providers = Collections.unmodifiableList(new ArrayList<>(providers));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -62,7 +62,7 @@ public final class ServerInterceptors {
|
|||
public static ServerServiceDefinition interceptForward(
|
||||
ServerServiceDefinition serviceDef,
|
||||
List<? extends ServerInterceptor> interceptors) {
|
||||
List<? extends ServerInterceptor> copy = new ArrayList<ServerInterceptor>(interceptors);
|
||||
List<? extends ServerInterceptor> copy = new ArrayList<>(interceptors);
|
||||
Collections.reverse(copy);
|
||||
return intercept(serviceDef, copy);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ final class ServiceProviders {
|
|||
} else {
|
||||
candidates = getCandidatesViaServiceLoader(klass, cl);
|
||||
}
|
||||
List<T> list = new ArrayList<T>();
|
||||
List<T> list = new ArrayList<>();
|
||||
for (T current: candidates) {
|
||||
if (!priorityAccessor.isAvailable(current)) {
|
||||
continue;
|
||||
|
@ -115,7 +115,7 @@ final class ServiceProviders {
|
|||
*/
|
||||
@VisibleForTesting
|
||||
static <T> Iterable<T> getCandidatesViaHardCoded(Class<T> klass, Iterable<Class<?>> hardcoded) {
|
||||
List<T> list = new ArrayList<T>();
|
||||
List<T> list = new ArrayList<>();
|
||||
for (Class<?> candidate : hardcoded) {
|
||||
list.add(create(klass, candidate));
|
||||
}
|
||||
|
|
|
@ -238,7 +238,7 @@ public final class Status {
|
|||
+ replaced.getCode().name() + " & " + code.name());
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableList(new ArrayList<Status>(canonicalizer.values()));
|
||||
return Collections.unmodifiableList(new ArrayList<>(canonicalizer.values()));
|
||||
}
|
||||
|
||||
// A pseudo-enum of Status instances mapped 1:1 with values in Code. This simplifies construction
|
||||
|
|
|
@ -207,7 +207,7 @@ final class InProcessTransport implements ServerTransport, ConnectionClientTrans
|
|||
if (terminated) {
|
||||
return;
|
||||
}
|
||||
streamsCopy = new ArrayList<InProcessStream>(streams);
|
||||
streamsCopy = new ArrayList<>(streams);
|
||||
}
|
||||
for (InProcessStream stream : streamsCopy) {
|
||||
stream.clientStream.cancel(reason);
|
||||
|
|
|
@ -97,7 +97,7 @@ public abstract class AbstractManagedChannelImplBuilder
|
|||
|
||||
ObjectPool<? extends Executor> executorPool = DEFAULT_EXECUTOR_POOL;
|
||||
|
||||
private final List<ClientInterceptor> interceptors = new ArrayList<ClientInterceptor>();
|
||||
private final List<ClientInterceptor> interceptors = new ArrayList<>();
|
||||
|
||||
// Access via getter, which may perform authority override as needed
|
||||
private NameResolver.Factory nameResolverFactory = DEFAULT_NAME_RESOLVER_FACTORY;
|
||||
|
@ -418,7 +418,7 @@ public abstract class AbstractManagedChannelImplBuilder
|
|||
@VisibleForTesting
|
||||
final List<ClientInterceptor> getEffectiveInterceptors() {
|
||||
List<ClientInterceptor> effectiveInterceptors =
|
||||
new ArrayList<ClientInterceptor>(this.interceptors);
|
||||
new ArrayList<>(this.interceptors);
|
||||
temporarilyDisableRetry = false;
|
||||
if (statsEnabled) {
|
||||
temporarilyDisableRetry = true;
|
||||
|
|
|
@ -82,12 +82,12 @@ public abstract class AbstractServerImplBuilder<T extends AbstractServerImplBuil
|
|||
new InternalHandlerRegistry.Builder();
|
||||
|
||||
final List<ServerTransportFilter> transportFilters =
|
||||
new ArrayList<ServerTransportFilter>();
|
||||
new ArrayList<>();
|
||||
|
||||
final List<ServerInterceptor> interceptors = new ArrayList<ServerInterceptor>();
|
||||
final List<ServerInterceptor> interceptors = new ArrayList<>();
|
||||
|
||||
private final List<InternalNotifyOnServerBuild> notifyOnBuildList =
|
||||
new ArrayList<InternalNotifyOnServerBuild>();
|
||||
new ArrayList<>();
|
||||
|
||||
private final List<ServerStreamTracer.Factory> streamTracerFactories =
|
||||
new ArrayList<ServerStreamTracer.Factory>();
|
||||
|
|
|
@ -82,7 +82,7 @@ final class ChannelTracer {
|
|||
int eventsLoggedSnapshot;
|
||||
synchronized (lock) {
|
||||
eventsLoggedSnapshot = eventsLogged;
|
||||
eventsSnapshot = new ArrayList<Event>(events);
|
||||
eventsSnapshot = new ArrayList<>(events);
|
||||
}
|
||||
builder.setChannelTrace(new ChannelTrace.Builder()
|
||||
.setNumEventsLogged(eventsLoggedSnapshot)
|
||||
|
|
|
@ -33,7 +33,7 @@ import javax.annotation.concurrent.NotThreadSafe;
|
|||
*/
|
||||
@NotThreadSafe
|
||||
final class ConnectivityStateManager {
|
||||
private ArrayList<Listener> listeners = new ArrayList<Listener>();
|
||||
private ArrayList<Listener> listeners = new ArrayList<>();
|
||||
|
||||
private volatile ConnectivityState state = ConnectivityState.IDLE;
|
||||
|
||||
|
@ -69,7 +69,7 @@ final class ConnectivityStateManager {
|
|||
// Swap out callback list before calling them, because a callback may register new callbacks,
|
||||
// if run in direct executor, can cause ConcurrentModificationException.
|
||||
ArrayList<Listener> savedListeners = listeners;
|
||||
listeners = new ArrayList<Listener>();
|
||||
listeners = new ArrayList<>();
|
||||
for (Listener listener : savedListeners) {
|
||||
listener.runInExecutor();
|
||||
}
|
||||
|
|
|
@ -281,9 +281,9 @@ final class DelayedClientTransport implements ManagedClientTransport {
|
|||
if (picker == null || !hasPendingStreams()) {
|
||||
return;
|
||||
}
|
||||
toProcess = new ArrayList<PendingStream>(pendingStreams);
|
||||
toProcess = new ArrayList<>(pendingStreams);
|
||||
}
|
||||
ArrayList<PendingStream> toRemove = new ArrayList<PendingStream>();
|
||||
ArrayList<PendingStream> toRemove = new ArrayList<>();
|
||||
|
||||
for (final PendingStream stream : toProcess) {
|
||||
PickResult pickResult = picker.pickSubchannel(stream.args);
|
||||
|
|
|
@ -52,7 +52,7 @@ class DelayedStream implements ClientStream {
|
|||
@GuardedBy("this")
|
||||
private Status error;
|
||||
@GuardedBy("this")
|
||||
private List<Runnable> pendingCalls = new ArrayList<Runnable>();
|
||||
private List<Runnable> pendingCalls = new ArrayList<>();
|
||||
@GuardedBy("this")
|
||||
private DelayedStreamListener delayedListener;
|
||||
|
||||
|
@ -120,7 +120,7 @@ class DelayedStream implements ClientStream {
|
|||
private void drainPendingCalls() {
|
||||
assert realStream != null;
|
||||
assert !passThrough;
|
||||
List<Runnable> toRun = new ArrayList<Runnable>();
|
||||
List<Runnable> toRun = new ArrayList<>();
|
||||
DelayedStreamListener delayedListener = null;
|
||||
while (true) {
|
||||
synchronized (this) {
|
||||
|
@ -367,7 +367,7 @@ class DelayedStream implements ClientStream {
|
|||
private final ClientStreamListener realListener;
|
||||
private volatile boolean passThrough;
|
||||
@GuardedBy("this")
|
||||
private List<Runnable> pendingCallbacks = new ArrayList<Runnable>();
|
||||
private List<Runnable> pendingCallbacks = new ArrayList<>();
|
||||
|
||||
public DelayedStreamListener(ClientStreamListener listener) {
|
||||
this.realListener = listener;
|
||||
|
@ -445,7 +445,7 @@ class DelayedStream implements ClientStream {
|
|||
|
||||
public void drainPendingCallbacks() {
|
||||
assert !passThrough;
|
||||
List<Runnable> toRun = new ArrayList<Runnable>();
|
||||
List<Runnable> toRun = new ArrayList<>();
|
||||
while (true) {
|
||||
synchronized (this) {
|
||||
if (pendingCallbacks.isEmpty()) {
|
||||
|
|
|
@ -244,7 +244,7 @@ final class DnsNameResolver extends NameResolver {
|
|||
return;
|
||||
}
|
||||
// Each address forms an EAG
|
||||
List<EquivalentAddressGroup> servers = new ArrayList<EquivalentAddressGroup>();
|
||||
List<EquivalentAddressGroup> servers = new ArrayList<>();
|
||||
for (InetAddress inetAddr : resolutionResults.addresses) {
|
||||
servers.add(new EquivalentAddressGroup(new InetSocketAddress(inetAddr, port)));
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ final class InternalHandlerRegistry extends HandlerRegistry {
|
|||
}
|
||||
}
|
||||
return new InternalHandlerRegistry(
|
||||
Collections.unmodifiableList(new ArrayList<ServerServiceDefinition>(services.values())),
|
||||
Collections.unmodifiableList(new ArrayList<>(services.values())),
|
||||
Collections.unmodifiableMap(map));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,8 +125,7 @@ final class InternalSubchannel implements InternalInstrumented<ChannelStats> {
|
|||
* also be present.
|
||||
*/
|
||||
@GuardedBy("lock")
|
||||
private final Collection<ConnectionClientTransport> transports =
|
||||
new ArrayList<ConnectionClientTransport>();
|
||||
private final Collection<ConnectionClientTransport> transports = new ArrayList<>();
|
||||
|
||||
// Must only be used from channelExecutor
|
||||
private final InUseStateAggregator<ConnectionClientTransport> inUseStateAggregator =
|
||||
|
@ -172,7 +171,7 @@ final class InternalSubchannel implements InternalInstrumented<ChannelStats> {
|
|||
Preconditions.checkArgument(!addressGroups.isEmpty(), "addressGroups is empty");
|
||||
checkListHasNoNulls(addressGroups, "addressGroups contains null entry");
|
||||
this.addressIndex = new Index(
|
||||
Collections.unmodifiableList(new ArrayList<EquivalentAddressGroup>(addressGroups)));
|
||||
Collections.unmodifiableList(new ArrayList<>(addressGroups)));
|
||||
this.authority = authority;
|
||||
this.userAgent = userAgent;
|
||||
this.backoffPolicyProvider = backoffPolicyProvider;
|
||||
|
@ -352,7 +351,7 @@ final class InternalSubchannel implements InternalInstrumented<ChannelStats> {
|
|||
checkListHasNoNulls(newAddressGroups, "newAddressGroups contains null entry");
|
||||
Preconditions.checkArgument(!newAddressGroups.isEmpty(), "newAddressGroups is empty");
|
||||
newAddressGroups =
|
||||
Collections.unmodifiableList(new ArrayList<EquivalentAddressGroup>(newAddressGroups));
|
||||
Collections.unmodifiableList(new ArrayList<>(newAddressGroups));
|
||||
ManagedClientTransport savedTransport = null;
|
||||
try {
|
||||
synchronized (lock) {
|
||||
|
|
|
@ -116,7 +116,7 @@ final class JndiResourceResolverFactory implements DnsNameResolver.ResourceResol
|
|||
Level.FINER, "Found {0} TXT records", new Object[]{serviceConfigRawTxtRecords.size()});
|
||||
}
|
||||
List<String> serviceConfigTxtRecords =
|
||||
new ArrayList<String>(serviceConfigRawTxtRecords.size());
|
||||
new ArrayList<>(serviceConfigRawTxtRecords.size());
|
||||
for (String serviceConfigRawTxtRecord : serviceConfigRawTxtRecords) {
|
||||
serviceConfigTxtRecords.add(unquote(serviceConfigRawTxtRecord));
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ final class JndiResourceResolverFactory implements DnsNameResolver.ResourceResol
|
|||
Level.FINER, "Found {0} SRV records", new Object[]{grpclbSrvRecords.size()});
|
||||
}
|
||||
List<EquivalentAddressGroup> balancerAddresses =
|
||||
new ArrayList<EquivalentAddressGroup>(grpclbSrvRecords.size());
|
||||
new ArrayList<>(grpclbSrvRecords.size());
|
||||
Exception first = null;
|
||||
Level level = Level.WARNING;
|
||||
for (String srvRecord : grpclbSrvRecords) {
|
||||
|
@ -146,7 +146,7 @@ final class JndiResourceResolverFactory implements DnsNameResolver.ResourceResol
|
|||
SrvRecord record = parseSrvRecord(srvRecord);
|
||||
|
||||
List<? extends InetAddress> addrs = addressResolver.resolveAddress(record.host);
|
||||
List<SocketAddress> sockaddrs = new ArrayList<SocketAddress>(addrs.size());
|
||||
List<SocketAddress> sockaddrs = new ArrayList<>(addrs.size());
|
||||
for (InetAddress addr : addrs) {
|
||||
sockaddrs.add(new InetSocketAddress(addr, record.port));
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ final class JndiResourceResolverFactory implements DnsNameResolver.ResourceResol
|
|||
private static List<String> getAllRecords(String recordType, String name)
|
||||
throws NamingException {
|
||||
String[] rrType = new String[]{recordType};
|
||||
List<String> records = new ArrayList<String>();
|
||||
List<String> records = new ArrayList<>();
|
||||
|
||||
@SuppressWarnings("JdkObsolete")
|
||||
Hashtable<String, String> env = new Hashtable<String, String>();
|
||||
|
|
|
@ -92,7 +92,7 @@ public final class JsonParser {
|
|||
|
||||
private static List<Object> parseJsonArray(JsonReader jr) throws IOException {
|
||||
jr.beginArray();
|
||||
List<Object> array = new ArrayList<Object>();
|
||||
List<Object> array = new ArrayList<>();
|
||||
while (jr.hasNext()) {
|
||||
Object value = parseRecursive(jr);
|
||||
array.add(value);
|
||||
|
|
|
@ -308,7 +308,7 @@ final class ManagedChannelImpl extends ManagedChannel implements
|
|||
channelTracer.updateBuilder(builder);
|
||||
}
|
||||
builder.setTarget(target).setState(channelStateManager.getState());
|
||||
List<InternalWithLogId> children = new ArrayList<InternalWithLogId>();
|
||||
List<InternalWithLogId> children = new ArrayList<>();
|
||||
children.addAll(subchannels);
|
||||
children.addAll(oobChannels);
|
||||
builder.setSubchannels(children);
|
||||
|
@ -963,7 +963,7 @@ final class ManagedChannelImpl extends ManagedChannel implements
|
|||
Collection<ClientStream> streams;
|
||||
|
||||
synchronized (lock) {
|
||||
streams = new ArrayList<ClientStream>(uncommittedRetriableStreams);
|
||||
streams = new ArrayList<>(uncommittedRetriableStreams);
|
||||
}
|
||||
|
||||
for (ClientStream stream : streams) {
|
||||
|
|
|
@ -381,7 +381,7 @@ public class MessageFramer implements Framer {
|
|||
* {@link OutputStream}.
|
||||
*/
|
||||
private final class BufferChainOutputStream extends OutputStream {
|
||||
private final List<WritableBuffer> bufferList = new ArrayList<WritableBuffer>();
|
||||
private final List<WritableBuffer> bufferList = new ArrayList<>();
|
||||
private WritableBuffer current;
|
||||
|
||||
/**
|
||||
|
|
|
@ -220,7 +220,7 @@ abstract class RetriableStream<ReqT> implements ClientStream {
|
|||
|
||||
int stop = Math.min(index + chunk, savedState.buffer.size());
|
||||
if (list == null) {
|
||||
list = new ArrayList<BufferEntry>(savedState.buffer.subList(index, stop));
|
||||
list = new ArrayList<>(savedState.buffer.subList(index, stop));
|
||||
} else {
|
||||
list.clear();
|
||||
list.addAll(savedState.buffer.subList(index, stop));
|
||||
|
@ -761,7 +761,7 @@ abstract class RetriableStream<ReqT> implements ClientStream {
|
|||
// optimize for 0-retry, which is most of the cases.
|
||||
drainedSubstreams = Collections.singletonList(substream);
|
||||
} else {
|
||||
drainedSubstreams = new ArrayList<Substream>(this.drainedSubstreams);
|
||||
drainedSubstreams = new ArrayList<>(this.drainedSubstreams);
|
||||
drainedSubstreams.add(substream);
|
||||
drainedSubstreams = Collections.unmodifiableCollection(drainedSubstreams);
|
||||
}
|
||||
|
@ -784,7 +784,7 @@ abstract class RetriableStream<ReqT> implements ClientStream {
|
|||
State substreamClosed(Substream substream) {
|
||||
substream.closed = true;
|
||||
if (this.drainedSubstreams.contains(substream)) {
|
||||
Collection<Substream> drainedSubstreams = new ArrayList<Substream>(this.drainedSubstreams);
|
||||
Collection<Substream> drainedSubstreams = new ArrayList<>(this.drainedSubstreams);
|
||||
drainedSubstreams.remove(substream);
|
||||
drainedSubstreams = Collections.unmodifiableCollection(drainedSubstreams);
|
||||
return new State(buffer, drainedSubstreams, winningSubstream, cancelled, passThrough);
|
||||
|
|
|
@ -139,7 +139,7 @@ public final class ServerImpl extends io.grpc.Server implements InternalInstrume
|
|||
this.decompressorRegistry = builder.decompressorRegistry;
|
||||
this.compressorRegistry = builder.compressorRegistry;
|
||||
this.transportFilters = Collections.unmodifiableList(
|
||||
new ArrayList<ServerTransportFilter>(builder.transportFilters));
|
||||
new ArrayList<>(builder.transportFilters));
|
||||
this.interceptors =
|
||||
builder.interceptors.toArray(new ServerInterceptor[builder.interceptors.size()]);
|
||||
this.handshakeTimeoutMillis = builder.handshakeTimeoutMillis;
|
||||
|
@ -188,7 +188,7 @@ public final class ServerImpl extends io.grpc.Server implements InternalInstrume
|
|||
List<ServerServiceDefinition> registryServices = registry.getServices();
|
||||
int servicesCount = registryServices.size() + fallbackServices.size();
|
||||
List<ServerServiceDefinition> services =
|
||||
new ArrayList<ServerServiceDefinition>(servicesCount);
|
||||
new ArrayList<>(servicesCount);
|
||||
services.addAll(registryServices);
|
||||
services.addAll(fallbackServices);
|
||||
return Collections.unmodifiableList(services);
|
||||
|
@ -241,7 +241,7 @@ public final class ServerImpl extends io.grpc.Server implements InternalInstrume
|
|||
return this;
|
||||
}
|
||||
shutdownNowStatus = nowStatus;
|
||||
transportsCopy = new ArrayList<ServerTransport>(transports);
|
||||
transportsCopy = new ArrayList<>(transports);
|
||||
savedServerShutdownCallbackInvoked = serverShutdownCallbackInvoked;
|
||||
}
|
||||
// Short-circuiting not strictly necessary, but prevents transports from needing to handle
|
||||
|
@ -343,7 +343,7 @@ public final class ServerImpl extends io.grpc.Server implements InternalInstrume
|
|||
synchronized (lock) {
|
||||
// transports collection can be modified during shutdown(), even if we hold the lock, due
|
||||
// to reentrancy.
|
||||
copiedTransports = new ArrayList<ServerTransport>(transports);
|
||||
copiedTransports = new ArrayList<>(transports);
|
||||
shutdownNowStatusCopy = shutdownNowStatus;
|
||||
serverShutdownCallbackInvoked = true;
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public final class StatsTraceContext {
|
|||
*/
|
||||
@VisibleForTesting
|
||||
public List<StreamTracer> getTracersForTest() {
|
||||
return new ArrayList<StreamTracer>(Arrays.asList(tracers));
|
||||
return new ArrayList<>(Arrays.asList(tracers));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -79,7 +79,7 @@ public final class MutableHandlerRegistry extends HandlerRegistry {
|
|||
@Override
|
||||
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2222")
|
||||
public List<ServerServiceDefinition> getServices() {
|
||||
return Collections.unmodifiableList(new ArrayList<ServerServiceDefinition>(services.values()));
|
||||
return Collections.unmodifiableList(new ArrayList<>(services.values()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -273,7 +273,7 @@ public final class RoundRobinLoadBalancerFactory extends LoadBalancer.Factory {
|
|||
*/
|
||||
private static List<Subchannel> filterNonFailingSubchannels(
|
||||
Collection<Subchannel> subchannels) {
|
||||
List<Subchannel> readySubchannels = new ArrayList<Subchannel>(subchannels.size());
|
||||
List<Subchannel> readySubchannels = new ArrayList<>(subchannels.size());
|
||||
for (Subchannel subchannel : subchannels) {
|
||||
if (isReady(subchannel)) {
|
||||
readySubchannels.add(subchannel);
|
||||
|
|
|
@ -130,7 +130,7 @@ public class ClientInterceptorsTest {
|
|||
|
||||
@Test
|
||||
public void ordered() {
|
||||
final List<String> order = new ArrayList<String>();
|
||||
final List<String> order = new ArrayList<>();
|
||||
channel = new Channel() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
|
@ -172,7 +172,7 @@ public class ClientInterceptorsTest {
|
|||
|
||||
@Test
|
||||
public void orderedForward() {
|
||||
final List<String> order = new ArrayList<String>();
|
||||
final List<String> order = new ArrayList<>();
|
||||
channel = new Channel() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
|
@ -267,7 +267,7 @@ public class ClientInterceptorsTest {
|
|||
|
||||
@Test
|
||||
public void examineInboundHeaders() {
|
||||
final List<Metadata> examinedHeaders = new ArrayList<Metadata>();
|
||||
final List<Metadata> examinedHeaders = new ArrayList<>();
|
||||
ClientInterceptor interceptor = new ClientInterceptor() {
|
||||
@Override
|
||||
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
|
||||
|
@ -423,8 +423,8 @@ public class ClientInterceptorsTest {
|
|||
private boolean done;
|
||||
private ClientCall.Listener<Integer> listener;
|
||||
private Metadata headers;
|
||||
private List<Integer> requests = new ArrayList<Integer>();
|
||||
private List<String> messages = new ArrayList<String>();
|
||||
private List<Integer> requests = new ArrayList<>();
|
||||
private List<String> messages = new ArrayList<>();
|
||||
private boolean halfClosed;
|
||||
private Throwable cancelCause;
|
||||
private String cancelMessage;
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ContextsTest {
|
|||
public void interceptCall_basic() {
|
||||
Context origContext = Context.current();
|
||||
final Object message = new Object();
|
||||
final List<Integer> methodCalls = new ArrayList<Integer>();
|
||||
final List<Integer> methodCalls = new ArrayList<>();
|
||||
final ServerCall.Listener<Object> listener = new ServerCall.Listener<Object>() {
|
||||
@Override public void onMessage(Object messageIn) {
|
||||
assertSame(message, messageIn);
|
||||
|
|
|
@ -184,7 +184,7 @@ public class ServerInterceptorsTest {
|
|||
|
||||
@Test
|
||||
public void ordered() {
|
||||
final List<String> order = new ArrayList<String>();
|
||||
final List<String> order = new ArrayList<>();
|
||||
handler = new ServerCallHandler<String, Integer>() {
|
||||
@Override
|
||||
public ServerCall.Listener<String> startCall(
|
||||
|
@ -226,7 +226,7 @@ public class ServerInterceptorsTest {
|
|||
|
||||
@Test
|
||||
public void orderedForward() {
|
||||
final List<String> order = new ArrayList<String>();
|
||||
final List<String> order = new ArrayList<>();
|
||||
handler = new ServerCallHandler<String, Integer>() {
|
||||
@Override
|
||||
public ServerCall.Listener<String> startCall(
|
||||
|
@ -296,7 +296,7 @@ public class ServerInterceptorsTest {
|
|||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void typedMarshalledMessages() {
|
||||
final List<String> order = new ArrayList<String>();
|
||||
final List<String> order = new ArrayList<>();
|
||||
Marshaller<Holder> marshaller = new Marshaller<Holder>() {
|
||||
@Override
|
||||
public InputStream stream(Holder value) {
|
||||
|
|
|
@ -533,7 +533,7 @@ public class DnsNameResolverTest {
|
|||
@Test
|
||||
public void maybeChooseServiceConfig_clientLanguageMatchesJava() {
|
||||
Map<String, Object> choice = new LinkedHashMap<String, Object>();
|
||||
List<Object> langs = new ArrayList<Object>();
|
||||
List<Object> langs = new ArrayList<>();
|
||||
langs.add("java");
|
||||
choice.put("clientLanguage", langs);
|
||||
choice.put("serviceConfig", serviceConfig);
|
||||
|
@ -544,7 +544,7 @@ public class DnsNameResolverTest {
|
|||
@Test
|
||||
public void maybeChooseServiceConfig_clientLanguageDoesntMatchGo() {
|
||||
Map<String, Object> choice = new LinkedHashMap<String, Object>();
|
||||
List<Object> langs = new ArrayList<Object>();
|
||||
List<Object> langs = new ArrayList<>();
|
||||
langs.add("go");
|
||||
choice.put("clientLanguage", langs);
|
||||
choice.put("serviceConfig", serviceConfig);
|
||||
|
@ -555,7 +555,7 @@ public class DnsNameResolverTest {
|
|||
@Test
|
||||
public void maybeChooseServiceConfig_clientLanguageCaseInsensitive() {
|
||||
Map<String, Object> choice = new LinkedHashMap<String, Object>();
|
||||
List<Object> langs = new ArrayList<Object>();
|
||||
List<Object> langs = new ArrayList<>();
|
||||
langs.add("JAVA");
|
||||
choice.put("clientLanguage", langs);
|
||||
choice.put("serviceConfig", serviceConfig);
|
||||
|
@ -566,7 +566,7 @@ public class DnsNameResolverTest {
|
|||
@Test
|
||||
public void maybeChooseServiceConfig_clientLanguageMatchesEmtpy() {
|
||||
Map<String, Object> choice = new LinkedHashMap<String, Object>();
|
||||
List<Object> langs = new ArrayList<Object>();
|
||||
List<Object> langs = new ArrayList<>();
|
||||
choice.put("clientLanguage", langs);
|
||||
choice.put("serviceConfig", serviceConfig);
|
||||
|
||||
|
@ -576,7 +576,7 @@ public class DnsNameResolverTest {
|
|||
@Test
|
||||
public void maybeChooseServiceConfig_clientLanguageMatchesMulti() {
|
||||
Map<String, Object> choice = new LinkedHashMap<String, Object>();
|
||||
List<Object> langs = new ArrayList<Object>();
|
||||
List<Object> langs = new ArrayList<>();
|
||||
langs.add("go");
|
||||
langs.add("java");
|
||||
choice.put("clientLanguage", langs);
|
||||
|
@ -702,7 +702,7 @@ public class DnsNameResolverTest {
|
|||
@Test
|
||||
public void maybeChooseServiceConfig_hostnameMatches() {
|
||||
Map<String, Object> choice = new LinkedHashMap<String, Object>();
|
||||
List<Object> hosts = new ArrayList<Object>();
|
||||
List<Object> hosts = new ArrayList<>();
|
||||
hosts.add("localhost");
|
||||
choice.put("clientHostname", hosts);
|
||||
choice.put("serviceConfig", serviceConfig);
|
||||
|
@ -713,7 +713,7 @@ public class DnsNameResolverTest {
|
|||
@Test
|
||||
public void maybeChooseServiceConfig_hostnameDoesntMatch() {
|
||||
Map<String, Object> choice = new LinkedHashMap<String, Object>();
|
||||
List<Object> hosts = new ArrayList<Object>();
|
||||
List<Object> hosts = new ArrayList<>();
|
||||
hosts.add("localhorse");
|
||||
choice.put("clientHostname", hosts);
|
||||
choice.put("serviceConfig", serviceConfig);
|
||||
|
@ -724,7 +724,7 @@ public class DnsNameResolverTest {
|
|||
@Test
|
||||
public void maybeChooseServiceConfig_clientLanguageCaseSensitive() {
|
||||
Map<String, Object> choice = new LinkedHashMap<String, Object>();
|
||||
List<Object> hosts = new ArrayList<Object>();
|
||||
List<Object> hosts = new ArrayList<>();
|
||||
hosts.add("LOCALHOST");
|
||||
choice.put("clientHostname", hosts);
|
||||
choice.put("serviceConfig", serviceConfig);
|
||||
|
@ -735,7 +735,7 @@ public class DnsNameResolverTest {
|
|||
@Test
|
||||
public void maybeChooseServiceConfig_hostnameMatchesEmtpy() {
|
||||
Map<String, Object> choice = new LinkedHashMap<String, Object>();
|
||||
List<Object> hosts = new ArrayList<Object>();
|
||||
List<Object> hosts = new ArrayList<>();
|
||||
choice.put("clientHostname", hosts);
|
||||
choice.put("serviceConfig", serviceConfig);
|
||||
|
||||
|
@ -745,7 +745,7 @@ public class DnsNameResolverTest {
|
|||
@Test
|
||||
public void maybeChooseServiceConfig_hostnameMatchesMulti() {
|
||||
Map<String, Object> choice = new LinkedHashMap<String, Object>();
|
||||
List<Object> hosts = new ArrayList<Object>();
|
||||
List<Object> hosts = new ArrayList<>();
|
||||
hosts.add("localhorse");
|
||||
hosts.add("localhost");
|
||||
choice.put("clientHostname", hosts);
|
||||
|
@ -773,7 +773,7 @@ public class DnsNameResolverTest {
|
|||
private byte lastByte = 0;
|
||||
|
||||
private List<InetAddress> createAddressList(int n) throws UnknownHostException {
|
||||
List<InetAddress> list = new ArrayList<InetAddress>(n);
|
||||
List<InetAddress> list = new ArrayList<>(n);
|
||||
for (int i = 0; i < n; i++) {
|
||||
list.add(InetAddress.getByAddress(new byte[] {127, 0, 0, ++lastByte}));
|
||||
}
|
||||
|
|
|
@ -233,7 +233,7 @@ public final class FakeClock {
|
|||
* Return all due tasks.
|
||||
*/
|
||||
public Collection<ScheduledTask> getDueTasks() {
|
||||
ArrayList<ScheduledTask> result = new ArrayList<ScheduledTask>();
|
||||
ArrayList<ScheduledTask> result = new ArrayList<>();
|
||||
for (ScheduledTask task : tasks) {
|
||||
if (task.dueTimeNanos > currentTimeNanos) {
|
||||
continue;
|
||||
|
@ -254,7 +254,7 @@ public final class FakeClock {
|
|||
* Return all unrun tasks accepted by the given filter.
|
||||
*/
|
||||
public Collection<ScheduledTask> getPendingTasks(TaskFilter filter) {
|
||||
ArrayList<ScheduledTask> result = new ArrayList<ScheduledTask>();
|
||||
ArrayList<ScheduledTask> result = new ArrayList<>();
|
||||
for (ScheduledTask task : tasks) {
|
||||
if (filter.shouldAccept(task.command)) {
|
||||
result.add(task);
|
||||
|
|
|
@ -45,7 +45,7 @@ public class JsonParserTest {
|
|||
|
||||
@Test
|
||||
public void emptyArray() throws IOException {
|
||||
assertEquals(new ArrayList<Object>(), JsonParser.parse("[]"));
|
||||
assertEquals(new ArrayList<>(), JsonParser.parse("[]"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -327,7 +327,7 @@ public class ManagedChannelImplIdlenessTest {
|
|||
MockClientTransportInfo t0 = newTransports.poll();
|
||||
t0.listener.transportReady();
|
||||
|
||||
List<SocketAddress> changedList = new ArrayList<SocketAddress>(servers.get(0).getAddresses());
|
||||
List<SocketAddress> changedList = new ArrayList<>(servers.get(0).getAddresses());
|
||||
changedList.add(new FakeSocketAddress("aDifferentServer"));
|
||||
helper.updateSubchannelAddresses(subchannel, new EquivalentAddressGroup(changedList));
|
||||
|
||||
|
@ -417,7 +417,7 @@ public class ManagedChannelImplIdlenessTest {
|
|||
MockClientTransportInfo t0 = newTransports.poll();
|
||||
t0.listener.transportReady();
|
||||
|
||||
List<SocketAddress> changedList = new ArrayList<SocketAddress>(servers.get(0).getAddresses());
|
||||
List<SocketAddress> changedList = new ArrayList<>(servers.get(0).getAddresses());
|
||||
changedList.add(new FakeSocketAddress("aDifferentServer"));
|
||||
helper.updateOobChannelAddresses(oobChannel, new EquivalentAddressGroup(changedList));
|
||||
|
||||
|
|
|
@ -2188,7 +2188,7 @@ public class ManagedChannelImplTest {
|
|||
public void channelTracing_nameResolvedEvent_zeorAndNonzeroBackends() throws Exception {
|
||||
timer.forwardNanos(1234);
|
||||
channelBuilder.maxTraceEvents(10);
|
||||
List<EquivalentAddressGroup> servers = new ArrayList<EquivalentAddressGroup>();
|
||||
List<EquivalentAddressGroup> servers = new ArrayList<>();
|
||||
servers.add(new EquivalentAddressGroup(socketAddress));
|
||||
FakeNameResolverFactory nameResolverFactory =
|
||||
new FakeNameResolverFactory.Builder(expectedUri).setServers(servers).build();
|
||||
|
@ -2222,7 +2222,7 @@ public class ManagedChannelImplTest {
|
|||
public void channelTracing_serviceConfigChange() throws Exception {
|
||||
timer.forwardNanos(1234);
|
||||
channelBuilder.maxTraceEvents(10);
|
||||
List<EquivalentAddressGroup> servers = new ArrayList<EquivalentAddressGroup>();
|
||||
List<EquivalentAddressGroup> servers = new ArrayList<>();
|
||||
servers.add(new EquivalentAddressGroup(socketAddress));
|
||||
FakeNameResolverFactory nameResolverFactory =
|
||||
new FakeNameResolverFactory.Builder(expectedUri).setServers(servers).build();
|
||||
|
@ -2836,7 +2836,7 @@ public class ManagedChannelImplTest {
|
|||
final List<EquivalentAddressGroup> servers;
|
||||
final boolean resolvedAtStart;
|
||||
final Status error;
|
||||
final ArrayList<FakeNameResolver> resolvers = new ArrayList<FakeNameResolver>();
|
||||
final ArrayList<FakeNameResolver> resolvers = new ArrayList<>();
|
||||
// The Attributes argument of the next invocation of listener.onAddresses(servers, attrs)
|
||||
final AtomicReference<Attributes> nextResolvedAttributes =
|
||||
new AtomicReference<Attributes>(Attributes.EMPTY);
|
||||
|
|
|
@ -57,7 +57,7 @@ public final class ManagedChannelOrphanWrapperTest {
|
|||
|
||||
// Try to capture the log output but without causing terminal noise. Adding the filter must
|
||||
// be done before clearing the ref or else it might be missed.
|
||||
final List<LogRecord> records = new ArrayList<LogRecord>(1);
|
||||
final List<LogRecord> records = new ArrayList<>(1);
|
||||
Logger orphanLogger = Logger.getLogger(ManagedChannelOrphanWrapper.class.getName());
|
||||
Filter oldFilter = orphanLogger.getFilter();
|
||||
orphanLogger.setFilter(new Filter() {
|
||||
|
|
|
@ -745,7 +745,7 @@ public class RetriableStreamTest {
|
|||
public void isReady_whileDraining() {
|
||||
final AtomicReference<ClientStreamListener> sublistenerCaptor1 =
|
||||
new AtomicReference<ClientStreamListener>();
|
||||
final List<Boolean> readiness = new ArrayList<Boolean>();
|
||||
final List<Boolean> readiness = new ArrayList<>();
|
||||
ClientStream mockStream1 =
|
||||
mock(
|
||||
ClientStream.class,
|
||||
|
|
|
@ -40,7 +40,7 @@ public class SerializeReentrantCallsDirectExecutorTest {
|
|||
}
|
||||
|
||||
@Test public void reentrantCallsShouldBeSerialized() {
|
||||
final List<Integer> callOrder = new ArrayList<Integer>(4);
|
||||
final List<Integer> callOrder = new ArrayList<>(4);
|
||||
executor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -105,7 +105,7 @@ public class SerializeReentrantCallsDirectExecutorTest {
|
|||
|
||||
@Test
|
||||
public void executeCanBeRepeated() {
|
||||
final List<Integer> executes = new ArrayList<Integer>();
|
||||
final List<Integer> executes = new ArrayList<>();
|
||||
executor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.junit.runners.JUnit4;
|
|||
public class SerializingExecutorTest {
|
||||
private SingleExecutor singleExecutor = new SingleExecutor();
|
||||
private SerializingExecutor executor = new SerializingExecutor(singleExecutor);
|
||||
private List<Integer> runs = new ArrayList<Integer>();
|
||||
private List<Integer> runs = new ArrayList<>();
|
||||
|
||||
private class AddToRuns implements Runnable {
|
||||
private final int val;
|
||||
|
|
|
@ -675,7 +675,7 @@ public class RoundRobinLoadBalancerTest {
|
|||
assertEquals(sc2, loadBalancer.getStickinessMapForTest().get("my-sticky-value").value);
|
||||
|
||||
// shutdown channel via name resolver change
|
||||
List<EquivalentAddressGroup> newServers = new ArrayList<EquivalentAddressGroup>(servers);
|
||||
List<EquivalentAddressGroup> newServers = new ArrayList<>(servers);
|
||||
newServers.remove(sc2.getAddresses());
|
||||
|
||||
loadBalancer.handleResolvedAddressGroups(newServers, attributes);
|
||||
|
|
|
@ -51,9 +51,9 @@ public final class CronetCallOptions {
|
|||
Collection<Object> existingAnnotations = callOptions.getOption(CRONET_ANNOTATIONS_KEY);
|
||||
ArrayList<Object> newAnnotations;
|
||||
if (existingAnnotations == null) {
|
||||
newAnnotations = new ArrayList<Object>();
|
||||
newAnnotations = new ArrayList<>();
|
||||
} else {
|
||||
newAnnotations = new ArrayList<Object>(existingAnnotations);
|
||||
newAnnotations = new ArrayList<>(existingAnnotations);
|
||||
}
|
||||
newAnnotations.add(annotation);
|
||||
return callOptions.withOption(
|
||||
|
|
|
@ -504,7 +504,7 @@ class CronetClientStream extends AbstractClientStream {
|
|||
|
||||
private void reportHeaders(List<Map.Entry<String, String>> headers, boolean endOfStream) {
|
||||
// TODO(ericgribkoff): create new utility methods to eliminate all these conversions
|
||||
List<String> headerList = new ArrayList<String>();
|
||||
List<String> headerList = new ArrayList<>();
|
||||
for (Map.Entry<String, String> entry : headers) {
|
||||
headerList.add(entry.getKey());
|
||||
headerList.add(entry.getValue());
|
||||
|
|
|
@ -188,7 +188,7 @@ class CronetClientTransport implements ConnectionClientTransport {
|
|||
synchronized (lock) {
|
||||
// A copy is always necessary since cancel() can call finishStream() which calls
|
||||
// streams.remove()
|
||||
streamsCopy = new ArrayList<CronetClientStream>(streams);
|
||||
streamsCopy = new ArrayList<>(streams);
|
||||
}
|
||||
for (int i = 0; i < streamsCopy.size(); i++) {
|
||||
// Avoid deadlock by calling into stream without lock held
|
||||
|
|
|
@ -79,7 +79,7 @@ public class SafeMethodCachingInterceptorTest {
|
|||
}
|
||||
};
|
||||
|
||||
private final List<String> cacheControlDirectives = new ArrayList<String>();
|
||||
private final List<String> cacheControlDirectives = new ArrayList<>();
|
||||
private ServerInterceptor injectCacheControlInterceptor =
|
||||
new ServerInterceptor() {
|
||||
@Override
|
||||
|
|
|
@ -261,7 +261,7 @@ public class RouteGuideActivity extends AppCompatActivity {
|
|||
@Override
|
||||
public String run(RouteGuideBlockingStub blockingStub, RouteGuideStub asyncStub)
|
||||
throws Exception {
|
||||
List<Point> points = new ArrayList<Point>();
|
||||
List<Point> points = new ArrayList<>();
|
||||
points.add(Point.newBuilder().setLatitude(407838351).setLongitude(-746143763).build());
|
||||
points.add(Point.newBuilder().setLatitude(408122808).setLongitude(-743999179).build());
|
||||
points.add(Point.newBuilder().setLatitude(413628156).setLongitude(-749015468).build());
|
||||
|
|
|
@ -254,7 +254,7 @@ public class RouteGuideClientTest {
|
|||
Feature.newBuilder().setLocation(point3).build();
|
||||
final List<Feature> features = Arrays.asList(
|
||||
requestFeature1, requestFeature2, requestFeature3);
|
||||
final List<Point> pointsDelivered = new ArrayList<Point>();
|
||||
final List<Point> pointsDelivered = new ArrayList<>();
|
||||
final RouteSummary fakeResponse = RouteSummary
|
||||
.newBuilder()
|
||||
.setPointCount(7)
|
||||
|
@ -357,8 +357,8 @@ public class RouteGuideClientTest {
|
|||
public void routeChat_simpleResponse() throws Exception {
|
||||
RouteNote fakeResponse1 = RouteNote.newBuilder().setMessage("dummy msg1").build();
|
||||
RouteNote fakeResponse2 = RouteNote.newBuilder().setMessage("dummy msg2").build();
|
||||
final List<String> messagesDelivered = new ArrayList<String>();
|
||||
final List<Point> locationsDelivered = new ArrayList<Point>();
|
||||
final List<String> messagesDelivered = new ArrayList<>();
|
||||
final List<Point> locationsDelivered = new ArrayList<>();
|
||||
final AtomicReference<StreamObserver<RouteNote>> responseObserverRef =
|
||||
new AtomicReference<StreamObserver<RouteNote>>();
|
||||
final CountDownLatch allRequestsDelivered = new CountDownLatch(1);
|
||||
|
@ -428,7 +428,7 @@ public class RouteGuideClientTest {
|
|||
*/
|
||||
@Test
|
||||
public void routeChat_echoResponse() throws Exception {
|
||||
final List<RouteNote> notesDelivered = new ArrayList<RouteNote>();
|
||||
final List<RouteNote> notesDelivered = new ArrayList<>();
|
||||
|
||||
// implement the fake service
|
||||
RouteGuideImplBase routeChatImpl =
|
||||
|
@ -476,7 +476,7 @@ public class RouteGuideClientTest {
|
|||
*/
|
||||
@Test
|
||||
public void routeChat_errorResponse() throws Exception {
|
||||
final List<RouteNote> notesDelivered = new ArrayList<RouteNote>();
|
||||
final List<RouteNote> notesDelivered = new ArrayList<>();
|
||||
final StatusRuntimeException fakeError = new StatusRuntimeException(Status.PERMISSION_DENIED);
|
||||
|
||||
// implement the fake service
|
||||
|
|
|
@ -68,7 +68,7 @@ public class RouteGuideServerTest {
|
|||
public void setUp() throws Exception {
|
||||
// Generate a unique in-process server name.
|
||||
String serverName = InProcessServerBuilder.generateName();
|
||||
features = new ArrayList<Feature>();
|
||||
features = new ArrayList<>();
|
||||
// Use directExecutor for both InProcessServerBuilder and InProcessChannelBuilder can reduce the
|
||||
// usage timeouts and latches in test. But we still add timeout and latches where they would be
|
||||
// needed if no directExecutor were used, just for demo purpose.
|
||||
|
|
|
@ -87,8 +87,8 @@ class GrpclbLoadBalancer extends LoadBalancer implements InternalWithLogId {
|
|||
public void handleResolvedAddressGroups(
|
||||
List<EquivalentAddressGroup> updatedServers, Attributes attributes) {
|
||||
// LB addresses and backend addresses are treated separately
|
||||
List<LbAddressGroup> newLbAddressGroups = new ArrayList<LbAddressGroup>();
|
||||
List<EquivalentAddressGroup> newBackendServers = new ArrayList<EquivalentAddressGroup>();
|
||||
List<LbAddressGroup> newLbAddressGroups = new ArrayList<>();
|
||||
List<EquivalentAddressGroup> newBackendServers = new ArrayList<>();
|
||||
for (EquivalentAddressGroup server : updatedServers) {
|
||||
String lbAddrAuthority = server.getAttributes().get(GrpcAttributes.ATTR_LB_ADDR_AUTHORITY);
|
||||
if (lbAddrAuthority != null) {
|
||||
|
|
|
@ -238,8 +238,8 @@ final class GrpclbState {
|
|||
usingFallbackBackends = true;
|
||||
logger.log(Level.INFO, "[{0}] Using fallback: {1}", new Object[] {logId, fallbackBackendList});
|
||||
|
||||
List<DropEntry> newDropList = new ArrayList<DropEntry>();
|
||||
List<BackendAddressGroup> newBackendAddrList = new ArrayList<BackendAddressGroup>();
|
||||
List<DropEntry> newDropList = new ArrayList<>();
|
||||
List<BackendAddressGroup> newBackendAddrList = new ArrayList<>();
|
||||
for (EquivalentAddressGroup eag : fallbackBackendList) {
|
||||
newDropList.add(null);
|
||||
newBackendAddrList.add(new BackendAddressGroup(eag, null));
|
||||
|
@ -348,7 +348,7 @@ final class GrpclbState {
|
|||
new Object[] {logId, newBackendAddrList, newDropList});
|
||||
HashMap<EquivalentAddressGroup, Subchannel> newSubchannelMap =
|
||||
new HashMap<EquivalentAddressGroup, Subchannel>();
|
||||
List<BackendEntry> newBackendList = new ArrayList<BackendEntry>();
|
||||
List<BackendEntry> newBackendList = new ArrayList<>();
|
||||
|
||||
for (BackendAddressGroup backendAddr : newBackendAddrList) {
|
||||
EquivalentAddressGroup eag = backendAddr.getAddresses();
|
||||
|
@ -572,8 +572,8 @@ final class GrpclbState {
|
|||
balancerWorking = true;
|
||||
// TODO(zhangkun83): handle delegate from initialResponse
|
||||
ServerList serverList = response.getServerList();
|
||||
List<DropEntry> newDropList = new ArrayList<DropEntry>();
|
||||
List<BackendAddressGroup> newBackendAddrList = new ArrayList<BackendAddressGroup>();
|
||||
List<DropEntry> newDropList = new ArrayList<>();
|
||||
List<BackendAddressGroup> newBackendAddrList = new ArrayList<>();
|
||||
// Construct the new collections. Create new Subchannels when necessary.
|
||||
for (Server server : serverList.getServersList()) {
|
||||
String token = server.getLoadBalanceToken();
|
||||
|
@ -673,7 +673,7 @@ final class GrpclbState {
|
|||
* changed since the last picker created.
|
||||
*/
|
||||
private void maybeUpdatePicker() {
|
||||
List<RoundRobinEntry> pickList = new ArrayList<RoundRobinEntry>(backendList.size());
|
||||
List<RoundRobinEntry> pickList = new ArrayList<>(backendList.size());
|
||||
Status error = null;
|
||||
boolean hasIdle = false;
|
||||
for (BackendEntry entry : backendList) {
|
||||
|
@ -728,7 +728,7 @@ final class GrpclbState {
|
|||
|
||||
private LbAddressGroup flattenLbAddressGroups(List<LbAddressGroup> groupList) {
|
||||
assert !groupList.isEmpty();
|
||||
List<EquivalentAddressGroup> eags = new ArrayList<EquivalentAddressGroup>(groupList.size());
|
||||
List<EquivalentAddressGroup> eags = new ArrayList<>(groupList.size());
|
||||
String authority = groupList.get(0).getAuthority();
|
||||
for (LbAddressGroup group : groupList) {
|
||||
if (!authority.equals(group.getAuthority())) {
|
||||
|
@ -758,7 +758,7 @@ final class GrpclbState {
|
|||
*/
|
||||
private static EquivalentAddressGroup flattenEquivalentAddressGroup(
|
||||
List<EquivalentAddressGroup> groupList, Attributes attrs) {
|
||||
List<SocketAddress> addrs = new ArrayList<SocketAddress>();
|
||||
List<SocketAddress> addrs = new ArrayList<>();
|
||||
for (EquivalentAddressGroup group : groupList) {
|
||||
addrs.addAll(group.getAddresses());
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class CachedSubchannelPoolTest {
|
|||
private final Helper helper = mock(Helper.class);
|
||||
private final FakeClock clock = new FakeClock();
|
||||
private final CachedSubchannelPool pool = new CachedSubchannelPool();
|
||||
private final ArrayList<Subchannel> mockSubchannels = new ArrayList<Subchannel>();
|
||||
private final ArrayList<Subchannel> mockSubchannels = new ArrayList<>();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
|
|
@ -150,9 +150,9 @@ public class GrpclbLoadBalancerTest {
|
|||
new LinkedList<StreamObserver<LoadBalanceRequest>>();
|
||||
private final LinkedList<Subchannel> mockSubchannels = new LinkedList<Subchannel>();
|
||||
private final LinkedList<ManagedChannel> fakeOobChannels = new LinkedList<ManagedChannel>();
|
||||
private final ArrayList<Subchannel> subchannelTracker = new ArrayList<Subchannel>();
|
||||
private final ArrayList<ManagedChannel> oobChannelTracker = new ArrayList<ManagedChannel>();
|
||||
private final ArrayList<String> failingLbAuthorities = new ArrayList<String>();
|
||||
private final ArrayList<Subchannel> subchannelTracker = new ArrayList<>();
|
||||
private final ArrayList<ManagedChannel> oobChannelTracker = new ArrayList<>();
|
||||
private final ArrayList<String> failingLbAuthorities = new ArrayList<>();
|
||||
private final TimeProvider timeProvider = new TimeProvider() {
|
||||
@Override
|
||||
public long currentTimeNanos() {
|
||||
|
@ -1305,8 +1305,8 @@ public class GrpclbLoadBalancerTest {
|
|||
|
||||
private List<Subchannel> fallbackTestVerifyUseOfBalancerBackendLists(
|
||||
InOrder inOrder, List<ServerEntry> servers) {
|
||||
ArrayList<EquivalentAddressGroup> addrs = new ArrayList<EquivalentAddressGroup>();
|
||||
ArrayList<String> tokens = new ArrayList<String>();
|
||||
ArrayList<EquivalentAddressGroup> addrs = new ArrayList<>();
|
||||
ArrayList<String> tokens = new ArrayList<>();
|
||||
for (ServerEntry server : servers) {
|
||||
addrs.add(new EquivalentAddressGroup(server.addr, LB_BACKEND_ATTRS));
|
||||
tokens.add(server.token);
|
||||
|
@ -1327,7 +1327,7 @@ public class GrpclbLoadBalancerTest {
|
|||
assertThat(picker.dropList).containsExactlyElementsIn(Collections.nCopies(addrs.size(), null));
|
||||
assertThat(picker.pickList).containsExactly(GrpclbState.BUFFER_ENTRY);
|
||||
assertEquals(addrs.size(), mockSubchannels.size());
|
||||
ArrayList<Subchannel> subchannels = new ArrayList<Subchannel>(mockSubchannels);
|
||||
ArrayList<Subchannel> subchannels = new ArrayList<>(mockSubchannels);
|
||||
mockSubchannels.clear();
|
||||
for (Subchannel subchannel : subchannels) {
|
||||
deliverSubchannelState(subchannel, ConnectivityStateInfo.forNonError(CONNECTING));
|
||||
|
@ -1337,7 +1337,7 @@ public class GrpclbLoadBalancerTest {
|
|||
inOrder.verify(helper, never())
|
||||
.updateBalancingState(any(ConnectivityState.class), any(SubchannelPicker.class));
|
||||
|
||||
ArrayList<BackendEntry> pickList = new ArrayList<BackendEntry>();
|
||||
ArrayList<BackendEntry> pickList = new ArrayList<>();
|
||||
for (int i = 0; i < addrs.size(); i++) {
|
||||
Subchannel subchannel = subchannels.get(i);
|
||||
BackendEntry backend;
|
||||
|
@ -1521,7 +1521,7 @@ public class GrpclbLoadBalancerTest {
|
|||
}
|
||||
|
||||
private static List<EquivalentAddressGroup> createResolvedServerAddresses(boolean ... isLb) {
|
||||
ArrayList<EquivalentAddressGroup> list = new ArrayList<EquivalentAddressGroup>();
|
||||
ArrayList<EquivalentAddressGroup> list = new ArrayList<>();
|
||||
for (int i = 0; i < isLb.length; i++) {
|
||||
SocketAddress addr = new FakeSocketAddress("fake-address-" + i);
|
||||
EquivalentAddressGroup eag =
|
||||
|
|
|
@ -824,7 +824,7 @@ public abstract class AbstractInteropTest {
|
|||
|
||||
final int numRequests = 10;
|
||||
List<StreamingOutputCallRequest> requests =
|
||||
new ArrayList<StreamingOutputCallRequest>(numRequests);
|
||||
new ArrayList<>(numRequests);
|
||||
for (int ix = numRequests; ix > 0; --ix) {
|
||||
requests.add(request);
|
||||
requestStream.onNext(request);
|
||||
|
@ -863,7 +863,7 @@ public abstract class AbstractInteropTest {
|
|||
|
||||
final int numRequests = 10;
|
||||
List<StreamingOutputCallRequest> requests =
|
||||
new ArrayList<StreamingOutputCallRequest>(numRequests);
|
||||
new ArrayList<>(numRequests);
|
||||
for (int ix = numRequests; ix > 0; --ix) {
|
||||
requests.add(request);
|
||||
requestStream.onNext(request);
|
||||
|
@ -1030,7 +1030,7 @@ public abstract class AbstractInteropTest {
|
|||
|
||||
final int numRequests = 10;
|
||||
List<StreamingOutputCallRequest> requests =
|
||||
new ArrayList<StreamingOutputCallRequest>(numRequests);
|
||||
new ArrayList<>(numRequests);
|
||||
|
||||
for (int ix = numRequests; ix > 0; --ix) {
|
||||
requests.add(request);
|
||||
|
|
|
@ -282,7 +282,7 @@ public final class Http2Client {
|
|||
|
||||
private class RstStreamObserver implements StreamObserver<SimpleResponse> {
|
||||
private final CountDownLatch latch = new CountDownLatch(1);
|
||||
private final List<SimpleResponse> responses = new ArrayList<SimpleResponse>();
|
||||
private final List<SimpleResponse> responses = new ArrayList<>();
|
||||
private Throwable error;
|
||||
|
||||
@Override
|
||||
|
|
|
@ -97,7 +97,7 @@ public class StressTestClient {
|
|||
|
||||
private List<InetSocketAddress> addresses =
|
||||
singletonList(new InetSocketAddress("localhost", 8080));
|
||||
private List<TestCaseWeightPair> testCaseWeightPairs = new ArrayList<TestCaseWeightPair>();
|
||||
private List<TestCaseWeightPair> testCaseWeightPairs = new ArrayList<>();
|
||||
|
||||
private String serverHostOverride;
|
||||
private boolean useTls = false;
|
||||
|
@ -118,7 +118,7 @@ public class StressTestClient {
|
|||
*/
|
||||
private final List<ListenableFuture<?>> workerFutures =
|
||||
new ArrayList<ListenableFuture<?>>();
|
||||
private final List<ManagedChannel> channels = new ArrayList<ManagedChannel>();
|
||||
private final List<ManagedChannel> channels = new ArrayList<>();
|
||||
private ListeningExecutorService threadpool;
|
||||
|
||||
@VisibleForTesting
|
||||
|
@ -291,7 +291,7 @@ public class StressTestClient {
|
|||
}
|
||||
|
||||
private List<InetSocketAddress> parseServerAddresses(String addressesStr) {
|
||||
List<InetSocketAddress> addresses = new ArrayList<InetSocketAddress>();
|
||||
List<InetSocketAddress> addresses = new ArrayList<>();
|
||||
|
||||
for (List<String> namePort : parseCommaSeparatedTuples(addressesStr)) {
|
||||
InetAddress address;
|
||||
|
@ -313,7 +313,7 @@ public class StressTestClient {
|
|||
}
|
||||
|
||||
private static List<TestCaseWeightPair> parseTestCases(String testCasesStr) {
|
||||
List<TestCaseWeightPair> testCaseWeightPairs = new ArrayList<TestCaseWeightPair>();
|
||||
List<TestCaseWeightPair> testCaseWeightPairs = new ArrayList<>();
|
||||
|
||||
for (List<String> nameWeight : parseCommaSeparatedTuples(testCasesStr)) {
|
||||
TestCases testCase = TestCases.fromString(nameWeight.get(0));
|
||||
|
@ -355,7 +355,7 @@ public class StressTestClient {
|
|||
}
|
||||
|
||||
private static String serverAddressesToString(List<InetSocketAddress> addresses) {
|
||||
List<String> tmp = new ArrayList<String>();
|
||||
List<String> tmp = new ArrayList<>();
|
||||
for (InetSocketAddress address : addresses) {
|
||||
URI uri;
|
||||
try {
|
||||
|
@ -541,7 +541,7 @@ public class StressTestClient {
|
|||
Preconditions.checkNotNull(testCaseWeightPairs, "testCaseWeightPairs");
|
||||
Preconditions.checkArgument(testCaseWeightPairs.size() > 0);
|
||||
|
||||
List<TestCases> testCases = new ArrayList<TestCases>();
|
||||
List<TestCases> testCases = new ArrayList<>();
|
||||
for (TestCaseWeightPair testCaseWeightPair : testCaseWeightPairs) {
|
||||
for (int i = 0; i < testCaseWeightPair.weight; i++) {
|
||||
testCases.add(testCaseWeightPair.testCase);
|
||||
|
|
|
@ -132,7 +132,7 @@ class GrpcHttp2HeadersUtils {
|
|||
@Override
|
||||
public List<CharSequence> getAll(CharSequence csName) {
|
||||
AsciiString name = requireAsciiString(csName);
|
||||
List<CharSequence> returnValues = new ArrayList<CharSequence>(4);
|
||||
List<CharSequence> returnValues = new ArrayList<>(4);
|
||||
for (int i = 0; i < namesAndValuesIdx; i += 2) {
|
||||
if (equals(name, namesAndValues[i])) {
|
||||
returnValues.add(values[i / 2]);
|
||||
|
|
|
@ -104,7 +104,7 @@ public class NettyClientTransportTest {
|
|||
@Mock
|
||||
private ManagedClientTransport.Listener clientTransportListener;
|
||||
|
||||
private final List<NettyClientTransport> transports = new ArrayList<NettyClientTransport>();
|
||||
private final List<NettyClientTransport> transports = new ArrayList<>();
|
||||
private final NioEventLoopGroup group = new NioEventLoopGroup(1);
|
||||
private final EchoServerListener serverListener = new EchoServerListener();
|
||||
private final InternalChannelz channelz = new InternalChannelz();
|
||||
|
@ -236,7 +236,7 @@ public class NettyClientTransportTest {
|
|||
}
|
||||
|
||||
// Send a single RPC on each transport.
|
||||
final List<Rpc> rpcs = new ArrayList<Rpc>(transports.size());
|
||||
final List<Rpc> rpcs = new ArrayList<>(transports.size());
|
||||
for (NettyClientTransport transport : transports) {
|
||||
rpcs.add(new Rpc(transport).halfClose());
|
||||
}
|
||||
|
@ -750,7 +750,7 @@ public class NettyClientTransportTest {
|
|||
}
|
||||
|
||||
private static final class EchoServerListener implements ServerListener {
|
||||
final List<NettyServerTransport> transports = new ArrayList<NettyServerTransport>();
|
||||
final List<NettyServerTransport> transports = new ArrayList<>();
|
||||
final List<EchoServerStreamListener> streamListeners =
|
||||
Collections.synchronizedList(new ArrayList<EchoServerStreamListener>());
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ class Headers {
|
|||
headers.discardAll(GrpcUtil.USER_AGENT_KEY);
|
||||
|
||||
// 7 is the number of explicit add calls below.
|
||||
List<Header> okhttpHeaders = new ArrayList<Header>(7 + InternalMetadata.headerCount(headers));
|
||||
List<Header> okhttpHeaders = new ArrayList<>(7 + InternalMetadata.headerCount(headers));
|
||||
|
||||
// Set GRPC-specific headers.
|
||||
okhttpHeaders.add(SCHEME_HEADER);
|
||||
|
|
|
@ -1938,7 +1938,7 @@ public class OkHttpClientTransportTest {
|
|||
Metadata trailers;
|
||||
RpcProgress rpcProgress;
|
||||
CountDownLatch closed = new CountDownLatch(1);
|
||||
ArrayList<String> messages = new ArrayList<String>();
|
||||
ArrayList<String> messages = new ArrayList<>();
|
||||
boolean onReadyCalled;
|
||||
|
||||
MockStreamListener() {
|
||||
|
|
|
@ -123,14 +123,14 @@ public final class OkHostnameVerifier implements HostnameVerifier {
|
|||
public static List<String> allSubjectAltNames(X509Certificate certificate) {
|
||||
List<String> altIpaNames = getSubjectAltNames(certificate, ALT_IPA_NAME);
|
||||
List<String> altDnsNames = getSubjectAltNames(certificate, ALT_DNS_NAME);
|
||||
List<String> result = new ArrayList<String>(altIpaNames.size() + altDnsNames.size());
|
||||
List<String> result = new ArrayList<>(altIpaNames.size() + altDnsNames.size());
|
||||
result.addAll(altIpaNames);
|
||||
result.addAll(altDnsNames);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static List<String> getSubjectAltNames(X509Certificate certificate, int type) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
List<String> result = new ArrayList<>();
|
||||
try {
|
||||
Collection<?> subjectAltNames = certificate.getSubjectAlternativeNames();
|
||||
if (subjectAltNames == null) {
|
||||
|
|
|
@ -449,7 +449,7 @@ public class Platform {
|
|||
public void configureTlsExtensions(
|
||||
SSLSocket sslSocket, String hostname, List<Protocol> protocols) {
|
||||
SSLParameters parameters = sslSocket.getSSLParameters();
|
||||
List<String> names = new ArrayList<String>(protocols.size());
|
||||
List<String> names = new ArrayList<>(protocols.size());
|
||||
for (Protocol protocol : protocols) {
|
||||
if (protocol == Protocol.HTTP_1_0) continue; // No HTTP/1.0 for ALPN.
|
||||
names.add(protocol.toString());
|
||||
|
@ -505,7 +505,7 @@ public class Platform {
|
|||
|
||||
@Override public void configureTlsExtensions(
|
||||
SSLSocket sslSocket, String hostname, List<Protocol> protocols) {
|
||||
List<String> names = new ArrayList<String>(protocols.size());
|
||||
List<String> names = new ArrayList<>(protocols.size());
|
||||
for (int i = 0, size = protocols.size(); i < size; i++) {
|
||||
Protocol protocol = protocols.get(i);
|
||||
if (protocol == Protocol.HTTP_1_0) continue; // No HTTP/1.0 for ALPN.
|
||||
|
|
|
@ -212,7 +212,7 @@ public final class Util {
|
|||
|
||||
/** Returns an immutable copy of {@code list}. */
|
||||
public static <T> List<T> immutableList(List<T> list) {
|
||||
return Collections.unmodifiableList(new ArrayList<T>(list));
|
||||
return Collections.unmodifiableList(new ArrayList<>(list));
|
||||
}
|
||||
|
||||
/** Returns an immutable list containing {@code elements}. */
|
||||
|
@ -250,7 +250,7 @@ public final class Util {
|
|||
* {@code second}. The returned elements are in the same order as in {@code first}.
|
||||
*/
|
||||
private static <T> List<T> intersect(T[] first, T[] second) {
|
||||
List<T> result = new ArrayList<T>();
|
||||
List<T> result = new ArrayList<>();
|
||||
for (T a : first) {
|
||||
for (T b : second) {
|
||||
if (a.equals(b)) {
|
||||
|
|
|
@ -35,7 +35,7 @@ import static org.junit.Assert.fail;
|
|||
public class HpackTest {
|
||||
|
||||
private static List<Header> headerEntries(String... elements) {
|
||||
List<Header> result = new ArrayList<Header>(elements.length / 2);
|
||||
List<Header> result = new ArrayList<>(elements.length / 2);
|
||||
for (int i = 0; i < elements.length; i += 2) {
|
||||
result.add(new Header(elements[i], elements[i + 1]));
|
||||
}
|
||||
|
|
|
@ -323,7 +323,7 @@ final class ChannelzProtoUtil {
|
|||
|
||||
static List<SocketOption> toSocketOptionsList(InternalChannelz.SocketOptions options) {
|
||||
Preconditions.checkNotNull(options);
|
||||
List<SocketOption> ret = new ArrayList<SocketOption>();
|
||||
List<SocketOption> ret = new ArrayList<>();
|
||||
if (options.lingerSeconds != null) {
|
||||
ret.add(toSocketOptionLinger(options.lingerSeconds));
|
||||
}
|
||||
|
@ -379,7 +379,7 @@ final class ChannelzProtoUtil {
|
|||
}
|
||||
|
||||
private static List<ChannelTraceEvent> toChannelTraceEvents(List<Event> events) {
|
||||
List<ChannelTraceEvent> channelTraceEvents = new ArrayList<ChannelTraceEvent>();
|
||||
List<ChannelTraceEvent> channelTraceEvents = new ArrayList<>();
|
||||
for (Event event : events) {
|
||||
ChannelTraceEvent.Builder builder = ChannelTraceEvent.newBuilder()
|
||||
.setDescription(event.description)
|
||||
|
|
|
@ -589,7 +589,7 @@ public class ProtoReflectionServiceTest {
|
|||
private static class FlowControlClientResponseObserver
|
||||
implements ClientResponseObserver<ServerReflectionRequest, ServerReflectionResponse> {
|
||||
private final List<ServerReflectionResponse> responses =
|
||||
new ArrayList<ServerReflectionResponse>();
|
||||
new ArrayList<>();
|
||||
private boolean onCompleteCalled = false;
|
||||
|
||||
@Override
|
||||
|
|
|
@ -146,7 +146,7 @@ public class BinaryLogProviderTest {
|
|||
};
|
||||
Channel wChannel = binlogProvider.wrapChannel(channel);
|
||||
ClientCall<String, Integer> clientCall = wChannel.newCall(method, CallOptions.DEFAULT);
|
||||
final List<Integer> observedResponse = new ArrayList<Integer>();
|
||||
final List<Integer> observedResponse = new ArrayList<>();
|
||||
clientCall.start(
|
||||
new NoopClientCall.NoopClientCallListener<Integer>() {
|
||||
@Override
|
||||
|
@ -224,7 +224,7 @@ public class BinaryLogProviderTest {
|
|||
@Test
|
||||
public void wrapMethodDefinition_handler() throws Exception {
|
||||
// The request as seen by the user supplied server code
|
||||
final List<String> observedRequest = new ArrayList<String>();
|
||||
final List<String> observedRequest = new ArrayList<>();
|
||||
final AtomicReference<ServerCall<String, Integer>> serverCall =
|
||||
new AtomicReference<ServerCall<String, Integer>>();
|
||||
ServerMethodDefinition<String, Integer> methodDef =
|
||||
|
@ -244,7 +244,7 @@ public class BinaryLogProviderTest {
|
|||
}
|
||||
});
|
||||
ServerMethodDefinition<?, ?> wDef = binlogProvider.wrapMethodDefinition(methodDef);
|
||||
List<Object> serializedResp = new ArrayList<Object>();
|
||||
List<Object> serializedResp = new ArrayList<>();
|
||||
ServerCall.Listener<?> wListener = startServerCallHelper(wDef, serializedResp);
|
||||
|
||||
String expectedRequest = "hello world";
|
||||
|
|
|
@ -244,7 +244,7 @@ public class ClientCallsTest {
|
|||
throws Exception {
|
||||
final AtomicReference<ClientCall.Listener<String>> listener =
|
||||
new AtomicReference<ClientCall.Listener<String>>();
|
||||
final List<Integer> requests = new ArrayList<Integer>();
|
||||
final List<Integer> requests = new ArrayList<>();
|
||||
NoopClientCall<Integer, String> call = new NoopClientCall<Integer, String>() {
|
||||
@Override
|
||||
public void start(io.grpc.ClientCall.Listener<String> responseListener, Metadata headers) {
|
||||
|
@ -305,7 +305,7 @@ public class ClientCallsTest {
|
|||
};
|
||||
final AtomicReference<ClientCall.Listener<String>> listener =
|
||||
new AtomicReference<ClientCall.Listener<String>>();
|
||||
final List<Integer> requests = new ArrayList<Integer>();
|
||||
final List<Integer> requests = new ArrayList<>();
|
||||
NoopClientCall<Integer, String> call = new NoopClientCall<Integer, String>() {
|
||||
@Override
|
||||
public void start(io.grpc.ClientCall.Listener<String> responseListener, Metadata headers) {
|
||||
|
@ -351,7 +351,7 @@ public class ClientCallsTest {
|
|||
};
|
||||
final AtomicReference<ClientCall.Listener<String>> listener =
|
||||
new AtomicReference<ClientCall.Listener<String>>();
|
||||
final List<Integer> requests = new ArrayList<Integer>();
|
||||
final List<Integer> requests = new ArrayList<>();
|
||||
NoopClientCall<Integer, String> call = new NoopClientCall<Integer, String>() {
|
||||
@Override
|
||||
public void start(io.grpc.ClientCall.Listener<String> responseListener, Metadata headers) {
|
||||
|
@ -407,7 +407,7 @@ public class ClientCallsTest {
|
|||
final ClientCall<Integer, Integer> clientCall = channel.newCall(STREAMING_METHOD,
|
||||
CallOptions.DEFAULT);
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final List<Object> receivedMessages = new ArrayList<Object>(6);
|
||||
final List<Object> receivedMessages = new ArrayList<>(6);
|
||||
|
||||
ClientResponseObserver<Integer, Integer> responseObserver =
|
||||
new ClientResponseObserver<Integer, Integer>() {
|
||||
|
@ -449,7 +449,7 @@ public class ClientCallsTest {
|
|||
@Test
|
||||
public void inprocessTransportOutboundFlowControl() throws Exception {
|
||||
final Semaphore semaphore = new Semaphore(0);
|
||||
final List<Object> receivedMessages = new ArrayList<Object>(6);
|
||||
final List<Object> receivedMessages = new ArrayList<>(6);
|
||||
final SettableFuture<ServerCallStreamObserver<Integer>> observerFuture
|
||||
= SettableFuture.create();
|
||||
ServerServiceDefinition service = ServerServiceDefinition.builder(
|
||||
|
|
|
@ -461,8 +461,8 @@ public class ServerCallsTest {
|
|||
|
||||
private static class ServerCallRecorder extends ServerCall<Integer, Integer> {
|
||||
private final MethodDescriptor<Integer, Integer> methodDescriptor;
|
||||
private final List<Integer> requestCalls = new ArrayList<Integer>();
|
||||
private final List<Integer> responses = new ArrayList<Integer>();
|
||||
private final List<Integer> requestCalls = new ArrayList<>();
|
||||
private final List<Integer> responses = new ArrayList<>();
|
||||
private Metadata headers;
|
||||
private Metadata trailers;
|
||||
private Status status;
|
||||
|
|
|
@ -90,7 +90,7 @@ public class TestUtils {
|
|||
} catch (NoSuchAlgorithmException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
List<String> ciphersMinusGcm = new ArrayList<String>();
|
||||
List<String> ciphersMinusGcm = new ArrayList<>();
|
||||
for (String cipher : ciphers) {
|
||||
// The GCM implementation in Java is _very_ slow (~1 MB/s)
|
||||
if (cipher.contains("_GCM_")) {
|
||||
|
|
|
@ -47,7 +47,7 @@ import org.junit.runners.model.Statement;
|
|||
@NotThreadSafe
|
||||
public final class GrpcCleanupRule implements TestRule {
|
||||
|
||||
private final List<Resource> resources = new ArrayList<Resource>();
|
||||
private final List<Resource> resources = new ArrayList<>();
|
||||
private long timeoutNanos = TimeUnit.SECONDS.toNanos(10L);
|
||||
private Stopwatch stopwatch = Stopwatch.createUnstarted();
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ public class TestUtils {
|
|||
} catch (NoSuchAlgorithmException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
List<String> ciphersMinusGcm = new ArrayList<String>();
|
||||
List<String> ciphersMinusGcm = new ArrayList<>();
|
||||
for (String cipher : ciphers) {
|
||||
// The GCM implementation in Java is _very_ slow (~1 MB/s)
|
||||
if (cipher.contains("_GCM_")) {
|
||||
|
|
Loading…
Reference in New Issue