Skip to content

Commit a3f31fd

Browse files
Fix some linting issues
Signed-off-by: Thomas Poignant <[email protected]>
1 parent 19f8d21 commit a3f31fd

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

providers/go-feature-flag/src/main/java/dev/openfeature/contrib/providers/gofeatureflag/GoFeatureFlagProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class GoFeatureFlagProvider extends EventProvider implements Tracking {
6060
* @param options - options to configure the provider
6161
* @throws InvalidOptions - if options are invalid
6262
*/
63-
public GoFeatureFlagProvider(GoFeatureFlagProviderOptions options) throws InvalidOptions {
63+
public GoFeatureFlagProvider(final GoFeatureFlagProviderOptions options) throws InvalidOptions {
6464
Validator.providerOptions(options);
6565
this.options = options;
6666
this.api = GoFeatureFlagApi.builder().options(options).build();
@@ -92,7 +92,7 @@ public Metadata getMetadata() {
9292

9393
@Override
9494
public List<Hook> getProviderHooks() {
95-
return this.hooks;
95+
return new ArrayList<>(this.hooks);
9696
}
9797

9898
@Override

providers/go-feature-flag/src/main/java/dev/openfeature/contrib/providers/gofeatureflag/api/GoFeatureFlagApi.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import dev.openfeature.contrib.providers.gofeatureflag.exception.InvalidEndpoint;
1919
import dev.openfeature.contrib.providers.gofeatureflag.exception.InvalidOptions;
2020
import dev.openfeature.contrib.providers.gofeatureflag.util.Const;
21-
import dev.openfeature.contrib.providers.gofeatureflag.validator.Validator;
2221
import dev.openfeature.sdk.EvaluationContext;
2322
import dev.openfeature.sdk.exceptions.FlagNotFoundError;
2423
import dev.openfeature.sdk.exceptions.GeneralError;
@@ -66,7 +65,6 @@ public class GoFeatureFlagApi {
6665
*/
6766
@Builder
6867
private GoFeatureFlagApi(final GoFeatureFlagProviderOptions options) throws InvalidOptions {
69-
Validator.providerOptions(options);
7068
this.apiKey = options.getApiKey();
7169
this.parsedEndpoint = HttpUrl.parse(options.getEndpoint());
7270
if (this.parsedEndpoint == null) {

providers/go-feature-flag/src/main/java/dev/openfeature/contrib/providers/gofeatureflag/service/EventsPublisher.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class EventsPublisher<T> {
3434
private final Lock writeLock = readWriteLock.writeLock();
3535

3636
private final ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
37-
private List<T> eventsList;
37+
private final List<T> eventsList;
3838

3939
/**
4040
* Constructor.
@@ -72,9 +72,14 @@ public void add(T event) {
7272
log.warn("events collection is full. Publishing before adding new events.");
7373
publish();
7474
}
75-
writeLock.lock();
76-
eventsList.add(event);
77-
writeLock.unlock();
75+
try {
76+
writeLock.lock();
77+
if (eventsList != null) {
78+
eventsList.add(event);
79+
}
80+
} finally {
81+
writeLock.unlock();
82+
}
7883
}
7984

8085
/**

providers/go-feature-flag/src/main/java/dev/openfeature/contrib/providers/gofeatureflag/util/Const.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,16 @@ public class Const {
1818
public static final String HTTP_HEADER_ETAG = "ETag";
1919
public static final String HTTP_HEADER_IF_NONE_MATCH = "If-None-Match";
2020
public static final String HTTP_HEADER_LAST_MODIFIED = "Last-Modified";
21-
public static final DateFormat LAST_MODIFIED_HEADER_FORMATTER =
22-
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");
23-
2421
// DEFAULT VALUES
2522
public static final long DEFAULT_POLLING_CONFIG_FLAG_CHANGE_INTERVAL_MS = 2L * 60L * 1000L;
2623
public static final long DEFAULT_FLUSH_INTERVAL_MS = Duration.ofMinutes(1).toMillis();
2724
public static final int DEFAULT_MAX_PENDING_EVENTS = 10000;
28-
2925
// MAPPERS
3026
public static final ObjectMapper DESERIALIZE_OBJECT_MAPPER =
3127
new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
3228
public static final ObjectMapper SERIALIZE_OBJECT_MAPPER = new ObjectMapper();
3329
public static final ObjectMapper SERIALIZE_WASM_MAPPER = new ObjectMapper()
3430
.setSerializationInclusion(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL);
35-
31+
public static DateFormat LAST_MODIFIED_HEADER_FORMATTER =
32+
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");
3633
}

providers/go-feature-flag/src/main/java/dev/openfeature/contrib/providers/gofeatureflag/wasm/EvaluationWasm.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import dev.openfeature.sdk.Reason;
1919
import java.io.File;
2020
import java.net.URL;
21+
import java.nio.charset.StandardCharsets;
2122
import java.nio.file.Files;
2223
import java.nio.file.Path;
2324
import java.nio.file.Paths;
@@ -99,22 +100,20 @@ private HostFunction getProcExitFunc() {
99100
});
100101
}
101102

102-
103103
/**
104104
* preWarmWasm is a function that is called to pre-warm the WASM module
105105
* It calls the malloc function to allocate memory for the WASM module
106106
* and then calls the free function to free the memory.
107107
*/
108108
public void preWarmWasm() {
109-
val message = "".getBytes();
109+
val message = "".getBytes(StandardCharsets.UTF_8);
110110
Memory memory = this.instance.memory();
111111
int len = message.length;
112112
int ptr = (int) malloc.apply(len)[0];
113113
memory.write(ptr, message);
114114
this.free.apply(ptr, len);
115115
}
116116

117-
118117
/**
119118
* Evaluate is a function that evaluates the feature flag using the WASM module.
120119
*

0 commit comments

Comments
 (0)