Skip to content

Allow the dynamic PDF-name cache to be cleared and bounded - #730

Open
softvisionfd wants to merge 1 commit into
veraPDF:integrationfrom
softvision-dev:clearable-name-cache
Open

Allow the dynamic PDF-name cache to be cleared and bounded#730
softvisionfd wants to merge 1 commit into
veraPDF:integrationfrom
softvision-dev:clearable-name-cache

Conversation

@softvisionfd

Copy link
Copy Markdown

Summary

ASAtom keeps a process-wide cache of PDF names that are not one of the predefined constants. It never
evicts, so a long-running process that validates documents with many unique names keeps accumulating them
for its whole lifetime, with no way to reclaim the memory.

Changes

  • ASAtom.clearCache() drops the accumulated dynamic names (the predefined name constants are untouched).
    A long-running process that validates untrusted documents can call this between jobs to release names
    accumulated from earlier documents.
  • ASAtom.setMaxCachedNames(int) / getMaxCachedNames() set an optional upper bound; once the cache holds
    that many names, new names are returned uncached.

Atom equality is by value (equals / hashCode), so an uncached atom behaves identically to a cached one;
no code compares atoms by identity except against the predefined constants, which are unaffected.

Backward compatibility

Default is unbounded with no automatic clearing, so behaviour is unchanged unless a caller opts in. Java 8
compatible, and all existing parser tests pass.

ASAtom keeps a process-wide cache of PDF names that are not one of the
predefined constants. It never evicts, so a long-running process that
validates documents with many unique names keeps accumulating them for its
whole lifetime, with no way to reclaim the memory.

Add ASAtom.clearCache() to drop the accumulated dynamic names (the predefined
constants are untouched), and an optional upper bound via setMaxCachedNames
beyond which new names are returned uncached. Atom equality is by value, so an
uncached atom behaves identically to a cached one; no code compares atoms by
identity except against the predefined constants, which are unaffected.

Default is unbounded with no automatic clearing, so behaviour is unchanged
unless a caller opts in.
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 46 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 3ee14947-4007-4cd3-a096-070d6e583a8d

📥 Commits

Reviewing files that changed from the base of the PR and between 815f8cc and 895871e.

📒 Files selected for processing (1)
  • src/main/java/org/verapdf/as/ASAtom.java

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant