davsclaus commented on code in PR #26304: URL: https://github.com/apache/camel/pull/26304#discussion_r3989793531
########## components/camel-groovy/src/main/java/org/apache/camel/groovy/json/PrettyJsonGenerator.java: ########## @@ -0,0 +1,138 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.groovy.json; + +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import groovy.json.DefaultJsonGenerator; +import groovy.json.JsonGenerator; +import org.apache.groovy.json.internal.CharBuf; Review Comment: `org.apache.groovy.json.internal` is, as the package name says, internal — it carries no compatibility promise across Groovy releases, and it appears here in the *signatures* of the overridden methods, so there is no way to insulate from it while subclassing `DefaultJsonGenerator`. I think the trade is defensible: `DefaultJsonGenerator` is public and its `writeMap`/`writeIterator`/`writeArray` are `protected` extension points, the alternative is a full reimplementation of Groovy's JSON output, and the golden test in this PR turns any drift into a hard build failure rather than silent wrong output. What I would like is for that to be written down — a sentence in the PR description (and ideally in the class javadoc) saying the class deliberately extends `DefaultJsonGenerator` and therefore binds to `org.apache.groovy.json.internal.CharBuf`, and that `GroovyJsonPrettyPrintTest` is the guard for a Groovy upgrade. camel-groovy tracks Groovy fairly closely, so whoever does the next bump should find out from the code why their build broke. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
