Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 322670 - Inconsistent context view in DefaultHandler vs. ContextHandlerCollection
Summary: Inconsistent context view in DefaultHandler vs. ContextHandlerCollection
Status: CLOSED WONTFIX
Alias: None
Product: Jetty
Classification: RT
Component: server (show other bugs)
Version: 7.1.4   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: 7.1.x   Edit
Assignee: Greg Wilkins CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-13 12:04 EDT by Gunnar Wagenknecht CLA
Modified: 2011-09-20 15:52 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gunnar Wagenknecht CLA 2010-08-13 12:04:28 EDT
I created a Jetty configuration with a custom ContextHandler (UrlToApplicationHandler). This handler waits for the first hit. If the hit arrives it lazily initializes the real application delegates to this. There can be multiple such handlers (for different URLs) all delegating to the same application.

Initially the stack looks like this:
org.eclipse.jetty.server.Server
 +-HandlerCollection 
    +-ContextHandlerCollection
    |  +-UrlToApplicationHandler [applicationId=myApp, url=http://localhost/test/v1]
    |     +-UrlToApplicationHandler$LazyInitializingHotSwapDelegator
    |  +-UrlToApplicationHandler [applicationId=myApp, url=http://localhost/test]
    |     +-UrlToApplicationHandler$LazyInitializingHotSwapDelegator
    +-DefaultHandler

If I now hit an unmatched URL (http://localhost/) the DefaultHandler triggers and lists both available UrlToApplicationHandler contexts.

DefaultHandler:
/test/v1 @ localhost:80 ---> UrlToApplicationHandler [applicationId=myApp, url=http://localhost/test/v1]
/test @ localhost:80 ---> UrlToApplicationHandler [applicationId=myApp, url=http://localhost/test]


If I then hit an actual context URL the application is initialized lazily and put into the stack (all implemented by my LazyInitializingHotSwapDelegator which is a HotSwapHandler). 

The stack now looks like this:
org.eclipse.jetty.server.Server
 +-HandlerCollection 
    +-ContextHandlerCollection
    |  +-UrlToApplicationHandler [applicationId=myApp, url=http://localhost/test/v1]
    |     +-UrlToApplicationHandler$LazyInitializingHotSwapDelegator
    |       +-MyApplicationHandler [applicationId=myApp]
    |  +-UrlToApplicationHandler [applicationId=myApp, url=http://localhost/test]
    |     +-UrlToApplicationHandler$LazyInitializingHotSwapDelegator
    +-DefaultHandler


If I now hit the DefaultHandler it displays _three_ contexts available.

DefaultHandler:
/test/v1 @ localhost:80 ---> UrlToApplicationHandler [applicationId=myApp, url=http://localhost/test/v1]
/test @ localhost:80 ---> UrlToApplicationHandler [applicationId=myApp, url=http://localhost/test]
/ ---> MyApplicationHandler /,null

However, the MyApplicationHandler actually is not reachable because it's never handled by the ContextHandlerCollection (which is the intended behavior).

I'm wondering if DefaultHandler should have the same view as ContextHandlerCollection?
Comment 1 Greg Wilkins CLA 2010-08-16 08:37:06 EDT
Gunnar,

It is probably a good idea for the default servlet to print the handler tree itself, with any URLs that is can work out.

I've changed this to be an enhancement request and we will see if we can get time for it.... happy for code contributions also.
Comment 2 Greg Wilkins CLA 2011-09-06 00:59:31 EDT
Gunnar,

sorry for long delay.  Also I've changed my mind on this one.  The DefaultHandler just lists all Contexts know to the server.  It can't know if they are actually reachable as there are an infinite number of ways handlers can direct requests to contexts and ContextHandlerCollection is just one way (ok it is the default and most common way).

So I'm going to leave it as is.... but feel free to try to convince me otherwise.

cheers
Comment 3 Gunnar Wagenknecht CLA 2011-09-06 01:52:55 EDT
Not sure I will. I wrote a bunch of new handlers already so this is no longer an issue for me. ;)
Comment 4 Jesse McConnell CLA 2011-09-20 15:52:17 EDT
Resolved -> Closed