Skip to content

Negative cache for 404 NOT_FOUND - #7334

Open
chrisrueger wants to merge 3 commits into
bndtools:masterfrom
chrisrueger:dep-sources-negative-cache
Open

Negative cache for 404 NOT_FOUND#7334
chrisrueger wants to merge 3 commits into
bndtools:masterfrom
chrisrueger:dep-sources-negative-cache

Conversation

@chrisrueger

@chrisrueger chrisrueger commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Closes #7310

This pull request introduces negative caching for HTTP 404 (Not Found) responses in the HTTP client and cache system. Now, when a resource is not found, the system records this state in the cache, allowing future requests to avoid unnecessary network calls until the cache entry expires. The changes also update related tests and increment the package version.

Negative caching implementation:

  • Added a notFound flag to the cache metadata (InfoDTO) and methods to record and check negative cache entries (updateNegativeCache, hasNegativeCache) in URLCache.java. [1] [2] [3]
  • Updated HttpClient.java to save negative cache entries when a 404 is received, and to return cached 404 responses if present and valid. [1] [2] [3]

Test updates for negative caching:

  • Modified tests in HttpClientTest.java and RemoteRepoTest.java to reflect the new behavior: 404 responses are now cached, and tests force cache refreshes as needed. [1] [2]

Version update:

  • Bumped the package version in package-info.java to 2.2.0 to reflect these changes.

Implement negative caching to avoid repeated requests for non-existent resources. When a 404 response is received, the metadata is cached with a notFound flag. Subsequent requests within the TTL window will return the cached 404 without making a network request. This reduces load on servers and improves performance for missing resource scenarios e.g. missing -sources.jar files of dependencies

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
@chrisrueger

Copy link
Copy Markdown
Contributor Author

@jhanders34 are you able to access https://github.com/bndtools/bnd/actions/runs/29997607951 and download the pr-7334-jdk17-ubuntu-latest at the bottom of the page?

This is the bndtools Eclipse plugin jar of this PR which you could install into Eclipse via "Help / Install new software" to test the PR if it improves the situation for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EclipsePlugin: Should there be a negative cache for source downloads?

1 participant