[
https://issues.apache.org/jira/browse/KNOX-3591?focusedWorklogId=1055591&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1055591
]
ASF GitHub Bot logged work on KNOX-3591:
----------------------------------------
Author: ASF GitHub Bot
Created on: 18/Nov/26 09:36
Start Date: 18/Nov/26 09:36
Worklog Time Spent: 10m
Work Description: smolnar82 opened a new pull request, #1525:
URL: https://github.com/apache/knox/pull/1525
[KNOX-3591](https://issues.apache.org/jira/browse/KNOX-3591) - KnoxIDF
resources are instantiated per request because @Singleton is not inherited
## What changes were proposed in this pull request?
`jakarta.inject.Singleton` is not `@Inherited`, so the KnoxIDF subclasses of
the singleton knoxtoken resources were created per request and ran `init()` on
every call. On the token endpoint, every request did an uncached gateway
keystore load under a file lock (`setupPublicCertPEM`) and wrote duplicate
`setupTokenStateService` log lines.
This PR adds `@Singleton` to all KnoxIDF resources except
`RegistrationResource`. That one keeps per-request state (`redirectUris`,
`allowedScopes`) on the instance, so it stays `@RequestScoped`.
## How was this patch tested?
- `mvn -pl gateway-service-knoxidf test`: all tests pass.
- Ran a local RFC 8693 token exchange load test (20 threads, delegation
depth 3) and checked that `init()` runs once per resource and the per-request
log lines are gone.
## Integration Tests
No new tests. The behaviour is unchanged; the existing KnoxIDF integration
tests exercise these endpoints.
Issue Time Tracking
-------------------
Worklog Id: (was: 1055591)
Remaining Estimate: 0h
Time Spent: 10m
> Make the KnoxIDF resources @Singleton
> -------------------------------------
>
> Key: KNOX-3591
> URL: https://issues.apache.org/jira/browse/KNOX-3591
> Project: Apache Knox
> Issue Type: Bug
> Components: KnoxIDF
> Reporter: Sandor Molnar
> Assignee: Sandor Molnar
> Priority: Major
> Fix For: 3.1.0
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> {{jakarta.inject.Singleton}} is not {{{}@Inherited{}}}, so the KnoxIDF
> subclasses of the singleton knoxtoken resources are created per request and
> run {{init()}} on every call. On the token endpoint, that means an uncached
> gateway keystore load under a file lock ({{{}setupPublicCertPEM{}}}) and
> duplicate {{setupTokenStateService}} log lines on each request. It caps RFC
> 8693 token exchange at about 105 req/s locally with 20 threads locally on my
> Mac.
> Fix: add {{@Singleton}} to all KnoxIDF resources except
> {{{}RegistrationResource{}}}. That one keeps per-request state
> ({{{}redirectUris{}}}, {{{}allowedScopes{}}}) on the instance, so it stays
> {{{}@RequestScoped{}}}.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)