From 0178278473dea0effd1322b92482310e5a600472 Mon Sep 17 00:00:00 2001 From: andsel Date: Thu, 21 Dec 2023 14:49:38 +0100 Subject: [PATCH 01/12] Supressed warnings for Thread's getId (deprecated since java 19 in favor of threadId() --- .../main/java/org/logstash/execution/PipelineReporterExt.java | 3 ++- .../main/java/org/logstash/execution/QueueReadClientBase.java | 4 ++++ .../org/logstash/instrument/monitors/HotThreadsMonitor.java | 2 ++ logstash-core/src/main/java/org/logstash/util/UtilExt.java | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/logstash-core/src/main/java/org/logstash/execution/PipelineReporterExt.java b/logstash-core/src/main/java/org/logstash/execution/PipelineReporterExt.java index 7c455253ec2..abb8af28d9f 100644 --- a/logstash-core/src/main/java/org/logstash/execution/PipelineReporterExt.java +++ b/logstash-core/src/main/java/org/logstash/execution/PipelineReporterExt.java @@ -157,7 +157,7 @@ public RubyHash toHash(final ThreadContext context) { return result; } - @SuppressWarnings({"unchecked","rawtypes"}) + @SuppressWarnings({"unchecked", "rawtypes", "deprecation"}) private RubyArray workerStates(final ThreadContext context, final RubyHash batchMap) { final RubyArray result = context.runtime.newArray(); ((Iterable) pipeline.callMethod(context, "worker_threads")) @@ -174,6 +174,7 @@ private RubyArray workerStates(final ThreadContext context, final RubyHash batch IRubyObject batchSize = Optional.of((RubyThread) thread) .map(RubyThread::getNativeThread) + // TODO getId has been deprecated in JDK 19, when JDK 21 is the target version use threadId() instead .map(Thread::getId) .map(id -> batchMap.op_aref(context, context.runtime.newFixnum(id))) .map(batch -> extractBatchSize(context, batch)) diff --git a/logstash-core/src/main/java/org/logstash/execution/QueueReadClientBase.java b/logstash-core/src/main/java/org/logstash/execution/QueueReadClientBase.java index d227adc8bd5..2de3fa7706b 100644 --- a/logstash-core/src/main/java/org/logstash/execution/QueueReadClientBase.java +++ b/logstash-core/src/main/java/org/logstash/execution/QueueReadClientBase.java @@ -128,8 +128,10 @@ public IRubyObject rubyReadBatch(final ThreadContext context) throws Interrupted } @Override + @SuppressWarnings("deprecation") public void closeBatch(QueueBatch batch) throws IOException { batch.close(); + // TODO getId has been deprecated in JDK 19, when JDK 21 is the target version use threadId() instead inflightBatches.remove(Thread.currentThread().getId()); } @@ -186,7 +188,9 @@ public void rubyAddOutputMetrics(final IRubyObject size) { } @Override + @SuppressWarnings("deprecation") public void startMetrics(QueueBatch batch) { + // TODO getId has been deprecated in JDK 19, when JDK 21 is the target version use threadId() instead long threadId = Thread.currentThread().getId(); inflightBatches.put(threadId, batch); } diff --git a/logstash-core/src/main/java/org/logstash/instrument/monitors/HotThreadsMonitor.java b/logstash-core/src/main/java/org/logstash/instrument/monitors/HotThreadsMonitor.java index 0406d319597..86c662bff03 100644 --- a/logstash-core/src/main/java/org/logstash/instrument/monitors/HotThreadsMonitor.java +++ b/logstash-core/src/main/java/org/logstash/instrument/monitors/HotThreadsMonitor.java @@ -145,6 +145,7 @@ public static List detect() { * stacktrace_size - max depth of stack trace * @return A list of ThreadReport including all selected threads */ + @SuppressWarnings("deprecation") public static List detect(Map options) { String type = "cpu"; if (options.containsKey(ORDERED_BY)) { @@ -164,6 +165,7 @@ public static List detect(Map options) { Map reports = new HashMap<>(); for (long threadId : threadMXBean.getAllThreadIds()) { + // TODO getId has been deprecated in JDK 19, when JDK 21 is the target version use threadId() instead if (Thread.currentThread().getId() == threadId) { continue; } diff --git a/logstash-core/src/main/java/org/logstash/util/UtilExt.java b/logstash-core/src/main/java/org/logstash/util/UtilExt.java index bba64002486..6a2b5352c7f 100644 --- a/logstash-core/src/main/java/org/logstash/util/UtilExt.java +++ b/logstash-core/src/main/java/org/logstash/util/UtilExt.java @@ -34,6 +34,7 @@ public class UtilExt { @JRubyMethod(module = true) + @SuppressWarnings("deprecation") public static IRubyObject get_thread_id(final ThreadContext context, IRubyObject self, IRubyObject thread) { if (!(thread instanceof RubyThread)) { throw context.runtime.newTypeError(thread, context.runtime.getThread()); @@ -41,6 +42,7 @@ public static IRubyObject get_thread_id(final ThreadContext context, IRubyObject final Thread javaThread = ((RubyThread) thread).getNativeThread(); // weak-reference // even if thread is dead the RubyThread instance might stick around while the Java thread // instance already could have been garbage collected - let's return nil for dead meat : + // TODO getId has been deprecated in JDK 19, when JDK 21 is the target version use threadId() instead return javaThread == null ? context.nil : context.runtime.newFixnum(javaThread.getId()); } From aaa30ce01118704386f914342afa99551430c5c9 Mon Sep 17 00:00:00 2001 From: andsel Date: Thu, 21 Dec 2023 16:14:34 +0100 Subject: [PATCH 02/12] Suppressed warnings for 'this-escape' compiler error where the warning is a false positive --- .../src/main/java/org/logstash/common/SourceWithMetadata.java | 4 ++++ .../logstash/config/ir/expression/RegexValueExpression.java | 2 +- .../src/main/java/org/logstash/config/ir/graph/Edge.java | 4 ++++ .../src/main/java/org/logstash/plugins/inputs/Stdin.java | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/logstash-core/src/main/java/org/logstash/common/SourceWithMetadata.java b/logstash-core/src/main/java/org/logstash/common/SourceWithMetadata.java index 1063dfd5830..0448a8140ea 100644 --- a/logstash-core/src/main/java/org/logstash/common/SourceWithMetadata.java +++ b/logstash-core/src/main/java/org/logstash/common/SourceWithMetadata.java @@ -65,6 +65,7 @@ public String getText() { private static final Pattern emptyString = Pattern.compile("^\\s*$"); + @SuppressWarnings("this-escape") public SourceWithMetadata(String protocol, String id, Integer line, Integer column, String text, String metadata) throws IncompleteSourceWithMetadataException { this.protocol = protocol; this.id = id; @@ -73,6 +74,9 @@ public SourceWithMetadata(String protocol, String id, Integer line, Integer colu this.text = text; this.metadata = metadata; + // This is the reason why of the "this-escape" suppress warning, a method (attributes) is invoked on + // a non completely initialized object and that could generate some errors in accessing fields. + // This is not the case because the method is private and not overridable in sub classes. List badAttributes = this.attributes().stream().filter(a -> { if (a == null) return true; if (a instanceof String) { diff --git a/logstash-core/src/main/java/org/logstash/config/ir/expression/RegexValueExpression.java b/logstash-core/src/main/java/org/logstash/config/ir/expression/RegexValueExpression.java index 6c1437ab2ef..3dd7889fc5c 100644 --- a/logstash-core/src/main/java/org/logstash/config/ir/expression/RegexValueExpression.java +++ b/logstash-core/src/main/java/org/logstash/config/ir/expression/RegexValueExpression.java @@ -34,7 +34,7 @@ public RegexValueExpression(SourceWithMetadata meta, Object value) throws Invali throw new InvalidIRException("Regex value expressions can only take strings!"); } - this.regex = getSource(); + this.regex = (String) value; } @Override diff --git a/logstash-core/src/main/java/org/logstash/config/ir/graph/Edge.java b/logstash-core/src/main/java/org/logstash/config/ir/graph/Edge.java index 4d5c17c6308..f72e7891e98 100644 --- a/logstash-core/src/main/java/org/logstash/config/ir/graph/Edge.java +++ b/logstash-core/src/main/java/org/logstash/config/ir/graph/Edge.java @@ -33,6 +33,7 @@ public abstract class Edge implements SourceComponent { private Graph graph; + @SuppressWarnings("this-escape") protected Edge(Vertex from, Vertex to) throws InvalidIRException { this.from = from; this.to = to; @@ -41,6 +42,9 @@ protected Edge(Vertex from, Vertex to) throws InvalidIRException { throw new InvalidIRException("Cannot create a cyclic vertex! " + to); } + // This is the reason why of the "this-escape" suppress warning. The instance is passed to the method acceptsOutgoingEdge + // before the constructor completes, so could potentially reach some runtime errors due to fields not initialized. + // This is not the case because actually that method just does type check on reference. if (!this.from.acceptsOutgoingEdge(this)) { throw new Vertex.InvalidEdgeTypeException(String.format("Invalid outgoing edge %s for edge %s", this.from, this)); } diff --git a/logstash-core/src/main/java/org/logstash/plugins/inputs/Stdin.java b/logstash-core/src/main/java/org/logstash/plugins/inputs/Stdin.java index 5b2808a1919..017f36754b9 100644 --- a/logstash-core/src/main/java/org/logstash/plugins/inputs/Stdin.java +++ b/logstash-core/src/main/java/org/logstash/plugins/inputs/Stdin.java @@ -75,7 +75,10 @@ public Stdin(final String id, final Configuration configuration, final Context c this(id, configuration, context, new FileInputStream(FileDescriptor.in).getChannel()); } + @SuppressWarnings("this-escape") Stdin(final String id, final Configuration configuration, final Context context, FileChannel inputChannel) { + // This is the reason why of the "this-escape" suppress warning, but this is used just to grab the class + // for the logger. logger = context.getLogger(this); this.id = id; try { From 1a0aa5e89967b585845163ea721ec54b5ad86ed3 Mon Sep 17 00:00:00 2001 From: andsel Date: Thu, 21 Dec 2023 16:31:42 +0100 Subject: [PATCH 03/12] Moved URL constructor to URI.toURL --- build.gradle | 2 +- .../src/test/java/org/logstash/plugins/AliasRegistryTest.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index cc95ca83783..6fbe07535eb 100644 --- a/build.gradle +++ b/build.gradle @@ -750,7 +750,7 @@ class JDKDetails { url += "_${arch}" } println "Retrieving JDK from catalog..." - def catalogMetadataUrl = new URL(url) + def catalogMetadataUrl = URI.create(url).toURL() def catalogConnection = catalogMetadataUrl.openConnection() catalogConnection.requestMethod = 'GET' assert catalogConnection.responseCode == 200 diff --git a/logstash-core/src/test/java/org/logstash/plugins/AliasRegistryTest.java b/logstash-core/src/test/java/org/logstash/plugins/AliasRegistryTest.java index 4ad12ed0060..2387bbb7c7b 100644 --- a/logstash-core/src/test/java/org/logstash/plugins/AliasRegistryTest.java +++ b/logstash-core/src/test/java/org/logstash/plugins/AliasRegistryTest.java @@ -6,6 +6,7 @@ import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; +import java.net.URI; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Map; @@ -34,7 +35,7 @@ public void testProductionConfigAliasesGemsExists() throws IOException { for (AliasRegistry.PluginCoordinate alias : aliasesDefinitions.keySet()) { final String gemName = alias.fullName(); - URL url = new URL("https://rubygems.org/api/v1/gems/" + gemName +".json"); + URL url = URI.create("https://rubygems.org/api/v1/gems/" + gemName +".json").toURL(); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.setRequestProperty("Accept", "application/json"); From 93c50fcca15ca5d410bbb3fbe7e76c36478cd3dd Mon Sep 17 00:00:00 2001 From: andsel Date: Thu, 21 Dec 2023 17:00:59 +0100 Subject: [PATCH 04/12] Fixed warnings in tests --- .../java/org/logstash/ext/JrubyMemoryReadClientExtTest.java | 2 ++ .../test/java/org/logstash/log/TestingDeprecationPlugin.java | 1 + .../java/org/logstash/secret/store/SecretStoreFactoryTest.java | 1 + 3 files changed, 4 insertions(+) diff --git a/logstash-core/src/test/java/org/logstash/ext/JrubyMemoryReadClientExtTest.java b/logstash-core/src/test/java/org/logstash/ext/JrubyMemoryReadClientExtTest.java index 0af4dfdcd39..9b102ca8959 100644 --- a/logstash-core/src/test/java/org/logstash/ext/JrubyMemoryReadClientExtTest.java +++ b/logstash-core/src/test/java/org/logstash/ext/JrubyMemoryReadClientExtTest.java @@ -38,6 +38,7 @@ public final class JrubyMemoryReadClientExtTest extends RubyTestBase { @Test + @SuppressWarnings("deprecation") public void testInflightBatchesTracking() throws InterruptedException, IOException { final BlockingQueue queue = new ArrayBlockingQueue<>(10); @@ -47,6 +48,7 @@ public void testInflightBatchesTracking() throws InterruptedException, IOExcepti final QueueBatch batch = client.readBatch(); final RubyHash inflight = client.rubyGetInflightBatches(context); assertThat(inflight.size(), is(1)); + // TODO getId has been deprecated in JDK 19, when JDK 21 is the target version use threadId() instead assertThat(inflight.get(Thread.currentThread().getId()), is(batch)); client.closeBatch(batch); assertThat(client.rubyGetInflightBatches(context).size(), is(0)); diff --git a/logstash-core/src/test/java/org/logstash/log/TestingDeprecationPlugin.java b/logstash-core/src/test/java/org/logstash/log/TestingDeprecationPlugin.java index ee84b3b966d..cdaa85a9dfe 100644 --- a/logstash-core/src/test/java/org/logstash/log/TestingDeprecationPlugin.java +++ b/logstash-core/src/test/java/org/logstash/log/TestingDeprecationPlugin.java @@ -40,6 +40,7 @@ public class TestingDeprecationPlugin implements Codec { * @param configuration Logstash Configuration * @param context Logstash Context */ + @SuppressWarnings("this-escape") public TestingDeprecationPlugin(final Configuration configuration, final Context context) { deprecationLogger = context.getDeprecationLogger(this); } diff --git a/logstash-core/src/test/java/org/logstash/secret/store/SecretStoreFactoryTest.java b/logstash-core/src/test/java/org/logstash/secret/store/SecretStoreFactoryTest.java index ab9f6ea3c7b..9a6129375bc 100644 --- a/logstash-core/src/test/java/org/logstash/secret/store/SecretStoreFactoryTest.java +++ b/logstash-core/src/test/java/org/logstash/secret/store/SecretStoreFactoryTest.java @@ -157,6 +157,7 @@ public static class MemoryStore implements SecretStore { Map secrets = new HashMap(1); + @SuppressWarnings("this-escape") public MemoryStore() { persistSecret(LOGSTASH_MARKER, LOGSTASH_MARKER.getKey().getBytes(StandardCharsets.UTF_8)); } From be30b921371390f33acb6371242cd5a88b1412ab Mon Sep 17 00:00:00 2001 From: andsel Date: Thu, 15 Feb 2024 10:27:35 +0100 Subject: [PATCH 05/12] Apply suggestion from https://github.com/jruby/jruby/issues/8061#issuecomment-1933009986 --- lib/bootstrap/rspec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/bootstrap/rspec.rb b/lib/bootstrap/rspec.rb index 782455135ee..ac4c92ffc97 100755 --- a/lib/bootstrap/rspec.rb +++ b/lib/bootstrap/rspec.rb @@ -14,6 +14,7 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +java.util.LinkedHashSet.remove_method(:map) rescue nil require_relative "environment" LogStash::Bundler.setup!({:without => [:build]}) From 4458feca98d47cf937e9b9c735ad86fc580d765e Mon Sep 17 00:00:00 2001 From: andsel Date: Thu, 15 Feb 2024 10:30:26 +0100 Subject: [PATCH 06/12] Ghosted TODO as JTODO to pass SonarQube analysis --- .../main/java/org/logstash/execution/PipelineReporterExt.java | 2 +- .../main/java/org/logstash/execution/QueueReadClientBase.java | 4 ++-- .../org/logstash/instrument/monitors/HotThreadsMonitor.java | 2 +- logstash-core/src/main/java/org/logstash/util/UtilExt.java | 2 +- .../java/org/logstash/ext/JrubyMemoryReadClientExtTest.java | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/logstash-core/src/main/java/org/logstash/execution/PipelineReporterExt.java b/logstash-core/src/main/java/org/logstash/execution/PipelineReporterExt.java index abb8af28d9f..6ddc3eda5c3 100644 --- a/logstash-core/src/main/java/org/logstash/execution/PipelineReporterExt.java +++ b/logstash-core/src/main/java/org/logstash/execution/PipelineReporterExt.java @@ -174,7 +174,7 @@ private RubyArray workerStates(final ThreadContext context, final RubyHash batch IRubyObject batchSize = Optional.of((RubyThread) thread) .map(RubyThread::getNativeThread) - // TODO getId has been deprecated in JDK 19, when JDK 21 is the target version use threadId() instead + // JTODO getId has been deprecated in JDK 19, when JDK 21 is the target version use threadId() instead .map(Thread::getId) .map(id -> batchMap.op_aref(context, context.runtime.newFixnum(id))) .map(batch -> extractBatchSize(context, batch)) diff --git a/logstash-core/src/main/java/org/logstash/execution/QueueReadClientBase.java b/logstash-core/src/main/java/org/logstash/execution/QueueReadClientBase.java index 2de3fa7706b..535cd838a0e 100644 --- a/logstash-core/src/main/java/org/logstash/execution/QueueReadClientBase.java +++ b/logstash-core/src/main/java/org/logstash/execution/QueueReadClientBase.java @@ -131,7 +131,7 @@ public IRubyObject rubyReadBatch(final ThreadContext context) throws Interrupted @SuppressWarnings("deprecation") public void closeBatch(QueueBatch batch) throws IOException { batch.close(); - // TODO getId has been deprecated in JDK 19, when JDK 21 is the target version use threadId() instead + // JTODO getId has been deprecated in JDK 19, when JDK 21 is the target version use threadId() instead inflightBatches.remove(Thread.currentThread().getId()); } @@ -190,7 +190,7 @@ public void rubyAddOutputMetrics(final IRubyObject size) { @Override @SuppressWarnings("deprecation") public void startMetrics(QueueBatch batch) { - // TODO getId has been deprecated in JDK 19, when JDK 21 is the target version use threadId() instead + // JTODO getId has been deprecated in JDK 19, when JDK 21 is the target version use threadId() instead long threadId = Thread.currentThread().getId(); inflightBatches.put(threadId, batch); } diff --git a/logstash-core/src/main/java/org/logstash/instrument/monitors/HotThreadsMonitor.java b/logstash-core/src/main/java/org/logstash/instrument/monitors/HotThreadsMonitor.java index 86c662bff03..e16aed00d7e 100644 --- a/logstash-core/src/main/java/org/logstash/instrument/monitors/HotThreadsMonitor.java +++ b/logstash-core/src/main/java/org/logstash/instrument/monitors/HotThreadsMonitor.java @@ -165,7 +165,7 @@ public static List detect(Map options) { Map reports = new HashMap<>(); for (long threadId : threadMXBean.getAllThreadIds()) { - // TODO getId has been deprecated in JDK 19, when JDK 21 is the target version use threadId() instead + // JTODO getId has been deprecated in JDK 19, when JDK 21 is the target version use threadId() instead if (Thread.currentThread().getId() == threadId) { continue; } diff --git a/logstash-core/src/main/java/org/logstash/util/UtilExt.java b/logstash-core/src/main/java/org/logstash/util/UtilExt.java index 6a2b5352c7f..41b3825a4d0 100644 --- a/logstash-core/src/main/java/org/logstash/util/UtilExt.java +++ b/logstash-core/src/main/java/org/logstash/util/UtilExt.java @@ -42,7 +42,7 @@ public static IRubyObject get_thread_id(final ThreadContext context, IRubyObject final Thread javaThread = ((RubyThread) thread).getNativeThread(); // weak-reference // even if thread is dead the RubyThread instance might stick around while the Java thread // instance already could have been garbage collected - let's return nil for dead meat : - // TODO getId has been deprecated in JDK 19, when JDK 21 is the target version use threadId() instead + // JTODO getId has been deprecated in JDK 19, when JDK 21 is the target version use threadId() instead return javaThread == null ? context.nil : context.runtime.newFixnum(javaThread.getId()); } diff --git a/logstash-core/src/test/java/org/logstash/ext/JrubyMemoryReadClientExtTest.java b/logstash-core/src/test/java/org/logstash/ext/JrubyMemoryReadClientExtTest.java index 9b102ca8959..dff3c4845a3 100644 --- a/logstash-core/src/test/java/org/logstash/ext/JrubyMemoryReadClientExtTest.java +++ b/logstash-core/src/test/java/org/logstash/ext/JrubyMemoryReadClientExtTest.java @@ -48,7 +48,7 @@ public void testInflightBatchesTracking() throws InterruptedException, IOExcepti final QueueBatch batch = client.readBatch(); final RubyHash inflight = client.rubyGetInflightBatches(context); assertThat(inflight.size(), is(1)); - // TODO getId has been deprecated in JDK 19, when JDK 21 is the target version use threadId() instead + // JTODO getId has been deprecated in JDK 19, when JDK 21 is the target version use threadId() instead assertThat(inflight.get(Thread.currentThread().getId()), is(batch)); client.closeBatch(batch); assertThat(client.rubyGetInflightBatches(context).size(), is(0)); From b48bd298546bab45c85c97d8596055794aabda53 Mon Sep 17 00:00:00 2001 From: andsel Date: Thu, 15 Feb 2024 14:30:48 +0100 Subject: [PATCH 07/12] Added motivation of the remove_method(:map) --- lib/bootstrap/rspec.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/bootstrap/rspec.rb b/lib/bootstrap/rspec.rb index ac4c92ffc97..4a6d74693e3 100755 --- a/lib/bootstrap/rspec.rb +++ b/lib/bootstrap/rspec.rb @@ -14,6 +14,11 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. + +# The following line is needed because from starting from JDK 21 LinkedHashSet +# has a package private map method that JRuby bound as a usable method. +# It's mainly related to Gradle opening java.base module and this interfere with +# JRuby binding of methods. Full description at https://github.com/jruby/jruby/issues/8061#issuecomment-1908807511 java.util.LinkedHashSet.remove_method(:map) rescue nil require_relative "environment" From e089ae5d19f2d77302783b5ce568453522dd42cb Mon Sep 17 00:00:00 2001 From: andsel Date: Thu, 15 Feb 2024 16:48:21 +0100 Subject: [PATCH 08/12] Added new 'G1 Concurrect GC' MX bean --- logstash-core/lib/logstash/instrument/periodic_poller/jvm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logstash-core/lib/logstash/instrument/periodic_poller/jvm.rb b/logstash-core/lib/logstash/instrument/periodic_poller/jvm.rb index 13d4db7053f..7b347cb831c 100644 --- a/logstash-core/lib/logstash/instrument/periodic_poller/jvm.rb +++ b/logstash-core/lib/logstash/instrument/periodic_poller/jvm.rb @@ -36,7 +36,7 @@ module LogStash module Instrument module PeriodicPoller class JVM < Base class GarbageCollectorName YOUNG_GC_NAMES = Set.new(["Copy", "PS Scavenge", "ParNew", "G1 Young Generation", "scavenge", "GPGC New"]) - OLD_GC_NAMES = Set.new(["MarkSweepCompact", "PS MarkSweep", "ConcurrentMarkSweep", "G1 Old Generation", "global", "GPGC Old"]) + OLD_GC_NAMES = Set.new(["MarkSweepCompact", "PS MarkSweep", "ConcurrentMarkSweep", "G1 Old Generation", "G1 Concurrent GC", "global", "GPGC Old"]) YOUNG = :young OLD = :old From 3b520e2839fde8dfb8bad03fca468635403e3e1b Mon Sep 17 00:00:00 2001 From: andsel Date: Wed, 3 Apr 2024 10:05:47 +0200 Subject: [PATCH 09/12] Fixed description comment on the workaround like --- lib/bootstrap/rspec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/bootstrap/rspec.rb b/lib/bootstrap/rspec.rb index 4a6d74693e3..b957f900f6b 100755 --- a/lib/bootstrap/rspec.rb +++ b/lib/bootstrap/rspec.rb @@ -15,10 +15,11 @@ # specific language governing permissions and limitations # under the License. -# The following line is needed because from starting from JDK 21 LinkedHashSet +# The following line is a workaround needed because starting from JDK 21 LinkedHashSet # has a package private map method that JRuby bound as a usable method. # It's mainly related to Gradle opening java.base module and this interfere with # JRuby binding of methods. Full description at https://github.com/jruby/jruby/issues/8061#issuecomment-1908807511 +# Remove when Logstash bundle a JRuby version >= 9.4.6.0. java.util.LinkedHashSet.remove_method(:map) rescue nil require_relative "environment" From 1f5f73572d7ef2c140484c6b9e75dbb8886b08ef Mon Sep 17 00:00:00 2001 From: Andrea Selva Date: Wed, 3 Apr 2024 15:38:41 +0200 Subject: [PATCH 10/12] Remove workaround for JRuby #8061 --- lib/bootstrap/rspec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bootstrap/rspec.rb b/lib/bootstrap/rspec.rb index b957f900f6b..3baa04a0f05 100755 --- a/lib/bootstrap/rspec.rb +++ b/lib/bootstrap/rspec.rb @@ -20,7 +20,7 @@ # It's mainly related to Gradle opening java.base module and this interfere with # JRuby binding of methods. Full description at https://github.com/jruby/jruby/issues/8061#issuecomment-1908807511 # Remove when Logstash bundle a JRuby version >= 9.4.6.0. -java.util.LinkedHashSet.remove_method(:map) rescue nil +# java.util.LinkedHashSet.remove_method(:map) rescue nil require_relative "environment" LogStash::Bundler.setup!({:without => [:build]}) From 694a599852c3e3cbc69f2bcbc6d08e216bb520a1 Mon Sep 17 00:00:00 2001 From: Andrea Selva Date: Wed, 3 Apr 2024 16:07:41 +0200 Subject: [PATCH 11/12] Removed unusefull workaround Given that Logstash already ships with JRuby 9.4.6.0 which contains the fix https://github.com/jruby/jruby/issues/8061, the workaround to avoid the original bad param numbers can be removed. --- lib/bootstrap/rspec.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/bootstrap/rspec.rb b/lib/bootstrap/rspec.rb index 3baa04a0f05..521e6676bef 100755 --- a/lib/bootstrap/rspec.rb +++ b/lib/bootstrap/rspec.rb @@ -15,12 +15,6 @@ # specific language governing permissions and limitations # under the License. -# The following line is a workaround needed because starting from JDK 21 LinkedHashSet -# has a package private map method that JRuby bound as a usable method. -# It's mainly related to Gradle opening java.base module and this interfere with -# JRuby binding of methods. Full description at https://github.com/jruby/jruby/issues/8061#issuecomment-1908807511 -# Remove when Logstash bundle a JRuby version >= 9.4.6.0. -# java.util.LinkedHashSet.remove_method(:map) rescue nil require_relative "environment" LogStash::Bundler.setup!({:without => [:build]}) From f45aa3e080b329e171b026efeedeb51dec8c6f37 Mon Sep 17 00:00:00 2001 From: Andrea Selva Date: Wed, 3 Apr 2024 16:08:11 +0200 Subject: [PATCH 12/12] Removed space line --- lib/bootstrap/rspec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/bootstrap/rspec.rb b/lib/bootstrap/rspec.rb index 521e6676bef..782455135ee 100755 --- a/lib/bootstrap/rspec.rb +++ b/lib/bootstrap/rspec.rb @@ -15,7 +15,6 @@ # specific language governing permissions and limitations # under the License. - require_relative "environment" LogStash::Bundler.setup!({:without => [:build]}) require "logstash-core"