Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonRecordSeparatorPolicy doesn't handle braces inside quoted strings properly [BATCH-2125] #1470

spring-issuemaster opened this issue Oct 16, 2013 · 1 comment


Copy link

@spring-issuemaster spring-issuemaster commented Oct 16, 2013

Frans Flippo opened BATCH-2125 and commented

isEndOfRecord is currently implemented as:

public boolean isEndOfRecord(String line) {
		return StringUtils.countOccurrencesOf(line, "{") == StringUtils.countOccurrencesOf(line, "}")
				&& line.trim().endsWith("}");

This is too simple. Nested braces inside quoted strings will be considered by the above code to unbalance the number of opening and closing braces.

Only braces outside of quotation marks should be considered. I think iterating over the string character by character, keeping track of whether or not we're inside quotation marks, is the only way to handle this.

I can write an implementation if desired.

Affects: 2.1.0



This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Oct 17, 2013

Frans Flippo commented

Added JAR file with that reproduces this. (Run as java -jar BATCH-2125.jar).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.