Uploaded image for project: 'Wink'
  1. Wink
  2. WINK-290

DeploymentConfiguration is not propertly initialized when the servlet doesn't create the RequestProcessor

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1.1
    • 1.1.1
    • Server
    • None
    • Patch Available

    Description

      Hi,

      I just bumped into this problem, seems the RestServlet doesn't initialize the DeploymentConfiguration properly and the servletContext and servletConfig are not set when the RequestProcessor is not created by the servlet.

      When I call context.getAttribute(ServletContext.class); from a userHandler the servletContext is null, it's also null if I call context.getAttribute(DeploymentConfiguration.class).getServletContext();

      Seems the servlet doesn't call getDeploymentConfiguration in some cases. To expose the bug I instanced an embedded jetty and overloaded the servlet, this is the code I'm using it:

      Server server = new Server(9009);
      Context contextHandler = new Context(server, "/api", Context.SESSIONS);
      
      contextHandler.addEventListener(new ContextLoaderListener());
      
              ServletHolder servletHolder = new ServletHolder(new RestServlet()
              {
                  @Override
                  public void init() throws ServletException
                  {
                      super.init();
                      System.err.println("SERVLET CONTEXT !!!!!!!! " + this.getServletContext());
                      System.err.println("CONFIGURATION SERVLET CONTEXT !!! "
                          + this.getRequestProcessor().getConfiguration().getServletContext());
                  }
              });
              contextHandler.addServlet(servletHolder, "/*");
      

      When the method init is called I get this output:

      SERVLET CONTEXT !!!!!!!! ServletContext@675926d1{/api,null}
      CONFIGURATION SERVLET CONTEXT !!! null
      

      I'm including a patch and test cases to solve this problem.

      Attachments

        1. WINK-290.patch
          5 kB
          David Calavera

        Activity

          People

            bluk Bryant Luk
            david.calavera David Calavera
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: