More Sonar fixes
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
* Copyright 2015-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -82,9 +82,9 @@ public class HazelcastLocalInstanceRegistrar implements SmartInitializingSinglet
|
||||
public void afterSingletonsInstantiated() {
|
||||
if (this.hazelcastInstance == null) {
|
||||
if (!Hazelcast.getAllHazelcastInstances().isEmpty()) {
|
||||
HazelcastInstance hazelcastInstance = Hazelcast.getAllHazelcastInstances().iterator().next();
|
||||
hazelcastInstance.getCluster().addMembershipListener(new HazelcastMembershipListener());
|
||||
syncConfigurationMultiMap(hazelcastInstance);
|
||||
HazelcastInstance anyHazelcastInstance = Hazelcast.getAllHazelcastInstances().iterator().next();
|
||||
anyHazelcastInstance.getCluster().addMembershipListener(new HazelcastMembershipListener());
|
||||
syncConfigurationMultiMap(anyHazelcastInstance);
|
||||
}
|
||||
else {
|
||||
logger.warn("No HazelcastInstances for MembershipListener registration");
|
||||
|
||||
@@ -73,12 +73,12 @@ public abstract class AbstractHazelcastMessageProducer extends MessageProducerSu
|
||||
}
|
||||
|
||||
public void setCacheEventTypes(String cacheEventTypes) {
|
||||
Set<String> cacheEvents =
|
||||
Set<String> events =
|
||||
HazelcastIntegrationDefinitionValidator.validateEnumType(CacheEventType.class, cacheEventTypes);
|
||||
Assert.notEmpty(cacheEvents, "'cacheEvents' must have elements");
|
||||
Assert.notEmpty(events, "'events' must have elements");
|
||||
HazelcastIntegrationDefinitionValidator.validateCacheEventsByDistributedObject(this.distributedObject,
|
||||
cacheEvents);
|
||||
this.cacheEvents = cacheEvents;
|
||||
events);
|
||||
this.cacheEvents = events;
|
||||
}
|
||||
|
||||
protected CacheListeningPolicyType getCacheListeningPolicy() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017 the original author or authors.
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,7 +43,7 @@ public class HazelcastMetadataStore implements ListenableMetadataStore, Initiali
|
||||
|
||||
private final IMap<String, String> map;
|
||||
|
||||
private final List<MetadataStoreListener> listeners = new CopyOnWriteArrayList<MetadataStoreListener>();
|
||||
private final List<MetadataStoreListener> listeners = new CopyOnWriteArrayList<>();
|
||||
|
||||
public HazelcastMetadataStore(HazelcastInstance hazelcastInstance) {
|
||||
Assert.notNull(hazelcastInstance, "Hazelcast instance can't be null");
|
||||
@@ -57,14 +57,14 @@ public class HazelcastMetadataStore implements ListenableMetadataStore, Initiali
|
||||
|
||||
@Override
|
||||
public String putIfAbsent(String key, String value) {
|
||||
Assert.notNull(key, "'key' must not be null.");
|
||||
assertKey(key);
|
||||
Assert.notNull(value, "'value' must not be null.");
|
||||
return this.map.putIfAbsent(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replace(String key, String oldValue, String newValue) {
|
||||
Assert.notNull(key, "'key' must not be null.");
|
||||
assertKey(key);
|
||||
Assert.notNull(oldValue, "'oldValue' must not be null.");
|
||||
Assert.notNull(newValue, "'newValue' must not be null.");
|
||||
return this.map.replace(key, oldValue, newValue);
|
||||
@@ -72,23 +72,27 @@ public class HazelcastMetadataStore implements ListenableMetadataStore, Initiali
|
||||
|
||||
@Override
|
||||
public void put(String key, String value) {
|
||||
Assert.notNull(key, "'key' must not be null.");
|
||||
assertKey(key);
|
||||
Assert.notNull(value, "'value' must not be null.");
|
||||
this.map.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(String key) {
|
||||
Assert.notNull(key, "'key' must not be null.");
|
||||
assertKey(key);
|
||||
return this.map.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String remove(String key) {
|
||||
Assert.notNull(key, "'key' must not be null.");
|
||||
assertKey(key);
|
||||
return this.map.remove(key);
|
||||
}
|
||||
|
||||
private static void assertKey(String key) {
|
||||
Assert.notNull(key, "'key' must not be null.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(MetadataStoreListener callback) {
|
||||
Assert.notNull(callback, "callback object can not be null");
|
||||
@@ -101,18 +105,14 @@ public class HazelcastMetadataStore implements ListenableMetadataStore, Initiali
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
public void afterPropertiesSet() {
|
||||
this.map.addEntryListener(new MapListener(this.listeners), true);
|
||||
}
|
||||
|
||||
private static class MapListener implements EntryAddedListener<String, String>,
|
||||
EntryRemovedListener<String, String>, EntryUpdatedListener<String, String> {
|
||||
|
||||
private final List<MetadataStoreListener> listeners;
|
||||
|
||||
MapListener(List<MetadataStoreListener> listeners) {
|
||||
this.listeners = listeners;
|
||||
}
|
||||
private record MapListener(List<MetadataStoreListener> listeners)
|
||||
implements EntryAddedListener<String, String>,
|
||||
EntryRemovedListener<String, String>,
|
||||
EntryUpdatedListener<String, String> {
|
||||
|
||||
@Override
|
||||
public void entryAdded(EntryEvent<String, String> event) {
|
||||
|
||||
Reference in New Issue
Block a user