Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

JavaFilterExampleTest.java fails due to ContextImpl argument count

Open
#21 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
java
Domain
backend

Research direction

Inspect src/test/java/org/logstashplugins/JavaFilterExampleTest.java, especially the ContextImpl construction in testJavaExampleFilter. Compile the test suite and confirm the constructor call matches the available ContextImpl signature; done means the test sources compile without the argument-count error.

Written by the indexing model from the issue text.

Description

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();
Dominant language
Java
Stars
19
Forks
39
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from logstash-plugins/logstash-filter-java_filter_example

All issues in logstash-plugins/logstash-filter-java_filter_example

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.