Skip to content

Commit 4a85316

Browse files
authored
Openrewrite Improvements (#709)
Apply OpenRewrite automated refactorings to this project, _already_ applied to `hazelcast-mono`. - `Add missing @OverRide annotation` - hazelcast/hazelcast-mono#2879 - Enum values should be compared with `==` - hazelcast/hazelcast-mono#2884 - Use diamond operator - hazelcast/hazelcast-mono#2887 - Remove empty Javadoc parameters - hazelcast/hazelcast-mono#2888 - Replace `Collection` `.size() > 0` with !`isEmpty()` - hazelcast/hazelcast-mono#2889 - Make JUnit5 tests default visibility - hazelcast/hazelcast-mono#2893 - Combine semantically equal `catch` blocks - hazelcast/hazelcast-mono#3716
1 parent ffd638c commit 4a85316

File tree

87 files changed

+154
-173
lines changed

Some content is hidden

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

87 files changed

+154
-173
lines changed

cluster-split-brain-protection/src/main/java/CustomSplitBrainProtectionFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class CustomSplitBrainProtectionFunction implements SplitBrainProtectionF
2323
static final long HEARTBEAT_TOLERANCE_MILLIS = 3000;
2424
static final int SPLIT_BRAIN_PROTECTION_SIZE = 2;
2525

26-
private Map<Member, Long> lastHeartbeatReceived = new HashMap<Member, Long>();
26+
private Map<Member, Long> lastHeartbeatReceived = new HashMap<>();
2727

2828
@Override
2929
public void memberAdded(MembershipEvent membershipEvent) {

cluster-split-brain-protection/src/test/java/CustomSplitBrainProtectionFunctionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void splitBrainProtectionAbsent_whenNotEnoughMembers() {
6262
splitBrainProtectionFunction.memberAdded(mockEvent(members.get(0)));
6363
splitBrainProtectionFunction.memberAdded(mockEvent(members.get(1)));
6464

65-
List<Member> splitCluster = new ArrayList<Member>();
65+
List<Member> splitCluster = new ArrayList<>();
6666
splitCluster.add(members.get(0));
6767
assertFalse(splitBrainProtectionFunction.apply(splitCluster));
6868
}

demo/src/main/java/com/hazelcast/demo/AllTest.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public final class AllTest {
6060

6161
private final HazelcastInstance hazelcast;
6262
private final int nThreads;
63-
private final List<Runnable> operations = new ArrayList<Runnable>();
63+
private final List<Runnable> operations = new ArrayList<>();
6464
private final ExecutorService ex;
6565
private final Random random = new Random();
6666
private final AtomicInteger messagesReceived = new AtomicInteger(0);
@@ -256,9 +256,7 @@ private List<Runnable> loadMapOperations() {
256256
IMap map = hazelcast.getMap("myMap");
257257
try {
258258
map.getAsync(random.nextInt(SIZE)).toCompletableFuture().get();
259-
} catch (InterruptedException e) {
260-
throw new RuntimeException(e);
261-
} catch (ExecutionException e) {
259+
} catch (InterruptedException | ExecutionException e) {
262260
throw new RuntimeException(e);
263261
}
264262
}, 1);
@@ -344,9 +342,7 @@ private List<Runnable> loadMapOperations() {
344342
try {
345343
map.putAsync(random.nextInt(SIZE), new Customer(random.nextInt(100), String.valueOf(random.nextInt(10000)))
346344
).toCompletableFuture().get();
347-
} catch (InterruptedException e) {
348-
throw new RuntimeException(e);
349-
} catch (ExecutionException e) {
345+
} catch (InterruptedException | ExecutionException e) {
350346
throw new RuntimeException(e);
351347
}
352348
}, 5);

demo/src/main/java/com/hazelcast/demo/LongRunningTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public final class LongRunningTest {
4141
private static final int STATS_SECONDS = 10;
4242
private static final Logger LOGGER = Logger.getLogger(LongRunningTest.class.getName());
4343

44-
private final List<TheNode> nodes = new CopyOnWriteArrayList<TheNode>();
44+
private final List<TheNode> nodes = new CopyOnWriteArrayList<>();
4545
private final Random random;
4646
private int nodeIdGen;
4747
private int starts;
@@ -85,7 +85,7 @@ private void run() {
8585
Runtime.getRuntime().addShutdownHook(new Thread() {
8686
public void run() {
8787
log("Shutting down " + nodes.size());
88-
while (nodes.size() > 0) {
88+
while (!nodes.isEmpty()) {
8989
removeNode();
9090
}
9191
}
@@ -251,8 +251,6 @@ public void run() {
251251
Stats currentStats = stats.getAndReset();
252252
logger.info("Cluster size: " + clusterSize + ", Operations per second: "
253253
+ (currentStats.total() / STATS_SECONDS));
254-
} catch (HazelcastInstanceNotActiveException e) {
255-
throw new RuntimeException(e);
256254
} catch (Exception e) {
257255
throw new RuntimeException(e);
258256
}

demo/src/main/java/com/hazelcast/demo/SimpleFunctionalMapTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private static Object createValue() {
7878
* Map statistics class
7979
*/
8080
private static class Stats {
81-
Map<String, AtomicLong> mapStats = new ConcurrentHashMap<String, AtomicLong>(10);
81+
Map<String, AtomicLong> mapStats = new ConcurrentHashMap<>(10);
8282

8383
Stats() {
8484
mapStats.put("put", new AtomicLong(0));

demo/src/main/java/com/hazelcast/demo/SimpleMapTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ private void load(ExecutorService es) throws InterruptedException {
160160

161161
final IMap<String, Object> map = instance.getMap(NAMESPACE);
162162
final Member thisMember = instance.getCluster().getLocalMember();
163-
List<String> lsOwnedEntries = new LinkedList<String>();
163+
List<String> lsOwnedEntries = new LinkedList<>();
164164
for (int i = 0; i < entryCount; i++) {
165165
final String key = String.valueOf(i);
166166
Partition partition = instance.getPartitionService().getPartition(key);

distributed-collections/itemlisteners/src/main/java/ItemListenerMember.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ public static void main(String[] args) {
1414
}
1515

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

22+
@Override
2123
public void itemRemoved(ItemEvent<E> itemEvent) {
2224
System.out.println("Item removed:" + itemEvent.getItem());
2325
}

distributed-executor/basic-executor/src/main/java/EchoTask.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public EchoTask(String msg) {
88
this.msg = msg;
99
}
1010

11+
@Override
1112
public void run() {
1213
try {
1314
Thread.sleep(5000);

distributed-executor/durable-executor-service/src/main/java/configuration/EchoTask.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class EchoTask implements Runnable, Serializable {
2828
this.msg = msg;
2929
}
3030

31+
@Override
3132
public void run() {
3233
sleepSeconds(5);
3334

distributed-executor/executing-on-all-members/src/main/java/SumTask.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ public class SumTask implements Callable<Integer>, Serializable, HazelcastInstan
99

1010
private transient HazelcastInstance hz;
1111

12+
@Override
1213
public void setHazelcastInstance(HazelcastInstance hz) {
1314
this.hz = hz;
1415
}
1516

17+
@Override
1618
public Integer call() throws Exception {
1719
IMap<String, Integer> map = hz.getMap("map");
1820
int result = 0;

0 commit comments

Comments
 (0)