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

fix: [go-feature-flag] Fix NullPointerException on checking anonymous user #609

Conversation

itchyny
Copy link
Contributor

@itchyny itchyny commented Dec 28, 2023

This PR

  • fixes java.lang.NullPointerException error on checking anonymous user in DataCollectorHook.

Related Issues

Fixes # No issues.

We're facing Null pointer exception on enabling the cache feature.

2023-12-25T06:29:07.141Z Unable to correctly evaluate flag with key 'feature-test' java.lang.NullPointerException: Cannot invoke "dev.openfeature.sdk.Value.asBoolean()" because the return value of "dev.openfeature.sdk.EvaluationContext.getValue(String)" is null
        at dev.openfeature.contrib.providers.gofeatureflag.hook.DataCollectorHook.after(DataCollectorHook.java:76)
        at dev.openfeature.sdk.HookSupport.lambda$afterHooks$2(HookSupport.java:32)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
        at dev.openfeature.sdk.HookSupport.executeHooksUnchecked(HookSupport.java:54)
        at dev.openfeature.sdk.HookSupport.afterHooks(HookSupport.java:32)
        at dev.openfeature.sdk.OpenFeatureClient.evaluateFlag(OpenFeatureClient.java:138)
        at dev.openfeature.sdk.OpenFeatureClient.getBooleanDetails(OpenFeatureClient.java:211)
        at dev.openfeature.sdk.OpenFeatureClient.getBooleanDetails(OpenFeatureClient.java:205)
        at dev.openfeature.sdk.OpenFeatureClient.getBooleanValue(OpenFeatureClient.java:189)

We firstly could not find what's happening, but noticed that the evaluation context needs to include the "anonymous" boolean field. But I think this field should be optional.

Notes

Follow-up Tasks

How to test

@itchyny itchyny requested a review from a team as a code owner December 28, 2023 05:38
… user

Signed-off-by: itchyny <itchyny@cybozu.co.jp>
@thomaspoignant thomaspoignant merged commit 9effb7d into open-feature:main Dec 28, 2023
4 checks passed
DBlanchard88 pushed a commit to DBlanchard88/java-sdk-contrib that referenced this pull request Apr 29, 2024
…ature#609)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants