chore: various improvements as suggested by sonar (#797)

* various improvements as suggested by sonar

Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>

* revert clonable change

Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>

---------

Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
This commit is contained in:
Kavindu Dodanduwa 2024-02-13 08:39:45 -08:00 committed by GitHub
parent 69f95b1bfd
commit 6c8657d520
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 8 additions and 14 deletions

View File

@ -163,8 +163,8 @@ class EventSupport {
private final Map<ProviderEvent, List<Consumer<EventDetails>>> handlerMap;
{
handlerMap = new ConcurrentHashMap<ProviderEvent, List<Consumer<EventDetails>>>();
HandlerStore() {
handlerMap = new ConcurrentHashMap<>();
handlerMap.put(ProviderEvent.PROVIDER_READY, new ArrayList<>());
handlerMap.put(ProviderEvent.PROVIDER_CONFIGURATION_CHANGED, new ArrayList<>());
handlerMap.put(ProviderEvent.PROVIDER_ERROR, new ArrayList<>());

View File

@ -40,7 +40,7 @@ public final class ImmutableStructure extends AbstractStructure {
.collect(HashMap::new,
(accumulated, entry) -> accumulated.put(entry.getKey(),
Optional.ofNullable(entry.getValue())
.map(e -> e.clone())
.map(Value::clone)
.orElse(null)),
HashMap::putAll)));
}
@ -70,7 +70,7 @@ public final class ImmutableStructure extends AbstractStructure {
.collect(HashMap::new,
(accumulated, entry) -> accumulated.put(entry.getKey(),
Optional.ofNullable(entry.getValue())
.map(e -> e.clone())
.map(Value::clone)
.orElse(null)),
HashMap::putAll);
}

View File

@ -145,7 +145,7 @@ public class MutableContext implements EvaluationContext {
return null;
}
public MutableStructure add(String ignoredKey, MutableStructure ignoredValue) {
public MutableStructure add(String ignoredKey, Structure ignoredValue) {
return null;
}

View File

@ -75,7 +75,7 @@ public class MutableStructure extends AbstractStructure {
return this;
}
public <T> MutableStructure add(String key, List<Value> value) {
public MutableStructure add(String key, List<Value> value) {
attributes.put(key, new Value(value));
return this;
}

View File

@ -18,12 +18,7 @@ public class NoOpProvider implements FeatureProvider {
@Override
public Metadata getMetadata() {
return new Metadata() {
@Override
public String getName() {
return name;
}
};
return () -> name;
}
@Override

View File

@ -168,7 +168,6 @@ class ProviderRepository {
private void shutdownProvider(FeatureProvider provider) {
taskExecutor.submit(() -> {
try {
// detachProviderEvents(provider);
provider.shutdown();
} catch (Exception e) {
log.error("Exception when shutting down feature provider {}", provider.getClass().getName(), e);

View File

@ -266,7 +266,6 @@ public class Value implements Cloneable {
*
* @return Value
*/
@SneakyThrows
@Override
protected Value clone() {

View File

@ -52,6 +52,7 @@ public class InMemoryProvider extends EventProvider {
* @param evaluationContext evaluation context
* @throws Exception on error
*/
@Override
public void initialize(EvaluationContext evaluationContext) throws Exception {
super.initialize(evaluationContext);
state = ProviderState.READY;