jerryshao commented on code in PR #14884:
URL: https://github.com/apache/gravitino/pull/14884#discussion_r4547888575
##########
core/build.gradle.kts:
##########
@@ -109,12 +109,24 @@ val testJar by tasks.registering(Jar::class) {
from(sourceSets["test"].output)
}
+// Modules weave MethodMonitorAspect into their own @Monitored methods from
this jar. The shaded
+// jar cannot be used as the aspect path: relocation rewrites the constant
pool of woven classes and
+// breaks their AspectJ attributes, which makes ajc fail.
+val aspectJar by tasks.registering(Jar::class) {
+ archiveClassifier.set("aspects")
+ from(sourceSets["main"].output) {
+ include("org/apache/gravitino/metrics/MethodMonitorAspect.class")
+ }
+}
Review Comment:
The weave-only aspects jar is written to the default Jar output directory,
`core/build/libs/gravitino-core-<version>-aspects.jar`. `copySubprojectLib`
copies every `*.jar` from each project's `build/libs` into
`distribution/package/libs`, excluding only `*-jcstress.jar`, `*-jmh.jar`, and
`error_prone_annotations-*.jar` (`build.gradle.kts` L1688-1694), and
`bin/gravitino.sh` then puts `libs/*` on the classpath in unspecified order.
Since `compileDistribution` builds the maintenance and idp-basic plugins
(which build this jar) and `copySubprojectLib` runs after `:core:build`, both
`gravitino-core-<version>.jar` and `gravitino-core-<version>-aspects.jar` end
up in the distribution. They contain different bytes for
`org.apache.gravitino.metrics.MethodMonitorAspect` (unshaded weave vs. the
shadow/ASM-rewritten class), so the server classpath gets two definitions of
the aspect, which is the runtime leak this patch tried to avoid by not using
the `aspect` configuration. I don't see wrong metric counts from it, but it's
worth keeping out of the package.
Could you set `aspectJar.destinationDirectory` outside `build/libs` (e.g.
`layout.buildDirectory.dir("aspects")`), or exclude `*-aspects.jar` in
`copySubprojectLib`? Moving the output directory is more robust, because the
distribution copy is a filename glob over `build/libs`, not a resolution of the
`aspects` configuration.
--
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]