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

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

Closed
1 task done
Katsute opened this issue Aug 10, 2020 · 2 comments
Closed
1 task done
Labels
bug Something isn't working as expected dropped This is not being worked on

Comments

@Katsute
Copy link
Member

Katsute commented Aug 10, 2020

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.

@Katsute Katsute added the bug Something isn't working as expected label Aug 10, 2020
Katsute added a commit that referenced this issue Aug 27, 2020
This is an issue with sun http server, not simplehttpserver
@Katsute
Copy link
Member Author

Katsute commented Aug 27, 2020

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

@Katsute Katsute added the dropped This is not being worked on label Aug 27, 2020
@Katsute Katsute reopened this Aug 28, 2020
@Katsute Katsute pinned this issue Aug 28, 2020
@Katsute Katsute mentioned this issue Aug 28, 2020
6 tasks
@Ktt-Development Ktt-Development locked as off-topic and limited conversation to collaborators Aug 30, 2020
@Katsute Katsute unpinned this issue Sep 20, 2020
@Katsute
Copy link
Member Author

Katsute commented Sep 29, 2020

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);
    }
...

@Katsute Katsute closed this as completed Sep 29, 2020
@Katsute Katsute pinned this issue Sep 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working as expected dropped This is not being worked on
Projects
None yet
Development

No branches or pull requests

1 participant