logstash-plugins / logstash-filter-date

Apache License 2.0
7 stars 43 forks source link

Test failure: org.logstash.Event seems to be missing. #116

Closed jordansissel closed 6 years ago

jordansissel commented 7 years ago
% LOGSTASH_BRANCH=6.0 ci/build.sh

org.logstash.filters.DateFilterTest > testUnixMillisLong FAILED
    java.lang.NoClassDefFoundError at DateFilterTest.java:194
        Caused by: java.lang.ClassNotFoundException at DateFilterTest.java:194

org.logstash.filters.DateFilterTest > testCancelledEvent FAILED
    java.lang.NoClassDefFoundError at DateFilterTest.java:163
        Caused by: java.lang.ClassNotFoundException at DateFilterTest.java:163

org.logstash.filters.DateFilterTest > testIsoStrings FAILED
    java.lang.NoClassDefFoundError at DateFilterTest.java:172
        Caused by: java.lang.ClassNotFoundException at DateFilterTest.java:172

org.logstash.filters.DateFilterTest > testTai64Strings FAILED
    java.lang.NoClassDefFoundError at DateFilterTest.java:172
        Caused by: java.lang.ClassNotFoundException at DateFilterTest.java:172

org.logstash.filters.DateFilterTest > testUnixLongs FAILED
    java.lang.NoClassDefFoundError at DateFilterTest.java:194
        Caused by: java.lang.ClassNotFoundException at DateFilterTest.java:194

org.logstash.filters.DateFilterTest > testUnixDouble FAILED
    java.lang.NoClassDefFoundError at DateFilterTest.java:201
        Caused by: java.lang.ClassNotFoundException at DateFilterTest.java:201

org.logstash.filters.DateFilterTest > testIsoStringsInterpolateTz FAILED
    java.lang.NoClassDefFoundError at DateFilterTest.java:179
        Caused by: java.lang.ClassNotFoundException at DateFilterTest.java:179

org.logstash.filters.DateFilterTest > testUnixInts FAILED
    java.lang.NoClassDefFoundError at DateFilterTest.java:187
        Caused by: java.lang.ClassNotFoundException at DateFilterTest.java:187

org.logstash.filters.DateFilterTest > testPatternStringsInterpolateTzNoYear FAILED
    java.lang.NoClassDefFoundError at DateFilterTest.java:179
        Caused by: java.lang.ClassNotFoundException at DateFilterTest.java:179

org.logstash.filters.DateFilterTest > testUnixStrings FAILED
    java.lang.NoClassDefFoundError at DateFilterTest.java:172
        Caused by: java.lang.ClassNotFoundException at DateFilterTest.java:172

968 tests completed, 10 failed
jordansissel commented 7 years ago
% sed -ne "$(grep "Caused by:" /tmp/x | fex :-1 | sed -e 's/$/p;/' | fmt)" src/test/java/org/logstash/filters/DateFilterTest.java | sort | uniq -c
     10         Event event = new Event();

Event class is not found at runtime, but at compile-time it is.

jordansissel commented 7 years ago
% rm Gemfile.lock gradle.properties; LOGSTASH_BRANCH=6.0 ci/build.sh
jordansissel commented 7 years ago

This works:

% rm Gemfile.lock gradle.properties; bundle install; bundle exec rake vendor; ./gradlew test

Because I think it targets Logstash 5.5.1 by accident.

this works when logstash source is v5.6.4

% rm Gemfile.lock gradle.properties; LOGSTASH_PATH=../logstash LOGSTASH_SOURCE=1 bundle install; bundle exec rake vendor; ./gradlew test
jakelandis commented 6 years ago

It looks like the actual class it can not find is :

org/jruby/RubyHash$VisitorWithState
java.lang.NoClassDefFoundError: org/jruby/RubyHash$VisitorWithState
    at org.logstash.Event.<init>(Event.java:46)

It appears that since Event object is compiled against JRuby 9k (6.x+) ,but this plugin has a compile time dependency against JRuby 1.7, so when trying to create a new Event it passes compile time checks just fine, but at runtime the JRuby transitive dependencies to Event effectively gets swapping out at runtime, and boom.

Bumping the dependency to JRuby 9k will fix the issue for the 6.x branch of code, and as long we aren't using any 9k should also work for the 5.x code.

In very brief testing compiling this plugin against JRuby 9k and running 5.6 (using JRuby 1.7) it worked...however, it is risky enough to warrant a major version bump in the plugin (and not including it in future versions 5.x versions). Also, I don't plan to pin since we are only releasing patch versions for 5.x and shouldn't include majors dependency bumps in patch releases.