Skip to content
This repository was archived by the owner on Jul 31, 2022. It is now read-only.
This repository was archived by the owner on Jul 31, 2022. It is now read-only.

Duplicate contexts do not throw IllegalArgumentException [EXTERNAL ISSUE] #86

Closed

Description

@Katsute

Prerequisites

If all checks are not passed then the issue will be closed

  • I have checked that no other similar issue already exists

Operating System: Operating system name and version
Windows 10

Release Version: Release version or branch where the issue occurred
03.05.06

Issue

Explain your issue. Add any screenshots here
Duplicate contexts do not throw IllegalArgumentException.
Issue is caused by HttpServer; this is not a SimpleHttpServer issue.

Expected Behavior

Explain what was supposed to happen
Duplicate contexts should throw IllegalArgumentException.

Steps To Reproduce

Explain how and/or when the error occurred
Use createContext on same context using HttpServer.

Activity

  1. added
    bugSomething isn't working as expected
    on Aug 10, 2020
  2. added 2 commits that reference this issue on Aug 27, 2020
    16b5abe
    226f8c6
  3. Katsute commented on Aug 27, 2020

    @Katsute
    MemberAuthor

    Multiple tests have been run against the #create method in the sun http server library; but the illargs exception is only thrown for specific contexts, not all. This is a dependency issue and can not be resolved by SimpleHttpServer

  4. pinned this issue on Aug 28, 2020
  5. locked as off topic and limited conversation to collaborators on Aug 30, 2020
  6. unpinned this issue on Sep 20, 2020
  7. Katsute commented on Sep 29, 2020

    @Katsute
    MemberAuthor

    According to the source code an IllegalArgumentException is never thrown for duplicate contexts. The documentation on this method is invalid.

    sun.net.httpserver.ServerImpl

    ...
        public synchronized HttpContextImpl createContext (String path, HttpHandler handler) {
            if (handler == null || path == null) {
                throw new NullPointerException ("null handler, or path parameter");
            }
            HttpContextImpl context = new HttpContextImpl (protocol, path, handler, this);
            contexts.add (context);
            logger.log (Level.DEBUG, "context created: " + path);
            return context;
        }
    ...

    sun.net.httpserver.HttpContextImpl

    ...
        HttpContextImpl (String protocol, String path, HttpHandler cb, ServerImpl server) {
            if (path == null || protocol == null || path.length() < 1 || path.charAt(0) != '/') {
                throw new IllegalArgumentException ("Illegal value for path or protocol");
            }
            this.protocol = protocol.toLowerCase();
            this.path = path;
            if (!this.protocol.equals ("http") && !this.protocol.equals ("https")) {
                throw new IllegalArgumentException ("Illegal value for protocol");
            }
            this.handler = cb;
            this.server = server;
            authfilter = new AuthFilter(null);
            sfilters.add (authfilter);
        }
    ...
  8. pinned this issue on Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working as expecteddroppedThis is not being worked on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions