Skip to content

Commit 3a39b81

Browse files
all: remove java6 type args
1 parent a31473e commit 3a39b81

File tree

145 files changed

+486
-489
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+486
-489
lines changed

alts/src/main/java/io/grpc/alts/internal/AltsHandshakerStub.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class AltsHandshakerStub {
2929
private final StreamObserver<HandshakerResp> reader = new Reader();
3030
private final StreamObserver<HandshakerReq> writer;
3131
private final ArrayBlockingQueue<Optional<HandshakerResp>> responseQueue =
32-
new ArrayBlockingQueue<Optional<HandshakerResp>>(1);
32+
new ArrayBlockingQueue<>(1);
3333
private final AtomicReference<String> exceptionMessage = new AtomicReference<>();
3434

3535
AltsHandshakerStub(HandshakerServiceStub serviceStub) {

alts/src/main/java/io/grpc/alts/internal/AltsTsiHandshaker.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public boolean processBytesFromPeer(ByteBuffer bytes) throws GeneralSecurityExce
9999
@Override
100100
public TsiPeer extractPeer() throws GeneralSecurityException {
101101
Preconditions.checkState(!isInProgress(), "Handshake is not complete.");
102-
List<TsiPeer.Property<?>> peerProperties = new ArrayList<TsiPeer.Property<?>>();
102+
List<TsiPeer.Property<?>> peerProperties = new ArrayList<>();
103103
peerProperties.add(
104104
new TsiPeer.StringProperty(
105105
TSI_SERVICE_ACCOUNT_PEER_PROPERTY,

alts/src/test/java/io/grpc/alts/internal/AltsProtocolNegotiatorTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public void operationComplete(ChannelFuture future) throws Exception {
210210

211211
// Capture the protected data written to the wire.
212212
assertEquals(1, channel.outboundMessages().size());
213-
ByteBuf protectedData = channel.<ByteBuf>readOutbound();
213+
ByteBuf protectedData = channel.readOutbound();
214214
assertEquals(message.length(), writeCount.get());
215215

216216
// Read the protected message at the server and verify it matches the original message.
@@ -276,7 +276,7 @@ public void accept(ByteBuf buf) {
276276
// Read the protected message at the client and verify that it matches the original message.
277277
assertEquals(1, channel.inboundMessages().size());
278278

279-
ByteBuf receivedData1 = channel.<ByteBuf>readInbound();
279+
ByteBuf receivedData1 = channel.readInbound();
280280
int receivedLen1 = receivedData1.readableBytes();
281281
byte[] receivedBytes = new byte[receivedLen1];
282282
receivedData1.readBytes(receivedBytes, 0, receivedLen1);
@@ -364,7 +364,7 @@ public void peerPropagated() throws Exception {
364364
private void doHandshake() throws Exception {
365365
// Capture the client frame and add to the server.
366366
assertEquals(1, channel.outboundMessages().size());
367-
ByteBuf clientFrame = channel.<ByteBuf>readOutbound();
367+
ByteBuf clientFrame = channel.readOutbound();
368368
assertTrue(serverHandshaker.processBytesFromPeer(clientFrame));
369369

370370
// Get the server response handshake frames.
@@ -374,7 +374,7 @@ private void doHandshake() throws Exception {
374374

375375
// Capture the next client frame and add to the server.
376376
assertEquals(1, channel.outboundMessages().size());
377-
clientFrame = channel.<ByteBuf>readOutbound();
377+
clientFrame = channel.readOutbound();
378378
assertTrue(serverHandshaker.processBytesFromPeer(clientFrame));
379379

380380
// Get the server response handshake frames.

auth/src/test/java/io/grpc/auth/GoogleAuthLibraryCallCredentialsTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public void credentialsReturnNullMetadata() throws Exception {
221221
ListMultimap<String, String> values = LinkedListMultimap.create();
222222
values.put("Authorization", "token1");
223223
when(credentials.getRequestMetadata(eq(expectedUri)))
224-
.thenReturn(null, Multimaps.<String, String>asMap(values), null);
224+
.thenReturn(null, Multimaps.asMap(values), null);
225225

226226
GoogleAuthLibraryCallCredentials callCredentials =
227227
new GoogleAuthLibraryCallCredentials(credentials);

benchmarks/src/jmh/java/io/grpc/benchmarks/netty/AbstractBenchmark.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ protected CountDownLatch startStreamingCalls(int callsPerChannel, final AtomicLo
432432
final ClientCall<ByteBuf, ByteBuf> streamingCall =
433433
channel.newCall(pingPongMethod, CALL_OPTIONS);
434434
final AtomicReference<StreamObserver<ByteBuf>> requestObserverRef =
435-
new AtomicReference<StreamObserver<ByteBuf>>();
435+
new AtomicReference<>();
436436
final AtomicBoolean ignoreMessages = new AtomicBoolean();
437437
StreamObserver<ByteBuf> requestObserver = ClientCalls.asyncBidiStreamingCall(
438438
streamingCall,
@@ -486,7 +486,7 @@ protected CountDownLatch startFlowControlledStreamingCalls(int callsPerChannel,
486486
final ClientCall<ByteBuf, ByteBuf> streamingCall =
487487
channel.newCall(flowControlledStreaming, CALL_OPTIONS);
488488
final AtomicReference<StreamObserver<ByteBuf>> requestObserverRef =
489-
new AtomicReference<StreamObserver<ByteBuf>>();
489+
new AtomicReference<>();
490490
final AtomicBoolean ignoreMessages = new AtomicBoolean();
491491
StreamObserver<ByteBuf> requestObserver = ClientCalls.asyncBidiStreamingCall(
492492
streamingCall,

benchmarks/src/main/java/io/grpc/benchmarks/driver/LoadClient.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ public void run() {
379379
while (!shutdown) {
380380
maxOutstanding.acquireUninterruptibly();
381381
final AtomicReference<StreamObserver<Messages.SimpleRequest>> requestObserver =
382-
new AtomicReference<StreamObserver<Messages.SimpleRequest>>();
382+
new AtomicReference<>();
383383
requestObserver.set(stub.streamingCall(
384384
new StreamObserver<Messages.SimpleResponse>() {
385385
long now = System.nanoTime();

benchmarks/src/main/java/io/grpc/benchmarks/qps/AbstractConfigurationBuilder.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ protected interface Param {
109109
public final T build(String[] args) {
110110
T config = newConfiguration();
111111
Map<String, Param> paramMap = getParamMap();
112-
Set<String> appliedParams = new TreeSet<String>(CASE_INSENSITIVE_ORDER);
112+
Set<String> appliedParams = new TreeSet<>(CASE_INSENSITIVE_ORDER);
113113

114114
for (String arg : args) {
115115
if (!arg.startsWith("--")) {
@@ -197,7 +197,7 @@ public final void printUsage() {
197197
protected abstract T build0(T config);
198198

199199
private Map<String, Param> getParamMap() {
200-
Map<String, Param> map = new TreeMap<String, Param>(CASE_INSENSITIVE_ORDER);
200+
Map<String, Param> map = new TreeMap<>(CASE_INSENSITIVE_ORDER);
201201
for (Param param : getParams()) {
202202
map.put(param.getName(), param);
203203
}

benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncClient.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ private List<Histogram> doBenchmark(SimpleRequest req,
122122
long endTime) throws Exception {
123123
// Initiate the concurrent calls
124124
List<Future<Histogram>> futures =
125-
new ArrayList<Future<Histogram>>(config.outstandingRpcsPerChannel);
125+
new ArrayList<>(config.outstandingRpcsPerChannel);
126126
for (int i = 0; i < config.channels; i++) {
127127
for (int j = 0; j < config.outstandingRpcsPerChannel; j++) {
128128
Channel channel = channels.get(i);

benchmarks/src/test/java/io/grpc/benchmarks/driver/LoadWorkerTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void setup() throws Exception {
5959
worker.start();
6060
channel = NettyChannelBuilder.forAddress("localhost", port).usePlaintext().build();
6161
workerServiceStub = WorkerServiceGrpc.newStub(channel);
62-
marksQueue = new LinkedBlockingQueue<Stats.ClientStats>();
62+
marksQueue = new LinkedBlockingQueue<>();
6363
}
6464

6565
@Test

context/src/jmh/java/io/grpc/ReadBenchmark.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class ReadBenchmark {
3333

3434
@State(Scope.Benchmark)
3535
public static class ContextState {
36-
List<Context.Key<Object>> keys = new ArrayList<Context.Key<Object>>();
36+
List<Context.Key<Object>> keys = new ArrayList<>();
3737
List<Context> contexts = new ArrayList<>();
3838

3939
@Setup

context/src/main/java/io/grpc/Context.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public class Context {
100100
private static final Logger log = Logger.getLogger(Context.class.getName());
101101

102102
private static final PersistentHashArrayMappedTrie<Key<?>, Object> EMPTY_ENTRIES =
103-
new PersistentHashArrayMappedTrie<Key<?>, Object>();
103+
new PersistentHashArrayMappedTrie<>();
104104

105105
// Long chains of contexts are suspicious and usually indicate a misuse of Context.
106106
// The threshold is arbitrarily chosen.
@@ -120,7 +120,7 @@ public class Context {
120120
// much easier to avoid circular loading since there can still be references to Context as long as
121121
// they don't depend on storage, like key() and currentContextExecutor(). It also makes it easier
122122
// to handle exceptions.
123-
private static final AtomicReference<Storage> storage = new AtomicReference<Storage>();
123+
private static final AtomicReference<Storage> storage = new AtomicReference<>();
124124

125125
// For testing
126126
static Storage storage() {
@@ -159,15 +159,15 @@ private static Storage createStorage() {
159159
* the name is intended for debugging purposes and does not impact behavior.
160160
*/
161161
public static <T> Key<T> key(String name) {
162-
return new Key<T>(name);
162+
return new Key<>(name);
163163
}
164164

165165
/**
166166
* Create a {@link Key} with the given debug name and default value. Multiple different keys may
167167
* have the same name; the name is intended for debugging purposes and does not impact behavior.
168168
*/
169169
public static <T> Key<T> keyWithDefault(String name, T defaultValue) {
170-
return new Key<T>(name, defaultValue);
170+
return new Key<>(name, defaultValue);
171171
}
172172

173173
/**

context/src/main/java/io/grpc/PersistentHashArrayMappedTrie.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ public V get(K key) {
6262
*/
6363
public PersistentHashArrayMappedTrie<K,V> put(K key, V value) {
6464
if (root == null) {
65-
return new PersistentHashArrayMappedTrie<K,V>(new Leaf<K,V>(key, value));
65+
return new PersistentHashArrayMappedTrie<>(new Leaf<>(key, value));
6666
} else {
67-
return new PersistentHashArrayMappedTrie<K,V>(root.put(key, value, key.hashCode(), 0));
67+
return new PersistentHashArrayMappedTrie<>(root.put(key, value, key.hashCode(), 0));
6868
}
6969
}
7070

@@ -99,13 +99,13 @@ public Node<K,V> put(K key, V value, int hash, int bitsConsumed) {
9999
if (thisHash != hash) {
100100
// Insert
101101
return CompressedIndex.combine(
102-
new Leaf<K,V>(key, value), hash, this, thisHash, bitsConsumed);
102+
new Leaf<>(key, value), hash, this, thisHash, bitsConsumed);
103103
} else if (this.key == key) {
104104
// Replace
105-
return new Leaf<K,V>(key, value);
105+
return new Leaf<>(key, value);
106106
} else {
107107
// Hash collision
108-
return new CollisionLeaf<K,V>(this.key, this.value, key, value);
108+
return new CollisionLeaf<>(this.key, this.value, key, value);
109109
}
110110
}
111111

@@ -158,21 +158,21 @@ public Node<K,V> put(K key, V value, int hash, int bitsConsumed) {
158158
if (thisHash != hash) {
159159
// Insert
160160
return CompressedIndex.combine(
161-
new Leaf<K,V>(key, value), hash, this, thisHash, bitsConsumed);
161+
new Leaf<>(key, value), hash, this, thisHash, bitsConsumed);
162162
} else if ((keyIndex = indexOfKey(key)) != -1) {
163163
// Replace
164164
K[] newKeys = Arrays.copyOf(keys, keys.length);
165165
V[] newValues = Arrays.copyOf(values, keys.length);
166166
newKeys[keyIndex] = key;
167167
newValues[keyIndex] = value;
168-
return new CollisionLeaf<K,V>(newKeys, newValues);
168+
return new CollisionLeaf<>(newKeys, newValues);
169169
} else {
170170
// Yet another hash collision
171171
K[] newKeys = Arrays.copyOf(keys, keys.length + 1);
172172
V[] newValues = Arrays.copyOf(values, keys.length + 1);
173173
newKeys[keys.length] = key;
174174
newValues[keys.length] = value;
175-
return new CollisionLeaf<K,V>(newKeys, newValues);
175+
return new CollisionLeaf<>(newKeys, newValues);
176176
}
177177
}
178178

@@ -238,14 +238,14 @@ public Node<K,V> put(K key, V value, int hash, int bitsConsumed) {
238238
@SuppressWarnings("unchecked")
239239
Node<K,V>[] newValues = (Node<K,V>[]) new Node<?,?>[values.length + 1];
240240
System.arraycopy(values, 0, newValues, 0, compressedIndex);
241-
newValues[compressedIndex] = new Leaf<K,V>(key, value);
241+
newValues[compressedIndex] = new Leaf<>(key, value);
242242
System.arraycopy(
243243
values,
244244
compressedIndex,
245245
newValues,
246246
compressedIndex + 1,
247247
values.length - compressedIndex);
248-
return new CompressedIndex<K,V>(newBitmap, newValues, size() + 1);
248+
return new CompressedIndex<>(newBitmap, newValues, size() + 1);
249249
} else {
250250
// Replace
251251
Node<K,V>[] newValues = Arrays.copyOf(values, values.length);
@@ -254,7 +254,7 @@ public Node<K,V> put(K key, V value, int hash, int bitsConsumed) {
254254
int newSize = size();
255255
newSize += newValues[compressedIndex].size();
256256
newSize -= values[compressedIndex].size();
257-
return new CompressedIndex<K,V>(bitmap, newValues, newSize);
257+
return new CompressedIndex<>(bitmap, newValues, newSize);
258258
}
259259
}
260260

@@ -267,7 +267,7 @@ static <K,V> Node<K,V> combine(
267267
Node<K,V> node = combine(node1, hash1, node2, hash2, bitsConsumed + BITS);
268268
@SuppressWarnings("unchecked")
269269
Node<K,V>[] values = (Node<K,V>[]) new Node<?,?>[] {node};
270-
return new CompressedIndex<K,V>(indexBit1, values, node.size());
270+
return new CompressedIndex<>(indexBit1, values, node.size());
271271
} else {
272272
// Make node1 the smallest
273273
if (uncompressedIndex(hash1, bitsConsumed) > uncompressedIndex(hash2, bitsConsumed)) {
@@ -277,7 +277,7 @@ static <K,V> Node<K,V> combine(
277277
}
278278
@SuppressWarnings("unchecked")
279279
Node<K,V>[] values = (Node<K,V>[]) new Node<?,?>[] {node1, node2};
280-
return new CompressedIndex<K,V>(indexBit1 | indexBit2, values, node1.size() + node2.size());
280+
return new CompressedIndex<>(indexBit1 | indexBit2, values, node1.size() + node2.size());
281281
}
282282
}
283283

context/src/main/java/io/grpc/ThreadLocalContextStorage.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final class ThreadLocalContextStorage extends Context.Storage {
2929
* Currently bound context.
3030
*/
3131
// VisibleForTesting
32-
static final ThreadLocal<Context> localContext = new ThreadLocal<Context>();
32+
static final ThreadLocal<Context> localContext = new ThreadLocal<>();
3333

3434
@Override
3535
public Context doAttach(Context toAttach) {

context/src/test/java/io/grpc/ContextTest.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public void attachingNonCurrentReturnsCurrent() {
166166

167167
@Test
168168
public void detachingNonCurrentLogsSevereMessage() {
169-
final AtomicReference<LogRecord> logRef = new AtomicReference<LogRecord>();
169+
final AtomicReference<LogRecord> logRef = new AtomicReference<>();
170170
Handler handler = new Handler() {
171171
@Override
172172
public void publish(LogRecord record) {
@@ -284,24 +284,24 @@ public void cancelled(Context context) {
284284
}
285285

286286
Context.CancellableContext base = Context.current().withCancellation();
287-
final AtomicReference<Context> observed1 = new AtomicReference<Context>();
287+
final AtomicReference<Context> observed1 = new AtomicReference<>();
288288
base.addListener(new SetContextCancellationListener(observed1), MoreExecutors.directExecutor());
289-
final AtomicReference<Context> observed2 = new AtomicReference<Context>();
289+
final AtomicReference<Context> observed2 = new AtomicReference<>();
290290
base.addListener(new SetContextCancellationListener(observed2), MoreExecutors.directExecutor());
291291
assertNull(observed1.get());
292292
assertNull(observed2.get());
293293
base.cancel(null);
294294
assertSame(base, observed1.get());
295295
assertSame(base, observed2.get());
296296

297-
final AtomicReference<Context> observed3 = new AtomicReference<Context>();
297+
final AtomicReference<Context> observed3 = new AtomicReference<>();
298298
base.addListener(new SetContextCancellationListener(observed3), MoreExecutors.directExecutor());
299299
assertSame(base, observed3.get());
300300
}
301301

302302
@Test
303303
public void exceptionOfExecutorDoesntThrow() {
304-
final AtomicReference<Throwable> loggedThrowable = new AtomicReference<Throwable>();
304+
final AtomicReference<Throwable> loggedThrowable = new AtomicReference<>();
305305
Handler logHandler = new Handler() {
306306
@Override
307307
public void publish(LogRecord record) {
@@ -325,7 +325,7 @@ public void flush() {}
325325
logger.addHandler(logHandler);
326326
try {
327327
Context.CancellableContext base = Context.current().withCancellation();
328-
final AtomicReference<Runnable> observed1 = new AtomicReference<Runnable>();
328+
final AtomicReference<Runnable> observed1 = new AtomicReference<>();
329329
final Error err = new Error();
330330
base.addListener(cancellationListener, new Executor() {
331331
@Override
@@ -342,7 +342,7 @@ public void execute(Runnable runnable) {
342342

343343
final Error err2 = new Error();
344344
loggedThrowable.set(null);
345-
final AtomicReference<Runnable> observed2 = new AtomicReference<Runnable>();
345+
final AtomicReference<Runnable> observed2 = new AtomicReference<>();
346346
base.addListener(cancellationListener, new Executor() {
347347
@Override
348348
public void execute(Runnable runnable) {
@@ -596,7 +596,7 @@ public void earlierParentDeadlineTakesPrecedenceOverLaterChildDeadline() throws
596596
assertSame(parent.getDeadline(), sooner);
597597
assertSame(child.getDeadline(), sooner);
598598
final CountDownLatch latch = new CountDownLatch(1);
599-
final AtomicReference<Exception> error = new AtomicReference<Exception>();
599+
final AtomicReference<Exception> error = new AtomicReference<>();
600600
child.addListener(new Context.CancellationListener() {
601601
@Override
602602
public void cancelled(Context context) {
@@ -709,7 +709,7 @@ public void cancellationCancelsScheduledTask() {
709709
}
710710

711711
private static class QueuedExecutor implements Executor {
712-
private final Queue<Runnable> runnables = new ArrayDeque<Runnable>();
712+
private final Queue<Runnable> runnables = new ArrayDeque<>();
713713

714714
@Override
715715
public void execute(Runnable r) {
@@ -939,7 +939,7 @@ public void cancellableContext_closeCancelsWithNullCause() throws Exception {
939939

940940
@Test
941941
public void errorWhenAncestryLengthLong() {
942-
final AtomicReference<LogRecord> logRef = new AtomicReference<LogRecord>();
942+
final AtomicReference<LogRecord> logRef = new AtomicReference<>();
943943
Handler handler = new Handler() {
944944
@Override
945945
public void publish(LogRecord record) {

0 commit comments

Comments
 (0)