Skip to content

Json Formatter in 1.1.3 giving Array Out of Bounds exception #476

Closed

Description

@joshughes

When I run a test with a Before Hook, I am getting an Array out of Bounds exception.

java.lang.ArrayIndexOutOfBoundsException: -1
    at java.util.ArrayList.get(ArrayList.java:324)
    at gherkin.formatter.JSONFormatter.getFeatureElement(JSONFormatter.java:199)
    at gherkin.formatter.JSONFormatter.addHook(JSONFormatter.java:156)
    at gherkin.formatter.JSONFormatter.before(JSONFormatter.java:147)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

The same feature and hook worked with Cucumber JVM 1.1.1 and Cucumber JVM 1.1.2

When I remove the json format from the scenario, the scenario runs.

Activity

  1. aslakhellesoy commented on Mar 11, 2013

    @aslakhellesoy
    Contributor

    I suspect this is a regression introduced by ba049aa. Can you create a test that reproduces this?

  2. joshughes commented on Mar 11, 2013

    @joshughes
    Author

    I will try to create a test tonight.

    I noticed that the commit you mentioned seemed to go into 1.1.2 which I can run without any issue. So I was thinking it was probably one of the commits in 1.1.3 that caused the regression....

    #426

    SInce this specifically dealt with the json formater I suspect it is the problem. If I do not use the json formater then the tests run fine and the html report looks good.

    Thanks

  3. joshughes commented on Mar 11, 2013

    @joshughes
    Author

    The test has been adjusted to show the issue in this PR

    #478

  4. joshughes commented on Mar 12, 2013

    @joshughes
    Author

    The JSONFormmater has no element to add the Before Hook to... since the senario has not beed added yet.

    Moving format(formatter)

    Before Move

    @Override
        public void run(Formatter formatter, Reporter reporter, Runtime runtime) {
            runtime.buildBackendWorlds(reporter);
    
            runtime.runBeforeHooks(reporter, tagsAndInheritedTags());
    
            runBackground(formatter, reporter, runtime);
            format(formatter);
            runSteps(formatter, reporter, runtime);
    
            runtime.runAfterHooks(reporter, tagsAndInheritedTags());
            runtime.disposeBackendWorlds();
        }
    

    After Move

    @Override
        public void run(Formatter formatter, Reporter reporter, Runtime runtime) {
            runtime.buildBackendWorlds(reporter);
             format(formatter);
            runtime.runBeforeHooks(reporter, tagsAndInheritedTags());
    
            runBackground(formatter, reporter, runtime);
    
            runSteps(formatter, reporter, runtime);
    
            runtime.runAfterHooks(reporter, tagsAndInheritedTags());
            runtime.disposeBackendWorlds();
        }
    

    in CucumberScenario.java.

    This fixes the issue with the JSONFormatter but causes issue in the JUnit Reporter.

    So it looks like one of the two will need to be updated to fix the issue.

  5. aslakhellesoy commented on Mar 16, 2013

    @aslakhellesoy
    Contributor

    This issue seems related to #447

  6. gphilipp commented on Apr 17, 2013

    @gphilipp
    Contributor

    I think we have the same issue at our place, @aslakhellesoy : does this PR fix the bug ?

  7. MatthiasFraass commented on Jun 6, 2013

    @MatthiasFraass

    I had to make a SNAPSHOT-build of cucumber-jvm/gherkin in order to fix our builds. But as we're using the Maven-Release-Plugin, which forbids making releases with SNAPSHOT-dependencies, we can't do legal releases anymore.

    When will this bugfix go into a release?

  8. aslakhellesoy commented on Jun 8, 2013

    @aslakhellesoy
    Contributor

    This might be related to cucumber/gherkin#252 as well.

  9. aslakhellesoy commented on Sep 12, 2013

    @aslakhellesoy
    Contributor

    Isn't this fixed in 1.1.4 and/or 1.1.5-SNAPSHOT?

  10. brasmusson commented on Sep 12, 2013

    @brasmusson
    Contributor

    Yes, it is fixed in 1.1.4 (which is showed by the merge of #478).

  11. lock commented on Oct 25, 2018

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  12. locked as resolved and limited conversation to collaborators on Oct 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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