Uploaded image for project: 'JBoss Web Server'
  1. JBoss Web Server
  2. JWS-139

ASF Bug 57645 – getContext("/") returns null: Correct a regression in the fix for 57190 that incorrectly required the path passed to ServletContext.getContext(String) to be an exact match to a path to an existing context.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • JWS 3.0.1 DR2
    • JWS 3.0.0 GA, JWS 3.0.1 DR1
    • tomcat8
    • None

    Description

      The getContext() method incorrectly returns null when requesting the ROOT context ("/"). The following fix resolves the issue:

      public ServletContext getContext(String uri) {

      // Validate the format of the specified argument
      if ((uri == null) || (!uri.startsWith("/")))
      return (null);

      Context child = null;
      try {
      // Look for an exact match
      Container host = context.getParent();
      child = (Context) host.findChild(uri);
      if ( (child == null) && "/".equals(uri) )

      { // fix child = (Context) host.findChild(""); // fix }

      // fix

      The root context was created via:

      Context context = embedded.addWebapp("", "/path/to/webapps/ROOT");

      https://bz.apache.org/bugzilla/show_bug.cgi?id=57645
      http://svn.apache.org/r1662178

      Attachments

        Activity

          People

            mbabacek1@redhat.com Michal Karm
            dknox_jira David Knox (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: