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

Jersey 2.X ResourceDoclet much slower compared to 1.X #5700

Open
yrosen-infinidat opened this issue Jul 18, 2024 · 4 comments
Open

Jersey 2.X ResourceDoclet much slower compared to 1.X #5700

yrosen-infinidat opened this issue Jul 18, 2024 · 4 comments

Comments

@yrosen-infinidat
Copy link

We've upgraded our Jersey from version 1.19.4 to version 2.40, and ever since then, our Javadoc task (executed by Ant) takes much longer - about 4 minutes, in contrast to the instant execution it had in 1.19.4.

This is the old task:

configurations {
    resourceDoclet
}
dependencies {
    resourceDoclet "com.sun.jersey.contribs:wadl-resourcedoc-doclet:1.19.4"
}

task generateResourcedocXmlAnt {
    def xmlOutputDir = "${buildDir}/resources/main"
    outputs.dir(xmlOutputDir)
    doLast {
        if (!file(xmlOutputDir).exists()) {
            // if gradle is executed directly (not out of make), resources dir doesn't exist
            xmlOutputDir = "${buildDir}"
        }
        ant.javadoc(
            docletpath: configurations.resourceDoclet.asPath,
            doclet: "com.sun.jersey.wadl.resourcedoc.ResourceDoclet",
            access: 'public',
            encoding: 'UTF-8',
            additionalparam: "-output ${xmlOutputDir}/resourcedoc.xml") {
                // Java files to generate javadoc from
                sourcepath {
                    sourceSets.main.java.srcDirs.each{ c -> pathElement(path: c) }
                }
                // libraries to use for compilation
                classpath {
                    sourceSets.main.compileClasspath.each{ c -> pathElement(path: c) }
                }
        }
    }
}

And this is the new one:

configurations {
    resourceDoclet
}
dependencies {
    resourceDoclet "org.glassfish.jersey.ext:jersey-wadl-doclet:2.40"
}

task generateResourcedocXmlAnt {
    def xmlOutputDir = "${buildDir}/resources/main"
    outputs.dir(xmlOutputDir)
    doLast {
        if (!file(xmlOutputDir).exists()) {
            // if gradle is executed directly (not out of make), resources dir doesn't exist
            xmlOutputDir = "${buildDir}"
        }
        ant.javadoc(
            docletpath: configurations.resourceDoclet.asPath,
            doclet: "org.glassfish.jersey.wadl.doclet.ResourceDoclet",
            access: 'public',
            encoding: 'UTF-8',
            additionalparam: "-output ${xmlOutputDir}/resourcedoc.xml") {
                // Java files to generate javadoc from
                sourcepath {
                    sourceSets.main.java.srcDirs.each{ c -> pathElement(path: c) }
                }
                // libraries to use for compilation
                classpath {
                    sourceSets.main.compileClasspath.each{ c -> pathElement(path: c) }
                }
        }
    }
}

This is the log produced by the execution of the task in the old version, everything here shows up instantly.
(There are some Javadoc warnings which I'm not showing because they reveal information about the source code, but they are the same in both the old and new version anyways)

[ant:javadoc] Jul 18, 2024 11:38:58 AM com.sun.jersey.wadl.resourcedoc.ResourceDoclet start
[ant:javadoc] INFO: Wrote /Volumes/Volume/workspace/core-system4/mgmt2/api/target/resources/main/resourcedoc.xml

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

However, in the new version, it gets to this point:

[ant:javadoc] Jul 18, 2024 11:42:23 AM org.glassfish.jersey.wadl.doclet.DocletUtils createOutputFile
[ant:javadoc] INFO: cdataElements [commentText]
[ant:javadoc] Jul 18, 2024 11:42:23 AM org.glassfish.jersey.wadl.doclet.DocletUtils createOutputFile
[ant:javadoc] INFO: classes [class org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ResourceDocType]
[ant:javadoc] Jul 18, 2024 11:42:25 AM org.glassfish.jersey.wadl.doclet.DocletUtils createOutputFile
[ant:javadoc] INFO: 28575 nodes found by commentText

Then it's stuck here for about 4 minutes, and afterwards proceeds normally with:

[ant:javadoc] Jul 18, 2024 11:42:23 AM org.glassfish.jersey.wadl.doclet.DocletUtils createOutputFile
[ant:javadoc] INFO: cdataElements [commentText]
[ant:javadoc] Jul 18, 2024 11:42:23 AM org.glassfish.jersey.wadl.doclet.DocletUtils createOutputFile
[ant:javadoc] INFO: classes [class org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ResourceDocType]
[ant:javadoc] Jul 18, 2024 11:42:25 AM org.glassfish.jersey.wadl.doclet.DocletUtils createOutputFile
[ant:javadoc] INFO: 28575 nodes found by commentText
[ant:javadoc] Jul 18, 2024 11:46:28 AM org.glassfish.jersey.wadl.doclet.DocletUtils createOutputFile
[ant:javadoc] INFO: Wrote org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ResourceDocType@7c2e059f in /Volumes/Volume/workspace/core-system2/mgmt2/api/target/resources/main/resourcedoc.xml

Is this a known issue/behavior? Or am I missing something in the configuration?
Is there any problem with keeping old Jersey just for this purpose while having everything else run on new Jersey? Or will there be some version mismatches?

@jansupol
Copy link
Contributor

What JDK do you use for Jersey 2.40? The jersey-wadl-doclet module used JDK classes, which are no longer available in a new JDK. So for JDK 12+, a different set of JDK classes are used, which might cause low speed.

@yrosen-infinidat
Copy link
Author

yrosen-infinidat commented Jul 22, 2024

I'm using JDK 8.
My main question here is just whether or not it would be problematic to keep the old doclet while still using Jersey 2.40.

Edit:
Tested now on JDK 17 as well, still the same.

@yrosen-infinidat
Copy link
Author

@jansupol Do you know if there's any problem with keeping the versions mismatched?

@senivam
Copy link
Contributor

senivam commented Aug 13, 2024

@yrosen-infinidat as per my investigation the main difference between 2.x and 1.x WADL generation approach is usage of JAXB vs Xerces (+JAXB). The newer Jersey generates a full DOM model using JAXB while the old one uses a combination of JAXB + XML serializer (from Xerces). While testing on small WADLs it gives a pretty similar generation speed. However, I presume, that when WADL is quite big, the newer Jersey could delay WADL's generation.
Regarding your question about mismatched versions - com.sun.jersey.contribs:wadl-resourcedoc-doclet:1.19.4 can be safely used as a WADL generator. It does not affect other modules' functionality.

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

No branches or pull requests

3 participants