Skip to content

Resolve OAuth2 access-token suppliers for each SMTP connection #9

Description

@bbottema

Problem

The pool currently reads one fixed OAuth2 token from its Jakarta Mail Session and reuses that value when allocating or reconnecting transports. A long-lived pool therefore cannot ask an application for a refreshed access token when the previous token expires.

This is the pool-side part of Simple Java Mail #692, which extends the fixed-token XOAUTH2 support originally introduced in Simple Java Mail #421.

Change

Accept a Supplier<String> through a dedicated Session property and resolve it immediately before every physical Transport.connect(username, token):

  • resolve on initial allocation;
  • resolve when a disconnected transport is claimed for reuse;
  • do not resolve when a connected transport is reused;
  • retain the existing fixed-token property as a compatible fallback;
  • fail clearly and without exposing token material when the supplier throws or returns a blank value.

The pool remains independent of Simple Java Mail's public provider interface and depends only on the JDK Supplier<String> contract.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions