optimizely / optimizely/java-sdk

[BUG] If configuration file initialization fails, the configuration file remains uninitialized indefinitely

Open
#574 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
44
Forks
32
Avg merge
8h 39m
Merged PRs (30d)
1

Description

Is there an existing issue for this?
  • I have searched the existing issues
SDK Version

3.2.0-alpha to 4.2.2.
Since this commit: Update HttpProjectConfigManager to use Last-Modified time (https://github.com/optimizely/java-sdk/pull/292)

Current Behavior

If the initialization of the configuration file fails, the configuration file remains un-initilialized indefinitely until the server/pod is restarted, or the configuration gets updated on Optimizely platform.

Expected Behavior

If the configuration file cannot be initialized at server start-up (eg: because Optimizely is down or takes to much time to respond), then during the next configuration poll, the configuration should be updated, even if Optimizely returns an HTTP 304 (Not Modified) code.

Steps To Reproduce
  • At initialization of the PollingProjectConfigManager the connection is broken, or there is a time out, or an error. => PollingProjectConfigManager.currentProjectConfig is empty.
  • 5min later, PollingProjectConfigManager.poll() polls the config file, but receives HTTP 304 from Optimizely => PollingProjectConfigManager.currentProjectConfig remains empty.
  • 5min later, still no modification on the configuration => PollingProjectConfigManager.currentProjectConfig remains empty.
  • PollingProjectConfigManager.currentProjectConfig is never initialized (except if a modification on the configuration is done on Optimizely side, or the server is restarted).
Java Version

No response

Link

No response

Logs

No response

Severity

Affecting users

Workaround/Solution

See the HttpProjectConfigManager:
https://github.com/optimizely/java-sdk/blob/746e81530a9224fabcd7f610d81800358e6e34c9/core-httpclient-impl/src/main/java/com/optimizely/ab/config/HttpProjectConfigManager.java#L95-L121

Here, the condition handling the HttpStatus.SC_NOT_MODIFIED should check if the currentProjectConfig is initialized or not. If it is empty, it means the configuration file has never been initialized properly and the configuration should thus be returned.

Recent Change

No response

Conflicts

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in core-httpclient-impl/src/main/java/com/optimizely/ab/config/HttpProjectConfigManager.java, especially the HttpStatus.SC_NOT_MODIFIED handling around lines 95–121. Trace how PollingProjectConfigManager initializes and polls currentProjectConfig after an HTTP 304. Done means a failed startup can initialize the configuration during a later poll even when the response is 304.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.