-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
Description
at com.flagsmith.config.FlagsmithConfig.hashCode(FlagsmithConfig.java:24) ~[flagsmith-java-client-6.1.0.jar:na]
at com.flagsmith.FlagsmithApiWrapper.hashCode(FlagsmithApiWrapper.java:28) ~[flagsmith-java-client-6.1.0.jar:na]
at com.flagsmith.threads.AnalyticsProcessor.hashCode(AnalyticsProcessor.java:19) ~[flagsmith-java-client-6.1.0.jar:na]
at com.flagsmith.config.FlagsmithConfig.hashCode(FlagsmithConfig.java:24) ~[flagsmith-java-client-6.1.0.jar:na]
at com.flagsmith.FlagsmithApiWrapper.hashCode(FlagsmithApiWrapper.java:28) ~[flagsmith-java-client-6.1.0.jar:na]
at com.flagsmith.threads.AnalyticsProcessor.hashCode(AnalyticsProcessor.java:19) ~[flagsmith-java-client-6.1.0.jar:na]
at com.flagsmith.config.FlagsmithConfig.hashCode(FlagsmithConfig.java:24) ~[flagsmith-java-client-6.1.0.jar:na]
at com.flagsmith.FlagsmithApiWrapper.hashCode(FlagsmithApiWrapper.java:28) ~[flagsmith-java-client-6.1.0.jar:na]
at com.flagsmith.threads.AnalyticsProcessor.hashCode(AnalyticsProcessor.java:19) ~[flagsmith-java-client-6.1.0.jar:na]
I am providing the sample code that crashes from a simple SpringBoot application which declares the FlagsmithClient as a Bean, like SpringBoot dictates.
package com.cyberark.epm.account.config;
import com.flagsmith.FlagsmithClient;
import com.flagsmith.config.FlagsmithCacheConfig;
import com.flagsmith.config.FlagsmithConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.ResponseEntity;
import java.util.List;
@Configuration
public class FlagsmithConfiguration {
@Bean
public FlagsmithClient flagsmithClient(
@Value("${flagsmith.apiUrl}") String apiUrl,
@Value("${flagsmith.key}") String key
) {
FlagsmithConfig flagsmithConfig = FlagsmithConfig.newBuilder()
// withEnableAnalytics(true) Causes a stackoverflow
.withEnableAnalytics(true)
.baseUri(apiUrl).build();
return FlagsmithClient
.newBuilder()
.setApiKey(key)
.withConfiguration(flagsmithConfig)
.withCache(FlagsmithCacheConfig
.newBuilder()
.build())
.build();
}
}
The code crashes when trying to inject FlagsmithClient to another bean in the project.
It looks like SpringBoot calls for the hashcode function which is cyclic.
Maybe adding Lombok's @HashCodeExclude annotation on one of the (cyclic) dependencies can resolve the issue.
For instance, inside AnalyticsProcessor's 'api' member, which was dealt with similar issues in the past:
@ToString.Exclude private FlagsmithSdk api;
Metadata
Metadata
Assignees
Labels
No labels