Uploaded image for project: 'Velocity'
  1. Velocity
  2. VELOCITY-383

Non thread-safe Template object can cause NPE under heavy concurrent load

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 1.4
    • 1.5
    • Engine
    • None
    • Operating System: Windows XP
      Platform: PC
    • 35331

    Description

      During load testing the server, with 50 concurrent users, the
      VelocityViewServlet would throw a null pointer exception about 3% of the time.
      97% of the time, the page would serve normally.

      Below is the trace:
      java.lang.NullPointerException
      at org.apache.velocity.runtime.parser.node.ASTDirective.init
      (ASTDirective.java:94)
      at org.apache.velocity.runtime.parser.node.SimpleNode.init
      (SimpleNode.java:201)
      at org.apache.velocity.Template.initDocument(Template.java:199)
      at org.apache.velocity.Template.process(Template.java:124)
      at
      org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource
      (ResourceManagerImpl.java:423)
      at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource
      (ResourceManagerImpl.java:341)
      at org.apache.velocity.runtime.RuntimeInstance.getTemplate
      (RuntimeInstance.java:831)
      at org.apache.velocity.runtime.RuntimeInstance.getTemplate
      (RuntimeInstance.java:813)
      at org.apache.velocity.runtime.RuntimeSingleton.getTemplate
      (RuntimeSingleton.java:285)
      at
      org.apache.velocity.tools.view.servlet.VelocityViewServlet.getTemplate
      (VelocityViewServlet.java:540)
      at
      org.apache.velocity.tools.view.servlet.VelocityViewServlet.handleRequest
      (VelocityViewServlet.java:475)
      at org.apache.velocity.tools.view.servlet.VelocityViewServlet.doRequest
      (VelocityViewServlet.java:407)
      at org.apache.velocity.tools.view.servlet.VelocityViewServlet.doPost
      (VelocityViewServlet.java:383)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
      (ApplicationFilterChain.java:237)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter
      (ApplicationFilterChain.java:157)
      at org.apache.catalina.core.ApplicationDispatcher.invoke
      (ApplicationDispatcher.java:674)
      at org.apache.catalina.core.ApplicationDispatcher.doInclude
      (ApplicationDispatcher.java:576)
      at org.apache.catalina.core.ApplicationDispatcher.include
      (ApplicationDispatcher.java:501)
      at org.apache.velocity.tools.view.ImportSupport.acquireString
      (ImportSupport.java:140)
      at org.apache.velocity.tools.struts.TilesTool.doInsert
      (TilesTool.java:476)
      at org.apache.velocity.tools.struts.TilesTool.doInsert
      (TilesTool.java:419)
      at org.apache.velocity.tools.struts.TilesTool.processUrl
      (TilesTool.java:398)
      at org.apache.velocity.tools.struts.TilesTool.processAsDefinitionOrURL
      (TilesTool.java:357)
      at org.apache.velocity.tools.struts.TilesTool.processObjectValue
      (TilesTool.java:305)
      at org.apache.velocity.tools.struts.TilesTool.get(TilesTool.java:135)
      at sun.reflect.GeneratedMethodAccessor136.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.apache.velocity.runtime.parser.node.GetExecutor.execute
      (GetExecutor.java:65)
      at
      org.apache.velocity.util.introspection.UberspectImpl$VelGetterImpl.invoke
      (UberspectImpl.java:302)
      at org.apache.velocity.runtime.parser.node.ASTIdentifier.execute
      (ASTIdentifier.java:157)
      at org.apache.velocity.runtime.parser.node.ASTReference.execute
      (ASTReference.java:175)
      at org.apache.velocity.runtime.parser.node.ASTReference.render
      (ASTReference.java:220)
      at org.apache.velocity.runtime.parser.node.SimpleNode.render
      (SimpleNode.java:230)
      at org.apache.velocity.Template.merge(Template.java:256)
      at
      org.apache.velocity.tools.view.servlet.VelocityViewServlet.mergeTemplate
      (VelocityViewServlet.java:592)
      at org.apache.velocity.tools.view.servlet.VelocityViewServlet.doRequest
      (VelocityViewServlet.java:417)
      at org.apache.velocity.tools.view.servlet.VelocityViewServlet.doPost
      (VelocityViewServlet.java:383)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
      (ApplicationFilterChain.java:237)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter
      (ApplicationFilterChain.java:157)
      at org.apache.catalina.core.ApplicationDispatcher.invoke
      (ApplicationDispatcher.java:674)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest
      (ApplicationDispatcher.java:465)
      at org.apache.catalina.core.ApplicationDispatcher.doForward
      (ApplicationDispatcher.java:400)
      at org.apache.catalina.core.ApplicationDispatcher.forward
      (ApplicationDispatcher.java:303)
      at org.apache.struts.action.RequestProcessor.doForward
      (RequestProcessor.java:1063)
      at org.apache.struts.tiles.TilesRequestProcessor.doForward
      (TilesRequestProcessor.java:263)
      at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition
      (TilesRequestProcessor.java:239)
      at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig
      (TilesRequestProcessor.java:302)
      at org.apache.struts.action.RequestProcessor.process
      (RequestProcessor.java:229)
      at org.apache.struts.action.ActionServlet.process
      (ActionServlet.java:1194)
      at org.apache.struts.action.ActionServlet.doPost
      (ActionServlet.java:432)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
      (ApplicationFilterChain.java:237)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter
      (ApplicationFilterChain.java:157)
      at org.apache.catalina.core.StandardWrapperValve.invoke
      (StandardWrapperValve.java:214)
      at org.apache.catalina.core.StandardContextValve.invoke
      (StandardContextValve.java:178)
      at org.apache.catalina.core.StandardHostValve.invoke
      (StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke
      (ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke
      (StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service
      (CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process
      (Http11Processor.java:825)
      at
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnecti
      on(Http11Protocol.java:731)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket
      (PoolTcpEndpoint.java:526)
      at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt
      (LeaderFollowerWorkerThread.java:80)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run
      (ThreadPool.java:684)
      at java.lang.Thread.run(Unknown Source)

      Attachments

        1. Example.java
          2 kB
          Stu Belden

        Activity

          People

            henning Henning Schmiedehausen
            live216@yahoo.com Hans
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: