Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: various improvements as suggested by sonar #797

Merged
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
4 changes: 2 additions & 2 deletions src/main/java/dev/openfeature/sdk/EventSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ static class HandlerStore {

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<>());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/dev/openfeature/sdk/ImmutableStructure.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public ImmutableStructure(Map<String, Value> attributes) {
.collect(HashMap::new,
(accumulated, entry) -> accumulated.put(entry.getKey(),
Optional.ofNullable(entry.getValue())
.map(e -> e.clone())
.map(Value::clone)
.orElse(null)),
HashMap::putAll)));
}
Expand Down Expand Up @@ -70,7 +70,7 @@ public Map<String, Value> asMap() {
.collect(HashMap::new,
(accumulated, entry) -> accumulated.put(entry.getKey(),
Optional.ofNullable(entry.getValue())
.map(e -> e.clone())
.map(Value::clone)
.orElse(null)),
HashMap::putAll);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/openfeature/sdk/MutableContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public MutableStructure add(String ignoredKey, List<Value> ignoredValue) {
return null;
}

public MutableStructure add(String ignoredKey, MutableStructure ignoredValue) {
public MutableStructure add(String ignoredKey, Structure ignoredValue) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/openfeature/sdk/MutableStructure.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public MutableStructure add(String key, Structure value) {
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;
}
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/dev/openfeature/sdk/NoOpProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ public ProviderState getState() {

@Override
public Metadata getMetadata() {
return new Metadata() {
@Override
public String getName() {
return name;
}
};
return () -> name;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ private boolean isProviderRegistered(FeatureProvider provider) {
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);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/dev/openfeature/sdk/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ public Instant asInstant() {
*
* @return Value
*/

@SneakyThrows
@Override
protected Value clone() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public InMemoryProvider(Map<String, Flag<?>> flags) {
* @param evaluationContext evaluation context
* @throws Exception on error
*/
@Override
public void initialize(EvaluationContext evaluationContext) throws Exception {
super.initialize(evaluationContext);
state = ProviderState.READY;
Expand Down
Loading