This is an automated email from the ASF dual-hosted git repository. robertlazarski pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git
commit 08f5f605f21afcf5423e504cad69fdd0b4e94237 Author: Robert Lazarski <[email protected]> AuthorDate: Sun Sep 6 14:03:20 2026 -1000 Fix a brace-counting drift and remove the last JiBX code The re-indenter dropped the brace delta on lines it emitted unchanged, so a line closing a block comment or text block with code after the delimiter -- "*/ }" -- lost those braces and shifted every later line for the rest of the file. All branches now fold the delta in. The userguide version sync also passed when its fileset matched nothing, both counts being zero; it now fails on that too. Separately, jibx has not been a selectable databinding since 2.0.1, so the unreachable branch in loadWsdl (which would have thrown NPE on a null type), the dead XSL template and two misleading comments are gone. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --- .../src/org/apache/axis2/util/PrettyPrinter.java | 10 +++++-- .../axis2/wsdl/codegen/CodeGenConfiguration.java | 3 +- .../AxisServiceBasedMultiLanguageEmitter.java | 3 +- .../wsdl/codegen/extension/XMLBeansExtension.java | 2 +- .../template/java/TestObjectCreationTemplate.xsl | 9 ------ .../org/apache/axis2/util/PrettyPrinterTest.java | 32 ++++++++++++++++++++++ pom.xml | 5 ++++ 7 files changed, 47 insertions(+), 17 deletions(-) diff --git a/modules/codegen/src/org/apache/axis2/util/PrettyPrinter.java b/modules/codegen/src/org/apache/axis2/util/PrettyPrinter.java index 7cec9c5e52..5f181f12e9 100644 --- a/modules/codegen/src/org/apache/axis2/util/PrettyPrinter.java +++ b/modules/codegen/src/org/apache/axis2/util/PrettyPrinter.java @@ -93,21 +93,25 @@ public class PrettyPrinter { int depth = 0; for (String raw : source.split("\r\n|\n|\r", -1)) { + // Every branch must fold the scan result into depth, including the ones + // that emit the line unchanged: a line can close a text block or a block + // comment and still carry code after the delimiter -- "*/ }" is the plain + // case -- and dropping those braces shifts every later line permanently. if (scanner.inTextBlock) { // Leading whitespace here is part of the string value. out.add(raw); - scanner.scan(raw); + depth = Math.max(depth + scanner.scan(raw), 0); continue; } String trimmed = raw.trim(); if (trimmed.isEmpty()) { out.add(""); - scanner.scan(raw); + depth = Math.max(depth + scanner.scan(raw), 0); continue; } if (scanner.inBlockComment) { out.add(indent(depth) + (trimmed.startsWith("*") ? " " + trimmed : trimmed)); - scanner.scan(raw); + depth = Math.max(depth + scanner.scan(raw), 0); continue; } // A line that starts by closing a block sits at the level of the block diff --git a/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java b/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java index c2de9046f4..2dd27f6878 100644 --- a/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java +++ b/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java @@ -803,8 +803,7 @@ public class CodeGenConfiguration implements CommandLineOptionConstants { } WSDL11ToAxisServiceBuilder builder; - // jibx currently does not support multiservice - if ((serviceQname != null) || (getDatabindingType().equals("jibx"))) { + if (serviceQname != null) { builder = new WSDL11ToAxisServiceBuilder( wsdl4jDef, serviceQname, diff --git a/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java b/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java index a8fa27e981..3d7d0bab33 100644 --- a/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java +++ b/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java @@ -1766,8 +1766,7 @@ public class AxisServiceBasedMultiLanguageEmitter implements Emitter { //add the db type attribute - the name of the databinding type //this will be used to select the correct template addAttribute(doc, "dbtype", codeGenConfiguration.getDatabindingType(), rootElement); - //add the wrapped flag state - this is used by JiBX, but may be useful - //for other frameworks in the future + //add the wrapped flag state - read by InterfaceImplementationTemplate String wrapflag = Boolean.toString(codeGenConfiguration.isParametersWrapped()); addAttribute(doc, "wrapped", wrapflag, rootElement); diff --git a/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java b/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java index 5019ef8413..b2a5b9504c 100644 --- a/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java +++ b/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java @@ -73,7 +73,7 @@ public class XMLBeansExtension extends AbstractDBProcessingExtension { return; } - // check the JiBX binding definition file specified + // the caller may override the randomly generated type system name String typeSystemName = (String)configuration.getProperties().get(TYPESYSTEMNAME_OPTION); try { diff --git a/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl b/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl index d0bccd2f16..197cda1517 100644 --- a/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl +++ b/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl @@ -144,15 +144,6 @@ </xsl:if> </xsl:for-each> - </xsl:template> - <!-- ################################################################################# --> - <!-- ############################ jibx template ############################## --> - <xsl:template match="databinders[@dbtype='jibx']"> - // create the desired object and provide it as the test object - public java.lang.Object getTestObject(java.lang.Class type) throws java.lang.Exception { - return type.newInstance(); - } - </xsl:template> <!-- ################################################################################# --> <!-- ############################ Jaxbri template ################################### --> diff --git a/modules/codegen/test/org/apache/axis2/util/PrettyPrinterTest.java b/modules/codegen/test/org/apache/axis2/util/PrettyPrinterTest.java index 747248d1a2..7cd623e1c6 100644 --- a/modules/codegen/test/org/apache/axis2/util/PrettyPrinterTest.java +++ b/modules/codegen/test/org/apache/axis2/util/PrettyPrinterTest.java @@ -133,6 +133,38 @@ public class PrettyPrinterTest { assertTrue(out.contains(" /**\n * javadoc\n */"), out); } + /** + * A line can close a block comment and still carry code after the delimiter. + * Dropping those braces shifted every later line permanently. + */ + @Test + public void testBracesAfterAClosingBlockCommentAreCounted() { + String out = PrettyPrinter.format( + "class A {\n" + + "void m() {\n" + + "/* comment\n" + + "*/ }\n" + + "int after = 1;\n" + + "}\n"); + assertTrue(out.contains("\n int after = 1;\n"), + "the method closed on the comment line, so this sits at class level:\n" + out); + assertTrue(out.endsWith("}\n"), out); + } + + /** Same, for a line that closes a text block and then opens a brace. */ + @Test + public void testBracesAfterAClosingTextBlockAreCounted() { + String out = PrettyPrinter.format( + "class A {\n" + + "String s = \"\"\"\n" + + "body\n" + + "\"\"\"; if (x) {\n" + + "y();\n" + + "}\n" + + "}\n"); + assertTrue(out.contains("\n y();\n"), out); + } + @Test public void testBlankLinesStayBlankAndCountIsPreserved() { assertOnlyIndentChanged("class A {\n\n \nvoid m() {}\n\n}\n"); diff --git a/pom.xml b/pom.xml index 21c1798c64..d16e8d04f2 100644 --- a/pom.xml +++ b/pom.xml @@ -1393,6 +1393,11 @@ <contains text="<axis2.version>${project.version}</axis2.version>"/> </fileset> </resourcecount> + <fail message="axis2.version sync found no userguide sample poms under modules/samples/userguide/src/userguide - the samples moved or were renamed, and the sync is now doing nothing"> + <condition> + <equals arg1="${userguide.pom.count}" arg2="0"/> + </condition> + </fail> <fail message="axis2.version sync reached only ${userguide.synced.count} of ${userguide.pom.count} userguide sample poms - check the property name in each"> <condition> <not>
