feat: JSON-LD context caching and HTTP access logging#46
Open
Mortega5 wants to merge 6 commits into
Open
Conversation
Without a timeout, fetching external JSON-LD contexts (e.g. w3.org) could block indefinitely, causing EDC transfer provisioning to fail with a socket timeout. The empty close() also leaked connections from the pool after each request. - Add configurable timeout to the Apache HTTP client (default 10s) via http-client.timeout-ms property - Implement close() in JsonLdHttpResponse to release connections
Introduces a composite document loader pattern to intercept known JSON-LD context URLs and serve them from classpath resources instead of hitting the W3C servers on every policy evaluation. The loader chain (LocalContextRepository → HTTP fallback) is produced as a singleton bean to avoid recreating it on each request.
Adds a CachingContextRepository that wraps HTTP fetches with a Caffeine cache (configurable TTL via jsonld-cache.ttl-seconds). Logs distinguish local classpath hits, cache hits, and HTTP fetches. The httpFallback in CompositeDocumentLoader is removed — the cache layer is now the last and exhaustive resolver in the chain.
Adds ContainerRequestFilter/ContainerResponseFilter for inbound requests (remote IP, X-Forwarded-For, protocol, method, path, status, duration) and ClientRequestFilter/ClientResponseFilter for outbound REST client calls. Configurable exclude-paths for server log. OPA REST client registered with the outgoing filter via providers config.
wistefan
requested changes
May 19, 2026
|
|
||
| @Slf4j | ||
| @Provider | ||
| @ApplicationScoped |
Collaborator
There was a problem hiding this comment.
Not fully sure, but I think the request filter needs to be annotated with@RegisterForReflection to work on native images
Collaborator
Author
There was a problem hiding this comment.
The runner file seems to work. Claude says it isn't needed, so I guess it isn't needed.
| Long start = (Long) requestContext.getProperty(START_TIME); | ||
| if (start == null) return; | ||
|
|
||
| long duration = System.currentTimeMillis() - start; |
Collaborator
There was a problem hiding this comment.
For testability, it would be better to use the clock interface here, instead of directly accessing System.currentTime
wistefan
approved these changes
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improvements to JSON-LD context resolution and server observability: