Skip to content

JavaFilterExampleTest.java fails due to ContextImpl argument count #21

@cameronkerrnz

Description

@cameronkerrnz

After managing to get tests to run with the PR in #20, I found that with Logstash 7.9 (not sure where this change actually came about), the tests fail to run:

> Task :compileTestJava FAILED
/workspaces/logstash-filter-java_filter_example/src/test/java/org/logstashplugins/JavaFilterExampleTest.java:22: error: constructor ContextImpl in class ContextImpl cannot be applied to given types;
        Context context = new ContextImpl(null);
                          ^
  required: DeadLetterQueueWriter,Metric
  found: <null>
  reason: actual and formal argument lists differ in length
1 error

The Javadocs (harvested from the Logstash source code) list only the following constructor:

ContextImpl(DeadLetterQueueWriter dlqWriter, Metric metric) 

The following diff resolves the issue, I guess either the DeadLetterWriter or the Metrics argument was added, perhaps at the time of GA.

[builder@e4261c43934e logstash-filter-java_filter_example]$ git diff
diff --git a/src/test/java/org/logstashplugins/JavaFilterExampleTest.java b/src/test/java/org/logstashplugins/JavaFilterExampleTest.java
index aee8e2a..99ce06d 100644
--- a/src/test/java/org/logstashplugins/JavaFilterExampleTest.java
+++ b/src/test/java/org/logstashplugins/JavaFilterExampleTest.java
@@ -19,7 +19,7 @@ public class JavaFilterExampleTest {
     public void testJavaExampleFilter() {
         String sourceField = "foo";
         Configuration config = new ConfigurationImpl(Collections.singletonMap("source", sourceField));
-        Context context = new ContextImpl(null);
+        Context context = new ContextImpl(null, null);
         JavaFilterExample filter = new JavaFilterExample("test-id", config, context);
 
         Event e = new org.logstash.Event();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions