Skip to content

Adding Parse Limit#2

Closed
mswatosh wants to merge 5 commits into
jbescos:masterfrom
mswatosh:token-limit
Closed

Adding Parse Limit#2
mswatosh wants to merge 5 commits into
jbescos:masterfrom
mswatosh:token-limit

Conversation

@mswatosh

Copy link
Copy Markdown

Adds a config property with default value to limit the total number of parsing operations done on a Json document. If this limit is exceeded an Exception is throw.

/etc/config/copyright-exclude
/etc/config/copyright.txt
/bundles/dist/src/main/resources/README.txt
/impl/src/test/java/org/eclipse/parsson/tests/JsonDocumentParseLimitTest.java

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that file has copyright, can we remove this line?

@mswatosh mswatosh May 22, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the copyright checker is only set to accept the Oracle license. The tricky part with the Eclipse AI license is the last line is variable depending on which AI model was used. As far as I could tell the copyright checker plugin has no way to handle variable text other than the year.

Unless the copyright checker is updated to support this, it will probably be best to remove the plugin for the next release (aligning with EE12). That seemed beyond the scope of this PR though, so I just had it ignore this file for now.

// which is higher than the literal JSON source length due to lookahead
// operations needed to determine parsing completion (e.g., detecting EOF after the
// last token). See JsonConfig.MAX_PARSING_LIMIT for details.
private long documentParseCount = 0;

@jbescos jbescos May 22, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This value cannot be higher than readEnd, and this one is an int. You can set documentParseCount to int too, and then you can remove the static methods you added in JsonContext, and use the existing integer ones.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had chosen long to give users the option of reading extremely large files if the had the memory available, but this is good point, I'll get it changed to int.

Assisted-by: IBM Bob 1.0.2
@jbescos

jbescos commented May 25, 2026

Copy link
Copy Markdown
Owner

eclipse-ee4j#169

@jbescos jbescos closed this May 25, 2026
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.

2 participants