open-feature / open-feature/java-sdk

on setProvider call, shutting down the previous provider should happen before creating the new one

オープン
#1,934 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
Java
スター
128
フォーク
61
平均マージ
5時間 57分
マージ済み PR(30日)
26

説明

Hi,

I noticed that if I use `setProvider` to set a provider, then later I want to replace it with another provider (in my case, I do this to supports changing the api key I use to connect to the provider without stopping my application, so I recreate the provider with the new key) the following happens in parallel:
- the shutting down of the old provider
- the initialization of the new one

For Unleash, this can be a problem as shown in those logs:
```
server-1 | {"timestamp":"2026-04-28T10:55:47.302964637Z","logger":"io.getunleash.repository.FeatureBackupHandlerFile","level":"INFO","thread":"openfeature-provider-thread-1","message":"Unleash will try to load feature toggle states from temporary backup"}
server-1 | {"timestamp":"2026-04-28T10:55:47.304799269Z","logger":"io.getunleash.repository.PollingFeatureFetcher","level":"INFO","thread":"openfeature-provider-thread-1","message":"Starting polling client"}
server-1 | {"timestamp":"2026-04-28T10:55:47.485565437Z","logger":"io.getunleash.DefaultUnleash","level":"ERROR","thread":"openfeature-provider-thread-1","message":"You already have 1 clients for AppName [my-app] with instanceId: [xxxxxxxx] running. Please double check your code where you are instantiating the Unleash SDK"}
server-1 | {"timestamp":"2026-04-28T10:55:47.485655434Z","logger":"dev.openfeature.contrib.providers.unleash.UnleashProvider","level":"INFO","thread":"openfeature-provider-thread-1","message":"finished initializing provider"}
server-1 | {"timestamp":"2026-04-28T10:55:47.485682289Z","logger":"dev.openfeature.sdk.FeatureProviderStateManager","level":"INFO","thread":"openfeature-provider-thread-1","message":"Provider Unleash transitioned from state NOT_READY to state READY"}
server-1 | {"timestamp":"2026-04-28T10:55:47.486912037Z","logger":"dev.openfeature.contrib.providers.unleash.UnleashProvider","level":"INFO","thread":"openfeature-provider-thread-2","message":"shutdown"}
server-1 |
```

As we can see the shutdown of the original client happens after the initialization of the new one and we get an ERROR message from the Unleash library.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

エントリーポイントのsetProviderから開始し、既存のproviderがどのように停止され、置き換えがどのように初期化されるかを追跡します。issueに示されているproviderの置き換えを再現し、停止が初期化の開始前に完了すること、およびUnleash duplicate-client errorが発生しなくなることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
api
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
50/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。