JBehave
  1. JBehave
  2. JBEHAVE-353

Empty example table row values cause exception

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0.3
    • Component/s: Core
    • Labels:
      None
    • Environment:
      JBehave core 3.0.2
    • Number of attachments :
      0

      Description

      Given the following example table:

      C1 C2 C3

      JBehave fails to parse the table. It reports the following error:

      C1 C2 C3
      (FAILED)
      (java.lang.IndexOutOfBoundsException: Index: 0, Size: 0)

      The stack trace reads:

      Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
      at java.util.ArrayList.RangeCheck(ArrayList.java:547)
      at java.util.ArrayList.remove(ArrayList.java:387)
      at org.jbehave.core.model.ExamplesTable.columnsFor(ExamplesTable.java:76)
      at org.jbehave.core.model.ExamplesTable.parse(ExamplesTable.java:60)
      at org.jbehave.core.model.ExamplesTable.<init>(ExamplesTable.java:48)
      at org.jbehave.core.steps.ParameterConverters$ExamplesTableConverter.convertValue(ParameterConverters.java:328)
      at org.jbehave.core.steps.ParameterConverters.convert(ParameterConverters.java:68)
      at org.jbehave.core.steps.StepCreator.convertParameters(StepCreator.java:253)
      at org.jbehave.core.steps.StepCreator.access$1100(StepCreator.java:25)
      at org.jbehave.core.steps.StepCreator$5.parametriseStep(StepCreator.java:161)
      at org.jbehave.core.steps.StepCreator$5.perform(StepCreator.java:129)
      at org.jbehave.core.embedder.StoryRunner$FineSoFar.run(StoryRunner.java:189)
      at org.jbehave.core.embedder.StoryRunner.runSteps(StoryRunner.java:174)
      at org.jbehave.core.embedder.StoryRunner.runScenarioSteps(StoryRunner.java:162)
      at org.jbehave.core.embedder.StoryRunner.run(StoryRunner.java:84)
      at org.jbehave.core.embedder.StoryRunner.run(StoryRunner.java:62)
      at org.jbehave.core.embedder.Embedder.runStoriesAsPaths(Embedder.java:160)
      ... 43 more

      Parsing the table works fine if the last row contains at least one space in one of the cells. So

      C1 C2 C3
       

      and

      C1 C2 C3
       

      works fine.

        Activity

        Hide
        Frank Grimm added a comment -

        Sorry, the wiki markup messed up the bug report. The examples should read:

        This table cannot be parsed:

        |C1|C2|C3|
        ||||
        

        This table can be parsed:

        |C1|C2|C3|
        | |||
        

        and this table can be parsed too:

        |C1|C2|C3|
        ||||
        ||| |
        
        Show
        Frank Grimm added a comment - Sorry, the wiki markup messed up the bug report. The examples should read: This table cannot be parsed: |C1|C2|C3| |||| This table can be parsed: |C1|C2|C3| | ||| and this table can be parsed too: |C1|C2|C3| |||| ||| |
        Hide
        Mauro Talevi added a comment -

        So, how should we handle empty rows? Ignore them? Print warning?

        Show
        Mauro Talevi added a comment - So, how should we handle empty rows? Ignore them? Print warning?
        Mauro Talevi made changes -
        Field Original Value New Value
        Fix Version/s 3.0.3 [ 16775 ]
        Hide
        Frank Grimm added a comment -

        Well, in the use case that triggered this error, empty rows (except for the heading row of course) are totally fine. So, ignoring empty rows wouldn't work.

        Show
        Frank Grimm added a comment - Well, in the use case that triggered this error, empty rows (except for the heading row of course) are totally fine. So, ignoring empty rows wouldn't work.
        Mauro Talevi made changes -
        Summary Empty example table row causes exception Empty example table row values cause exception
        Mauro Talevi made changes -
        Assignee Mauro Talevi [ maurotalevi ]
        Hide
        Mauro Talevi added a comment -

        Empty table row values are now allowed.

        Show
        Mauro Talevi added a comment - Empty table row values are now allowed.
        Mauro Talevi made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Mauro Talevi
            Reporter:
            Frank Grimm
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: