Struts 2
  1. Struts 2
  2. WW-3348

IndexOutOfBoundsException in ValueStackDataSource

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Not a Problem
    • Affects Version/s: 2.1.8
    • Fix Version/s: 2.3.18
    • Component/s: Plugin - JasperReports
    • Labels:
      None
    • Environment:

      WinXP, Tomcat

      Description

      Scenario:

      • Jasper report with 4 subreports.
      • Subreports content is provided from org.apache.struts2.views.jasperreports.ValueStackDataSource

      Exception
      java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
      is thrown from org.apache.struts2.views.jasperreports.ValueStackDataSource:
      public boolean next() throws JRException {
      if (firstTimeThrough)

      { firstTimeThrough = false; } else { valueStack.pop(); <== throws exception }
      . . .
      }

      Exception is thrown if the last row from subreport fits the current page and a new page is started. Thus the exception is data dependent.

      The following workaround works nicely:
      public boolean next() throws JRException {
      if (firstTimeThrough) { firstTimeThrough = false; }

      else {
      if (valueStack.size() > 0)

      { valueStack.pop(); }

      }
      . . .
      }

      Please test and implement in the next release.

      The following does not work (main report is generated partially, stops on empty valueStack condition):
      public boolean next() throws JRException {
      if (firstTimeThrough)

      { firstTimeThrough = false; }

      else {
      if (valueStack.size() == 0)

      { return false; }

      valueStack.pop();
      }
      . . .
      }

        Activity

          People

          • Assignee:
            Unassigned
            Reporter:
            Mark Gorokhov
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development