Add some additional null checks for shutdown, make sure requestURI is never null
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1660927 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/Dispatcher.java b/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/Dispatcher.java
index 07b68d3..8d73570 100644
--- a/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/Dispatcher.java
+++ b/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/Dispatcher.java
@@ -568,6 +568,10 @@
this.whiteboardService.sessionDestroyed(session, ids);
}
String requestURI = getRequestURI(req);
+ if ( requestURI == null )
+ {
+ requestURI = "";
+ }
// Determine which servlets we should forward the request to...
final ServletHandler servletHandler = this.handlerRegistry.getServletHander(requestURI);
@@ -641,6 +645,10 @@
}
// TODO remove path parameters...
String requestURI = decodePath(removeDotSegments(path));
+ if ( requestURI == null )
+ {
+ requestURI = "";
+ }
ServletHandler handler = this.handlerRegistry.getServletHander(requestURI);
if (handler == null)
diff --git a/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ContextHandler.java b/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ContextHandler.java
index d1461c6..15c344a 100644
--- a/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ContextHandler.java
+++ b/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ContextHandler.java
@@ -203,13 +203,23 @@
if ( holder != null )
{
holder.counter--;
- if ( holder.counter <= 0 )
+ if ( holder.counter == 0 )
{
this.perBundleContextMap.remove(key);
- final ServiceObjects<ServletContextHelper> so = bundle.getBundleContext().getServiceObjects(this.info.getServiceReference());
- if ( so != null )
+ if ( holder.servletContextHelper != null )
{
- so.ungetService(holder.servletContextHelper);
+ final ServiceObjects<ServletContextHelper> so = bundle.getBundleContext().getServiceObjects(this.info.getServiceReference());
+ if ( so != null )
+ {
+ try
+ {
+ so.ungetService(holder.servletContextHelper);
+ }
+ catch ( final IllegalArgumentException iae)
+ {
+ // this seems to be thrown sometimes on shutdown; we have to evaluate
+ }
+ }
}
}
}
diff --git a/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardHttpService.java b/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardHttpService.java
index 002213f..918ea9e 100644
--- a/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardHttpService.java
+++ b/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardHttpService.java
@@ -327,12 +327,16 @@
{
for(final Long contextId : contextIds)
{
- final ContextHandler handler = this.contextManager.getContextHandler(contextId);
- if ( handler != null )
+ // TODO - on shutdown context manager is already NULL which shouldn't be the case
+ if ( this.contextManager != null )
{
- final ExtServletContext context = handler.getServletContext(this.bundleContext.getBundle());
- new HttpSessionWrapper(contextId, session, context, true).invalidate();
- handler.ungetServletContext(this.bundleContext.getBundle());
+ final ContextHandler handler = this.contextManager.getContextHandler(contextId);
+ if ( handler != null )
+ {
+ final ExtServletContext context = handler.getServletContext(this.bundleContext.getBundle());
+ new HttpSessionWrapper(contextId, session, context, true).invalidate();
+ handler.ungetServletContext(this.bundleContext.getBundle());
+ }
}
}
}