Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class CustomSplitBrainProtectionFunction implements SplitBrainProtectionF
static final long HEARTBEAT_TOLERANCE_MILLIS = 3000;
static final int SPLIT_BRAIN_PROTECTION_SIZE = 2;

private Map<Member, Long> lastHeartbeatReceived = new HashMap<Member, Long>();
private Map<Member, Long> lastHeartbeatReceived = new HashMap<>();

@Override
public void memberAdded(MembershipEvent membershipEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void splitBrainProtectionAbsent_whenNotEnoughMembers() {
splitBrainProtectionFunction.memberAdded(mockEvent(members.get(0)));
splitBrainProtectionFunction.memberAdded(mockEvent(members.get(1)));

List<Member> splitCluster = new ArrayList<Member>();
List<Member> splitCluster = new ArrayList<>();
splitCluster.add(members.get(0));
assertFalse(splitBrainProtectionFunction.apply(splitCluster));
}
Expand Down
10 changes: 3 additions & 7 deletions demo/src/main/java/com/hazelcast/demo/AllTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public final class AllTest {

private final HazelcastInstance hazelcast;
private final int nThreads;
private final List<Runnable> operations = new ArrayList<Runnable>();
private final List<Runnable> operations = new ArrayList<>();
private final ExecutorService ex;
private final Random random = new Random();
private final AtomicInteger messagesReceived = new AtomicInteger(0);
Expand Down Expand Up @@ -256,9 +256,7 @@ private List<Runnable> loadMapOperations() {
IMap map = hazelcast.getMap("myMap");
try {
map.getAsync(random.nextInt(SIZE)).toCompletableFuture().get();
} catch (InterruptedException e) {
throw new RuntimeException(e);
} catch (ExecutionException e) {
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}, 1);
Expand Down Expand Up @@ -344,9 +342,7 @@ private List<Runnable> loadMapOperations() {
try {
map.putAsync(random.nextInt(SIZE), new Customer(random.nextInt(100), String.valueOf(random.nextInt(10000)))
).toCompletableFuture().get();
} catch (InterruptedException e) {
throw new RuntimeException(e);
} catch (ExecutionException e) {
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}, 5);
Expand Down
6 changes: 2 additions & 4 deletions demo/src/main/java/com/hazelcast/demo/LongRunningTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public final class LongRunningTest {
private static final int STATS_SECONDS = 10;
private static final Logger LOGGER = Logger.getLogger(LongRunningTest.class.getName());

private final List<TheNode> nodes = new CopyOnWriteArrayList<TheNode>();
private final List<TheNode> nodes = new CopyOnWriteArrayList<>();
private final Random random;
private int nodeIdGen;
private int starts;
Expand Down Expand Up @@ -85,7 +85,7 @@ private void run() {
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
log("Shutting down " + nodes.size());
while (nodes.size() > 0) {
while (!nodes.isEmpty()) {
removeNode();
}
}
Expand Down Expand Up @@ -251,8 +251,6 @@ public void run() {
Stats currentStats = stats.getAndReset();
logger.info("Cluster size: " + clusterSize + ", Operations per second: "
+ (currentStats.total() / STATS_SECONDS));
} catch (HazelcastInstanceNotActiveException e) {
throw new RuntimeException(e);
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private static Object createValue() {
* Map statistics class
*/
private static class Stats {
Map<String, AtomicLong> mapStats = new ConcurrentHashMap<String, AtomicLong>(10);
Map<String, AtomicLong> mapStats = new ConcurrentHashMap<>(10);

Stats() {
mapStats.put("put", new AtomicLong(0));
Expand Down
2 changes: 1 addition & 1 deletion demo/src/main/java/com/hazelcast/demo/SimpleMapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private void load(ExecutorService es) throws InterruptedException {

final IMap<String, Object> map = instance.getMap(NAMESPACE);
final Member thisMember = instance.getCluster().getLocalMember();
List<String> lsOwnedEntries = new LinkedList<String>();
List<String> lsOwnedEntries = new LinkedList<>();
for (int i = 0; i < entryCount; i++) {
final String key = String.valueOf(i);
Partition partition = instance.getPartitionService().getPartition(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ public static void main(String[] args) {
}

private static class ItemListenerImpl<E> implements ItemListener<E> {
@Override
public void itemAdded(ItemEvent<E> itemEvent) {
System.out.println("Item added:" + itemEvent.getItem());
}

@Override
public void itemRemoved(ItemEvent<E> itemEvent) {
System.out.println("Item removed:" + itemEvent.getItem());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public EchoTask(String msg) {
this.msg = msg;
}

@Override
public void run() {
try {
Thread.sleep(5000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class EchoTask implements Runnable, Serializable {
this.msg = msg;
}

@Override
public void run() {
sleepSeconds(5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ public class SumTask implements Callable<Integer>, Serializable, HazelcastInstan

private transient HazelcastInstance hz;

@Override
public void setHazelcastInstance(HazelcastInstance hz) {
this.hz = hz;
}

@Override
public Integer call() throws Exception {
IMap<String, Integer> map = hz.getMap("map");
int result = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ public VerifyTask(String key) {
this.key = key;
}

@Override
public void setHazelcastInstance(HazelcastInstance hz) {
this.hz = hz;
}

@Override
public void run() {
IMap map = hz.getMap("map");
boolean localKey = map.localKeySet().contains(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ public class ComputationHeavyTask implements Callable<Integer>, Serializable, Ha

private transient HazelcastInstance hz;

@Override
public void setHazelcastInstance(HazelcastInstance hz) {
this.hz = hz;
}

@Override
public Integer call() throws Exception {
System.out.println("Running a computation heavy task on " + hz.getCluster().getLocalMember());
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public FibonacciCallable(int input) {
this.input = input;
}

@Override
public Long call() {
return calculate(input);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static void main(String[] args) {
HazelcastInstance hz = Hazelcast.newHazelcastInstance();
IExecutorService executor = hz.getExecutorService("executor");

ExecutionCallback<Long> executionCallback = new ExecutionCallback<Long>() {
ExecutionCallback<Long> executionCallback = new ExecutionCallback<>() {
public void onFailure(Throwable t) {
t.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public FibonacciCallable(int input) {
this.input = input;
}

@Override
public Long call() {
return calculate(input);
}
Expand Down
1 change: 1 addition & 0 deletions distributed-executor/scale-out/src/main/java/EchoTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public EchoTask(String msg) {
this.msg = msg;
}

@Override
public void run() {
try {
Thread.sleep(5000);
Expand Down
1 change: 1 addition & 0 deletions distributed-executor/scale-up/src/main/java/EchoTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public EchoTask(String msg) {
this.msg = msg;
}

@Override
public void run() {
try {
Thread.sleep(5000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ private void run() {
}

System.out.println("Find name Peter and age 37, which doesn't exist");
System.out.println("Did we find it? " + (getWithNameAndAge("Peter", 37).size() != 0));
System.out.println("Did we find it? " + (!getWithNameAndAge("Peter", 37).isEmpty()));
}

private Set<Person> getWithNameNaive(String name) {
Set<Person> result = new HashSet<Person>();
Set<Person> result = new HashSet<>();
for (Person person : personMap.values()) {
if (person.getName().equals(name)) {
result.add(person);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class Car implements Serializable {
private Map<String, Object> attributes;

public Car(String name) {
attributes = new HashMap<String, Object>();
attributes = new HashMap<>();
attributes.put("name", name);
attributes.put("tripStart", 0);
attributes.put("tripStop", 0);
Expand Down
4 changes: 2 additions & 2 deletions distributed-map/mapstore/src/main/java/LoadAll.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private static Config createNewConfig(String mapName) {

private static class SimpleStore implements MapStore<Integer, Integer> {

private ConcurrentMap<Integer, Integer> store = new ConcurrentHashMap<Integer, Integer>();
private ConcurrentMap<Integer, Integer> store = new ConcurrentHashMap<>();

@Override
public void store(Integer key, Integer value) {
Expand Down Expand Up @@ -117,7 +117,7 @@ public Integer load(Integer key) {

@Override
public Map<Integer, Integer> loadAll(Collection<Integer> keys) {
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
Map<Integer, Integer> map = new HashMap<>();
for (Integer key : keys) {
Integer value = load(key);
map.put(key, value);
Expand Down
2 changes: 1 addition & 1 deletion enterprise/auditlog/src/main/java/auditlog/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static Builder builder(String typeId, AuditlogService els) {
public static final class Builder implements EventBuilder<Builder> {
private String message;
private String typeId;
private Map<String, Object> parameters = new HashMap<String, Object>();
private Map<String, Object> parameters = new HashMap<>();
private Level level = Level.INFO;
private Throwable cause;
private long timestamp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static void main(String[] args) {
//INFO: hz.client_0 [cluster1] [3.12] HazelcastClient 3.12 (20190205 - 3af10e3) is CLIENT_CHANGED_CLUSTER
// user can listen the cluster change and take action
client.getLifecycleService().addLifecycleListener(event -> {
if (LifecycleEvent.LifecycleState.CLIENT_CHANGED_CLUSTER.equals(event.getState())) {
if (LifecycleEvent.LifecycleState.CLIENT_CHANGED_CLUSTER == event.getState()) {
System.out.println("Client has switched to a new cluster");
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static void main(String[] args) {
//INFO: hz.client_0 [cluster1] [3.12] HazelcastClient 3.12 (20190205 - 3af10e3) is CLIENT_CHANGED_CLUSTER
// user can listen the cluster change and take action
client.getLifecycleService().addLifecycleListener(event -> {
if (LifecycleEvent.LifecycleState.CLIENT_CHANGED_CLUSTER.equals(event.getState())) {
if (LifecycleEvent.LifecycleState.CLIENT_CHANGED_CLUSTER == event.getState()) {
System.out.println("Client has switched to a new cluster");
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ <K, V> HiDensityNearCacheSupportContext<K, V> createHiDensityCacheWithHiDensityN
EnterpriseSerializationService enterpriseSerializationService =
(EnterpriseSerializationService) client.getSerializationService();

return new HiDensityNearCacheSupportContext<K, V>(cache, enterpriseSerializationService.getMemoryManager());
return new HiDensityNearCacheSupportContext<>(cache, enterpriseSerializationService.getMemoryManager());
}

class HiDensityNearCacheSupportContext<K, V> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ public void terminate() throws Exception {
/**
* Imports given LDIF files to the directory using given directory service and schema manager.
*
* @param ldifFiles
* @throws Exception
*/
public void importLdifFiles(String... ldifFiles) throws Exception {
Expand Down Expand Up @@ -222,6 +221,7 @@ public InMemoryDirectoryServiceFactory(DirectoryService directoryService, Partit
/**
* {@inheritDoc}
*/
@Override
public void init(String name) throws Exception {
if ((directoryService != null) && directoryService.isStarted()) {
return;
Expand Down Expand Up @@ -266,7 +266,7 @@ public void init(String name) throws Exception {
schemaPartition.setWrappedPartition(inMemorySchemaPartition);
directoryService.setSchemaPartition(schemaPartition);
List<Throwable> errors = schemaManager.getErrors();
if (errors.size() != 0) {
if (!errors.isEmpty()) {
throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors)));
}

Expand All @@ -284,13 +284,15 @@ public void init(String name) throws Exception {
/**
* {@inheritDoc}
*/
@Override
public DirectoryService getDirectoryService() throws Exception {
return directoryService;
}

/**
* {@inheritDoc}
*/
@Override
public PartitionFactory getPartitionFactory() throws Exception {
return partitionFactory;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,15 @@ private static Collection<String> getAttributeValues(X509Certificate cert, Strin
return Collections.emptySet();
}
LdapName ldapName = new LdapName(cert.getSubjectX500Principal().getName());
Set<String> values = new HashSet<String>();
Set<String> values = new HashSet<>();
for (Rdn rdn : ldapName.getRdns()) {
values.addAll(getAttributeValues(rdn.toAttributes(), attribute));
}
return values;
}

private static Collection<String> getAttributeValues(Attributes attributes, String attribute) throws NamingException {
Set<String> names = new HashSet<String>();
Set<String> names = new HashSet<>();
Attribute attr = attribute != null && attributes != null ? attributes.get(attribute) : null;
if (attr != null) {
NamingEnumeration<?> values = attr.getAll();
Expand All @@ -248,7 +248,7 @@ private static Collection<String> getAttributeValues(Attributes attributes, Stri

protected String getStringOption(String optionName, String defaultValue) {
String option = getOptionInternal(optionName);
return option != null ? option.toString() : defaultValue;
return option != null ? option : defaultValue;
}

private String getOptionInternal(String optionName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
class ClientCertCheckingLoginModuleTest {

@AfterEach
public void afterEach() {
void afterEach() {
HazelcastClient.shutdownAll();
Hazelcast.shutdownAll();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ private void access(long now,
Map<String, ExpiryData> keyToExpiryData,
IMap<String, String> mapA,
IMap<String, String> mapB) {
if (keyToExpiryData.keySet().size() < 1) {
if (keyToExpiryData.keySet().isEmpty()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Item {

@OneToMany(cascade = CascadeType.ALL, mappedBy = "item")
@Cache(region = "SubItems-Collection-Cache", usage = CacheConcurrencyStrategy.READ_WRITE)
private List<SubItem> subItems = new ArrayList<SubItem>();
private List<SubItem> subItems = new ArrayList<>();

public Item() { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void clients() {
log.info("Client => name '{}'", client);
}

if (clients.size() > 0) {
if (!clients.isEmpty()) {
log.info("-----------------------");
}
log.info("[{} client{}]",
Expand Down Expand Up @@ -81,7 +81,7 @@ public void list() {
}
}

if (distributedObjects.size() > 0) {
if (!distributedObjects.isEmpty()) {
log.info("-----------------------");
}
log.info("[{} distributed object{}]",
Expand Down
Loading
Loading