Skip to content

feat: added auto refresh token #388 (#389)#390

Merged
petruki merged 2 commits into
masterfrom
staging
May 22, 2026
Merged

feat: added auto refresh token #388 (#389)#390
petruki merged 2 commits into
masterfrom
staging

Conversation

@petruki
Copy link
Copy Markdown
Member

@petruki petruki commented May 22, 2026

This pull request introduces a new feature for automatic authentication token refresh in the Switcher client, along with supporting infrastructure and minor code improvements. The main focus is on enabling the client to automatically refresh its API token before expiration, improving reliability for long-running applications. Additionally, there are some refactorings to executor management and test code cleanup.

New Feature: Automatic Token Refresh

  • Added support for the switcher.autorefreshtoken property, allowing the client to automatically refresh the API token before expiration. This includes updates to the configuration, builder, and property handling (README.md, SwitcherConfig.java, ContextBuilder.java, SwitcherPropertiesImpl.java, ContextKey.java). [1] [2] [3] [4] [5] [6]

  • Implemented a scheduled executor service and logic in ClientRemoteService to handle token refresh, including scheduling, cancellation, and error handling. The service schedules a token refresh shortly before expiry if auto-refresh is enabled (ClientRemoteService.java, SwitcherContextBase.java, WorkerName.java). [1] [2] [3] [4] [5] [6] [7] [8] [9]

Executor Service and Refactoring

  • Refactored snapshot and token refresh executor management for clarity and separation of concerns, including new executor fields, initialization methods, and termination logic in SwitcherContextBase and related files. [1] [2] [3] [4] [5]

Configuration and Documentation

  • Updated the README.md to document the new switcher.autorefreshtoken property and fixed a minor formatting issue in the configuration table. [1] [2]

  • Bumped the project version to 1.10.0-SNAPSHOT in pom.xml.

Testing and Minor Fixes

  • Simplified test setup and teardown methods by calling helper methods directly, improving readability in several test classes. [1] [2] [3] [4] [5]

  • Added a getter for the exp field in AuthResponse to support the token refresh logic.

Other Improvements

  • Minor bug fix in token validation logic to ensure correct silent mode handling.

@petruki petruki added this to the v1.10.0 milestone May 22, 2026
@petruki petruki self-assigned this May 22, 2026
@petruki petruki added the enhancement New feature or request label May 22, 2026
@sonarqubecloud
Copy link
Copy Markdown

@petruki petruki merged commit f26434a into master May 22, 2026
23 of 24 checks passed
@petruki petruki deleted the staging branch May 22, 2026 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant