This is an automated email from the ASF dual-hosted git repository. jdaugherty pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 8efcc85ea8da3b4d4832716a2a3c70e8201ce46d Merge: 963386d56d 408728babc Author: James Daugherty <[email protected]> AuthorDate: Fri Oct 16 13:12:34 2026 -0400 Merge branch '8.1.x' into 9.0.x .../org/grails/io/support/AntPathMatcher.java | 36 ++++++----- .../grails/io/support/AntPathMatcherSpec.groovy | 29 ++++++++- .../commands/io/FileSystemInteractionImpl.groovy | 9 +-- .../io/FileSystemInteractionImplSpec.groovy | 75 ++++++++++++++++++++++ .../core/cli/io/FileSystemInteractionImpl.groovy | 9 +-- .../groovy/org/grails/config/CompositeConfig.java | 59 ++++++++++------- .../cli/io/FileSystemInteractionImplSpec.groovy | 75 ++++++++++++++++++++++ .../org/grails/config/CompositeConfigSpec.groovy | 40 +++++++++--- .../org/grails/io/support/GrailsResourceUtils.java | 4 +- .../io/support/GrailsResourceUtilsSpec.groovy | 8 +-- .../web/layout/TokenizedHTMLPage2Content.java | 2 +- .../web/layout/GrailsHTMLPageParserSpec.groovy | 1 + .../commands/io/FileSystemInteractionImpl.groovy | 9 +-- .../io/FileSystemInteractionImplSpec.groovy | 22 +++++++ .../templates/TemplateRendererImplSpec.groovy | 4 +- .../groovy/org/grails/web/json/JSONTokener.java | 2 +- .../groovy/org/grails/web/json/JSONWriter.java | 3 +- .../org/grails/web/json/JSONTokenerApiSpec.groovy | 10 +++ .../org/grails/web/json/JSONWriterApiSpec.groovy | 5 +- .../web/json/PrettyPrintJSONWriterApiSpec.groovy | 19 +++++- 20 files changed, 340 insertions(+), 81 deletions(-) diff --cc grails-web-common/src/main/groovy/org/grails/web/json/JSONWriter.java index 0e3997a35a,98d829f044..f9bbe5f07c --- a/grails-web-common/src/main/groovy/org/grails/web/json/JSONWriter.java +++ b/grails-web-common/src/main/groovy/org/grails/web/json/JSONWriter.java @@@ -187,13 -161,15 +187,12 @@@ public class JSONWriter */ protected JSONWriter end(Mode m, char c) { if (this.mode != m) { - throw new JSONException(m == OBJECT ? "Misplaced endObject." : - "Misplaced endArray."); + throw new JSONException(c == '}' ? "Misplaced endObject." : "Misplaced endArray."); } this.pop(m); - try { - this.writer.write(c); - } catch (IOException e) { - throw new JSONException(e); - } + generate(c == ']' ? generator::writeEndArray : generator::writeEndObject); this.comma = true; + closeIfDone(); return this; } diff --cc grails-web-common/src/test/groovy/org/grails/web/json/PrettyPrintJSONWriterApiSpec.groovy index a1d1feca94,84230a889c..4f556790f5 --- a/grails-web-common/src/test/groovy/org/grails/web/json/PrettyPrintJSONWriterApiSpec.groovy +++ b/grails-web-common/src/test/groovy/org/grails/web/json/PrettyPrintJSONWriterApiSpec.groovy @@@ -69,9 -71,54 +69,24 @@@ class PrettyPrintJSONWriterApiSpec exte operation | message ({ w -> w.key(null) }) | 'Null key' ({ w -> w.key('key') }) | 'Misplaced key' - ({ w -> w.value(true) }) | 'Value out of sequence' ({ w -> w.object().valueNull() }) | 'Value out of sequence' - // endObject misuse is matched on the shared prefix only: the writer currently reports it as endArray - ({ w -> w.array().endObject() }) | 'Misplaced end' + ({ w -> w.array().endObject() }) | 'Misplaced endObject' ({ w -> w.object().endArray() }) | 'Misplaced endArray' } + + void "pretty writer writes nothing before rejecting a misplaced end"() { + given: + def output = new StringWriter() + def writer = new PrettyPrintJSONWriter(output) + writer.array() + def written = output.toString() + + when: + writer.endObject() + + then: + def error = thrown(JSONException) + error.message == 'Misplaced endObject.' + output.toString() == written + } - - void "pretty writer wraps failures in newlines indentation keys and values"() { - given: - def output = Stub(Writer) { - write(_) >> { List arguments -> - def value = arguments[0] - if (value == failingValue) { - throw new IOException('broken output') - } - } - } - def writer = new PrettyPrintJSONWriter(output) - - when: - operation(writer) - - then: - def error = thrown(JSONException) - error.cause instanceof IOException - error.message == 'broken output' - - where: - failingValue | operation - PrettyPrintJSONWriter.NEWLINE | ({ w -> w.object().key('key') }) - ' ' | ({ w -> w.object().key('key') }) - ': ' | ({ w -> w.object().key('key') }) - 'true' | ({ w -> w.array().value(true) }) - (int) ',' | ({ w -> w.array().value(true).value(false) }) - } }
