New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
joshughes opened this Issue Mar 11, 2013 · 11 comments

Comments

Projects
None yet
5 participants
@joshughes
Contributor

joshughes commented Mar 11, 2013

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.

@aslakhellesoy

This comment has been minimized.

Contributor

aslakhellesoy commented Mar 11, 2013

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

@joshughes

This comment has been minimized.

Contributor

joshughes commented Mar 11, 2013

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

@joshughes

This comment has been minimized.

Contributor

joshughes commented Mar 11, 2013

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

#478

@joshughes

This comment has been minimized.

Contributor

joshughes commented Mar 12, 2013

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.

@aslakhellesoy

This comment has been minimized.

Contributor

aslakhellesoy commented Mar 16, 2013

This issue seems related to #447

@gphilipp

This comment has been minimized.

Contributor

gphilipp commented Apr 17, 2013

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

@MatthiasFraass

This comment has been minimized.

MatthiasFraass commented Jun 6, 2013

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?

@aslakhellesoy

This comment has been minimized.

Contributor

aslakhellesoy commented Jun 8, 2013

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

@aslakhellesoy

This comment has been minimized.

Contributor

aslakhellesoy commented Sep 12, 2013

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

@brasmusson

This comment has been minimized.

Contributor

brasmusson commented Sep 12, 2013

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

@lock

This comment has been minimized.

lock bot commented Oct 25, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.