Avoid to copy Logstash's classes into the uber jar

未关闭
#17 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
java
领域
build-system

调研方向

Start in build.gradle, especially the LOGSTASH_CORE_PATH dependency and jar packaging configuration. Run ./gradlew jar, then inspect build/libs/logstash-input-java_input_example-1.0.2.jar with jar tf; done means the uber jar no longer contains org/logstash classes.

由索引模型根据 Issue 内容生成。

描述

bug

Logstash information:

Please include the following information:

  1. Logstash version (e.g. bin/logstash --version) 8.4.0
  2. Logstash installation source (e.g. built from source, with a package manager: DEB/RPM, expanded from tar or zip archive, docker)
  3. How is Logstash being run (e.g. as a service/service manager: systemd, upstart, etc. Via command line, docker/kubernetes)
  4. How was the Logstash Plugin installed

JVM (e.g. java -version):

If the affected version of Logstash is 7.9 (or earlier), or if it is NOT using the bundled JDK or using the 'no-jdk' version in 7.10 (or higher), please provide the following information:

  1. JVM version (java -version) (bundled)
  2. JVM installation source (e.g. from the Operating System's package manager, from source, etc).
  3. Value of the JAVA_HOME environment variable if set.

OS version (uname -a if on a Unix-like system):

Description of the problem including expected versus actual behavior:
The uber jar (and the gem) created contains also the Logstash classes. This could create weird problems when loaded inside a runtime Logstash, because the classloader could load a class from this jar and not from the runtime Logstash creating weird linkage errors.

Steps to reproduce:

  1. Build the jar with ./gradlew jar, eventually fixing the build.gradle with:
diff --git a/build.gradle b/build.gradle
index 5f54ad3..4a85c25 100644
--- a/build.gradle
+++ b/build.gradle
@@ -49,7 +49,7 @@ dependencies {
    compileOnly 'org.apache.logging.log4j:log4j-api:2.17.0' // provided by Logstash
    compileOnly 'org.apache.logging.log4j:log4j-core:2.17.0' // provided by Logstash
 
-    implementation fileTree(dir: LOGSTASH_CORE_PATH, include: "**/logstash-core.jar")
+    implementation fileTree(dir: LOGSTASH_CORE_PATH, include: "**/lib/jars/logstash-core.jar")

    testImplementation 'junit:junit:4.12'
    testImplementation 'org.jruby:jruby-complete:9.2.20.1'

  1. verify that the created jar contains classes from Logstash:
$ jar tf ./build/libs/logstash-input-java_input_example-1.0.2.jar
META-INF/
META-INF/MANIFEST.MF
org/
org/logstashplugins/
org/logstashplugins/JavaInputExample.class
org/logstash/
org/logstash/JavaVersionUtils.class
org/logstash/Rubyfier.class
org/logstash/Valuefier$Converter.class
org/logstash/FieldReference$IllegalSyntaxException.class
org/logstash/Timestamp.class
org/logstash/Javafier.class
org/logstash/execution/
org/logstash/execution/ConvergeResultExt$FailedActionExt.class
org/logstash/execution/QueueBatch.class
org/logstash/execution/PipelineReporterExt$SnapshotExt.class
主要语言
Java
星标
8
派生
18
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

logstash-plugins/logstash-input-java_input_example 的其他 Issue

查看 logstash-plugins/logstash-input-java_input_example 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。