Jetty
  1. Jetty
  2. JETTY-151

ArrayIndexOutOfBoundsException from JSP file which is printing/writing long lines

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.0.1
    • Fix Version/s: 6.0.2, 6.1.0pre1
    • Component/s: None
    • Labels:
      None
    • Environment:
      Linux, Java build 1.6.0-beta2-b82
    • Number of attachments :
      1

      Description

      I'm getting these ArrayIndexOutOfBoundsExceptions from a legacy JSP I'm suddenly in charge of. It seems like the code is printing very long lines, and that isn't handled properly.

      (It might be worth pointing out that the writing/printing is actually performed inside an invoked java class on the supplied out (javax.servlet.jsp.JspWriter), and not from the actual jsp.)

      I don't quite get the "writeUnchecked()" method of ByteArrayOutputStream2, as the whole idea with the "write()" is to handle the "overflowing of the array" by increasing its size? If this was supposed to be handled by autoflushing, then I think that there is a discrepency between the size of JspWriterImpl's buffer (which is 8192 at the time), and the buf in ByteArrayOutputStream2, which is 3000.

      At the time of the AIOOB, ByteArrayOutputStream2's vars:
      buf's length: 3000
      count: 3001 (probably obviously!)

      and JspWriterImpl's has the following:
      autoFlush: true
      bufferSize: 8192
      cb's length: 8192
      nextChar: 335

      Sorry for not having a testcase yet, I wanted to send this before I left work today!
      (However I reckon that people with insight into this apparent optimization might spot the problem quickly?)

      java.lang.ArrayIndexOutOfBoundsException: 3000
      at org.mortbay.util.ByteArrayOutputStream2.writeUnchecked(ByteArrayOutputStream2.java:40)
      at org.mortbay.jetty.HttpGenerator$OutputWriter.write(HttpGenerator.java:1355)
      at java.io.PrintWriter.write(PrintWriter.java:354)
      at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:148)
      at org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:202)
      at net.marketaudit.services.util.DocTreeUtils.printDocTree(DocTreeUtils.java:305)
      at org.apache.jsp.TextQueryTestV3_005f01_jsp._jspService(org.apache.jsp.TextQueryTestV3_005f01_jsp:942)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:440)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:335)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:445)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:356)
      at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:226)
      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:627)
      at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:149)
      at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:123)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:141)
      at org.mortbay.jetty.Server.handle(Server.java:269)
      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:430)
      at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:687)
      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:492)
      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:199)
      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:339)
      at org.mortbay.jetty.nio.HttpChannelEndPoint.run(HttpChannelEndPoint.java:270)
      at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)

        Issue Links

          Activity

          No work has yet been logged on this issue.

            People

            • Assignee:
              Greg Wilkins
              Reporter:
              Endre Stølsvik
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: