Skip to content

Commit

Permalink
Use the diamond notation
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Jul 16, 2023
1 parent 0145d1a commit 26f6f99
Show file tree
Hide file tree
Showing 54 changed files with 95 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ Map<Integer, Queue<CachedBuffer>> newPoolMap() {
Map<Integer, Queue<CachedBuffer>> poolMap = new HashMap<>();

for (int i = 0; i < 31; i++) {
poolMap.put(1 << i, new ConcurrentLinkedQueue<CachedBuffer>());
poolMap.put(1 << i, new ConcurrentLinkedQueue<>());
}

poolMap.put(0, new ConcurrentLinkedQueue<CachedBuffer>());
poolMap.put(Integer.MAX_VALUE, new ConcurrentLinkedQueue<CachedBuffer>());
poolMap.put(0, new ConcurrentLinkedQueue<>());
poolMap.put(Integer.MAX_VALUE, new ConcurrentLinkedQueue<>());

return poolMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public abstract class AbstractPollingIoAcceptor<S extends AbstractIoSession, H>

private final Queue<AcceptorOperationFuture> cancelQueue = new ConcurrentLinkedQueue<>();

private final Map<SocketAddress, H> boundHandles = Collections.synchronizedMap(new HashMap<SocketAddress, H>());
private final Map<SocketAddress, H> boundHandles = Collections.synchronizedMap(new HashMap<>());

private final ServiceOperationFuture disposalFuture = new ServiceOperationFuture();

Expand Down Expand Up @@ -116,7 +116,7 @@ public abstract class AbstractPollingIoAcceptor<S extends AbstractIoSession, H>
* type.
*/
protected AbstractPollingIoAcceptor(IoSessionConfig sessionConfig, Class<? extends IoProcessor<S>> processorClass) {
this(sessionConfig, null, new SimpleIoProcessorPool<S>(processorClass), true, null);
this(sessionConfig, null, new SimpleIoProcessorPool<>(processorClass), true, null);
}

/**
Expand All @@ -135,7 +135,7 @@ protected AbstractPollingIoAcceptor(IoSessionConfig sessionConfig, Class<? exten
*/
protected AbstractPollingIoAcceptor(IoSessionConfig sessionConfig, Class<? extends IoProcessor<S>> processorClass,
int processorCount) {
this(sessionConfig, null, new SimpleIoProcessorPool<S>(processorClass, processorCount), true, null);
this(sessionConfig, null, new SimpleIoProcessorPool<>(processorClass, processorCount), true, null);
}

/**
Expand All @@ -155,7 +155,7 @@ protected AbstractPollingIoAcceptor(IoSessionConfig sessionConfig, Class<? exten
*/
protected AbstractPollingIoAcceptor(IoSessionConfig sessionConfig, Class<? extends IoProcessor<S>> processorClass,
int processorCount, SelectorProvider selectorProvider ) {
this(sessionConfig, null, new SimpleIoProcessorPool<S>(processorClass, processorCount, selectorProvider), true, selectorProvider);
this(sessionConfig, null, new SimpleIoProcessorPool<>(processorClass, processorCount, selectorProvider), true, selectorProvider);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public abstract class AbstractPollingIoConnector<S extends AbstractIoSession, H>
* {@link IoSession} type.
*/
protected AbstractPollingIoConnector(IoSessionConfig sessionConfig, Class<? extends IoProcessor<S>> processorClass) {
this(sessionConfig, null, new SimpleIoProcessorPool<S>(processorClass), true);
this(sessionConfig, null, new SimpleIoProcessorPool<>(processorClass), true);
}

/**
Expand All @@ -117,7 +117,7 @@ protected AbstractPollingIoConnector(IoSessionConfig sessionConfig, Class<? exte
*/
protected AbstractPollingIoConnector(IoSessionConfig sessionConfig, Class<? extends IoProcessor<S>> processorClass,
int processorCount) {
this(sessionConfig, null, new SimpleIoProcessorPool<S>(processorClass, processorCount), true);
this(sessionConfig, null, new SimpleIoProcessorPool<>(processorClass, processorCount), true);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ private static List<WriteRequest> asRequestList(Collection<WriteRequest> request
}

// Create a list of requests removing duplicates.
Set<WriteRequest> newRequests = new MapBackedSet<>(new LinkedHashMap<WriteRequest, Boolean>());
Set<WriteRequest> newRequests = new MapBackedSet<>(new LinkedHashMap<>());

for (WriteRequest r : requests) {
newRequests.add(r.getOriginalRequest());
}

return Collections.unmodifiableList(new ArrayList<WriteRequest>(newRequests));
return Collections.unmodifiableList(new ArrayList<>(newRequests));
}

private static List<WriteRequest> asRequestList(WriteRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public BufferedWriteFilter(int bufferSize, LazyInitializedCacheMap<IoSession, Io
super();
this.bufferSize = bufferSize;
if (buffersMap == null) {
this.buffersMap = new LazyInitializedCacheMap<IoSession, IoBuffer>();
this.buffersMap = new LazyInitializedCacheMap<>();
} else {
this.buffersMap = buffersMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public OrderedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long kee
// We have to initialize the pool with default values (0 and 1) in order to
// handle the exception in a better way. We can't add a try {} catch() {}
// around the super() call.
super(DEFAULT_INITIAL_THREAD_POOL_SIZE, 1, keepAliveTime, unit, new SynchronousQueue<Runnable>(),
super(DEFAULT_INITIAL_THREAD_POOL_SIZE, 1, keepAliveTime, unit, new SynchronousQueue<>(),
threadFactory, new AbortPolicy());

if (corePoolSize < DEFAULT_INITIAL_THREAD_POOL_SIZE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public PriorityThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long ke
// handle the exception in a better way. We can't add a try {} catch()
// {}
// around the super() call.
super(DEFAULT_INITIAL_THREAD_POOL_SIZE, 1, keepAliveTime, unit, new SynchronousQueue<Runnable>(), threadFactory,
super(DEFAULT_INITIAL_THREAD_POOL_SIZE, 1, keepAliveTime, unit, new SynchronousQueue<>(), threadFactory,
new AbortPolicy());

if (corePoolSize < DEFAULT_INITIAL_THREAD_POOL_SIZE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public UnorderedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long k
*/
public UnorderedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit,
ThreadFactory threadFactory, IoEventQueueHandler queueHandler) {
super(0, 1, keepAliveTime, unit, new LinkedBlockingQueue<Runnable>(), threadFactory, new AbortPolicy());
super(0, 1, keepAliveTime, unit, new LinkedBlockingQueue<>(), threadFactory, new AbortPolicy());

if (corePoolSize < 0) {
throw new IllegalArgumentException("corePoolSize: " + corePoolSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*/
public class BlacklistFilter extends IoFilterAdapter {
/** The list of blocked addresses */
private final List<Subnet> blacklist = new CopyOnWriteArrayList<Subnet>();
private final List<Subnet> blacklist = new CopyOnWriteArrayList<>();

/** A logger for this class */
private final static Logger LOGGER = LoggerFactory.getLogger(BlacklistFilter.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public ConnectionThrottleFilter() {
*/
public ConnectionThrottleFilter(long allowedInterval) {
this.allowedInterval = allowedInterval;
clients = new ConcurrentHashMap<String, Long>();
clients = new ConcurrentHashMap<>();

// Create the cleanup thread
ExpiredSessionThread cleanupThread = new ExpiredSessionThread();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class SslFilter extends IoFilterAdapter {
* Task executor for processing handshakes
*/
static protected final Executor EXECUTOR = new ThreadPoolExecutor(2, 2, 100, TimeUnit.MILLISECONDS,
new LinkedBlockingDeque<Runnable>(), new BasicThreadFactory("ssl-exec", true));
new LinkedBlockingDeque<>(), new BasicThreadFactory("ssl-exec", true));

protected final SSLContext sslContext;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public void stopProfile(IoEventType type) {
* @return a Set containing all the profiled {@link IoEventType}
*/
public Set<IoEventType> getEventsToProfile() {
Set<IoEventType> set = new HashSet<IoEventType>();
Set<IoEventType> set = new HashSet<>();

if (profileMessageReceived) {
set.add(IoEventType.MESSAGE_RECEIVED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public synchronized IoHandlerCommand remove(String name) {
* @throws Exception If we faced some exception during the cleanup
*/
public synchronized void clear() throws Exception {
Iterator<String> it = new ArrayList<String>(name2entry.keySet()).iterator();
Iterator<String> it = new ArrayList<>(name2entry.keySet()).iterator();

while (it.hasNext()) {
remove(it.next());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected synchronized void flushPendingWriteRequests() throws Exception {
*/
public synchronized void enqueueWriteRequest(final NextFilter nextFilter, final WriteRequest writeRequest) {
if (writeRequestQueue == null) {
writeRequestQueue = new LinkedList<Event>();
writeRequestQueue = new LinkedList<>();
}

writeRequestQueue.offer(new Event(nextFilter, writeRequest));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void doHandshake(final NextFilter nextFilter) throws ProxyAuthException {
// Compute request headers
HttpProxyRequest req = (HttpProxyRequest) getProxyIoSession().getRequest();
Map<String, List<String>> headers = req.getHeaders() != null ? req.getHeaders()
: new HashMap<String, List<String>>();
: new HashMap<>();

AbstractAuthLogicHandler.addKeepAliveHeaders(headers);
req.setHeaders(headers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void doHandshake(final NextFilter nextFilter) throws ProxyAuthException {
// Send request
HttpProxyRequest req = (HttpProxyRequest) request;
Map<String, List<String>> headers = req.getHeaders() != null ? req.getHeaders()
: new HashMap<String, List<String>>();
: new HashMap<>();

String username = req.getProperties().get(HttpProxyConstants.USER_PROPERTY);
String password = req.getProperties().get(HttpProxyConstants.PWD_PROPERTY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void doHandshake(NextFilter nextFilter) throws ProxyAuthException {

HttpProxyRequest req = (HttpProxyRequest) request;
Map<String, List<String>> headers = req.getHeaders() != null ? req.getHeaders()
: new HashMap<String, List<String>>();
: new HashMap<>();

if (step > 0) {
if (LOGGER.isDebugEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void doHandshake(NextFilter nextFilter) throws ProxyAuthException {

HttpProxyRequest req = (HttpProxyRequest) request;
Map<String, List<String>> headers = req.getHeaders() != null ? req.getHeaders()
: new HashMap<String, List<String>>();
: new HashMap<>();

String domain = req.getProperties().get(HttpProxyConstants.DOMAIN_PROPERTY);
String workstation = req.getProperties().get(HttpProxyConstants.WORKSTATION_PROPERTY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public final class NioDatagramAcceptor extends AbstractIoAcceptor implements Dat
private final Queue<NioSession> flushingSessions = new ConcurrentLinkedQueue<>();

private final Map<SocketAddress, DatagramChannel> boundHandles = Collections
.synchronizedMap(new HashMap<SocketAddress, DatagramChannel>());
.synchronizedMap(new HashMap<>());

private IoSessionRecycler sessionRecycler = DEFAULT_RECYCLER;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public final class VmPipeAcceptor extends AbstractIoAcceptor {
// object used for checking session idle
private IdleStatusChecker idleChecker;

static final Map<VmPipeAddress, VmPipe> boundHandlers = new HashMap<VmPipeAddress, VmPipe>();
static final Map<VmPipeAddress, VmPipe> boundHandlers = new HashMap<>();

/**
* Creates a new instance.
Expand Down Expand Up @@ -124,7 +124,7 @@ protected void dispose0() throws Exception {
*/
@Override
protected Set<SocketAddress> bindInternal(List<? extends SocketAddress> localAddresses) throws IOException {
Set<SocketAddress> newLocalAddresses = new HashSet<SocketAddress>();
Set<SocketAddress> newLocalAddresses = new HashSet<>();

synchronized (boundHandlers) {
for (SocketAddress a : localAddresses) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ protected void dispose0() throws Exception {
idleChecker.getNotifyingTask().cancel();
}

private static final Set<VmPipeAddress> TAKEN_LOCAL_ADDRESSES = new HashSet<VmPipeAddress>();
private static final Set<VmPipeAddress> TAKEN_LOCAL_ADDRESSES = new HashSet<>();

private static int nextLocalPort = -1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*/
class VmPipeFilterChain extends DefaultIoFilterChain {

private final Queue<IoEvent> eventQueue = new ConcurrentLinkedQueue<IoEvent>();
private final Queue<IoEvent> eventQueue = new ConcurrentLinkedQueue<>();

private final IoProcessor<VmPipeSession> processor = new VmPipeIoProcessor();

Expand Down Expand Up @@ -244,7 +244,7 @@ public void flush(VmPipeSession session) {

flushPendingDataQueues(session);
} else {
List<WriteRequest> failedRequests = new ArrayList<WriteRequest>();
List<WriteRequest> failedRequests = new ArrayList<>();
WriteRequest req;
while ((req = queue.poll(session)) != null) {
failedRequests.add(req);
Expand Down Expand Up @@ -305,7 +305,7 @@ public void add(VmPipeSession session) {

public void updateTrafficControl(VmPipeSession session) {
if (!session.isReadSuspended()) {
List<Object> data = new ArrayList<Object>();
List<Object> data = new ArrayList<>();
session.receivedMessageQueue.drainTo(data);
for (Object aData : data) {
VmPipeFilterChain.this.fireMessageReceived(aData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class VmPipeSession extends AbstractIoSession {
this.localAddress = localAddress;
remoteAddress = serviceAddress = remoteEntry.getAddress();
filterChain = new VmPipeFilterChain(this);
receivedMessageQueue = new LinkedBlockingQueue<Object>();
receivedMessageQueue = new LinkedBlockingQueue<>();

remoteSession = new VmPipeSession(this, remoteEntry);
}
Expand All @@ -90,7 +90,7 @@ private VmPipeSession(VmPipeSession remoteSession, VmPipe entry) {
remoteAddress = remoteSession.localAddress;
filterChain = new VmPipeFilterChain(this);
this.remoteSession = remoteSession;
receivedMessageQueue = new LinkedBlockingQueue<Object>();
receivedMessageQueue = new LinkedBlockingQueue<>();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class ConcurrentHashSet<E> extends MapBackedSet<E> {
* Creates a new instance of ConcurrentHashSet
*/
public ConcurrentHashSet() {
super(new ConcurrentHashMap<E, Boolean>());
super(new ConcurrentHashMap<>());
}

/**
Expand All @@ -49,7 +49,7 @@ public ConcurrentHashSet() {
* @param collection The collection to inject in this set
*/
public ConcurrentHashSet(Collection<E> collection) {
super(new ConcurrentHashMap<E, Boolean>(), collection);
super(new ConcurrentHashMap<>(), collection);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public ExpiringMap(int timeToLive) {
* @param expirationInterval The time between checks to see if a value should be removed (seconds)
*/
public ExpiringMap(int timeToLive, int expirationInterval) {
this(new ConcurrentHashMap<K, ExpiringObject>(), new CopyOnWriteArrayList<ExpirationListener<V>>(), timeToLive,
this(new ConcurrentHashMap<>(), new CopyOnWriteArrayList<>(), timeToLive,
expirationInterval);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class IdentityHashSet<E> extends MapBackedSet<E> {
* Creates a new IdentityHashSet instance
*/
public IdentityHashSet() {
super(new IdentityHashMap<E, Boolean>());
super(new IdentityHashMap<>());
}

/**
Expand All @@ -46,7 +46,7 @@ public IdentityHashSet() {
* @param expectedMaxSize The maximum size for the map
*/
public IdentityHashSet(int expectedMaxSize) {
super(new IdentityHashMap<E, Boolean>(expectedMaxSize));
super(new IdentityHashMap<>(expectedMaxSize));
}

/**
Expand All @@ -55,6 +55,6 @@ public IdentityHashSet(int expectedMaxSize) {
* @param c The elements to put in the map
*/
public IdentityHashSet(Collection<E> c) {
super(new IdentityHashMap<E, Boolean>(), c);
super(new IdentityHashMap<>(), c);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public class ByteArrayPool implements ByteArrayFactory {
*/
public ByteArrayPool(boolean direct, int maxFreeBuffers, int maxFreeMemory) {
this.direct = direct;
freeBuffers = new ArrayList<Stack<DirectBufferByteArray>>();
freeBuffers = new ArrayList<>();
for (int i = 0; i < MAX_BITS; i++) {
freeBuffers.add(new Stack<DirectBufferByteArray>());
freeBuffers.add(new Stack<>());
}
this.maxFreeBuffers = maxFreeBuffers;
this.maxFreeMemory = maxFreeMemory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ public boolean hasArray() {
public void testObjectSerialization() throws Exception {
IoBuffer buf = IoBuffer.allocate(16);
buf.setAutoExpand(true);
List<Object> o = new ArrayList<Object>();
List<Object> o = new ArrayList<>();
o.add(new Date());
o.add(long.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public static void main(String[] args) throws IOException, InterruptedException
}

private List<String> getThreadNames() {
List<String> list = new ArrayList<String>();
List<String> list = new ArrayList<>();
int active = Thread.activeCount();
Thread[] threads = new Thread[active];
Thread.enumerate(threads);
Expand Down
Loading

0 comments on commit 26f6f99

Please sign in to comment.