Fix resource unregistration problem2


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1692158 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ResourceInfo.java b/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ResourceInfo.java
index 580cb8d..4a90a14 100644
--- a/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ResourceInfo.java
+++ b/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ResourceInfo.java
@@ -37,11 +37,14 @@
      */
     private final String prefix;
 
+    private final ServletInfo servletInfo;
+
     public ResourceInfo(final ServiceReference<Object> ref)
     {
         super(ref);
         this.patterns = getStringArrayProperty(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN);
         this.prefix = getStringProperty(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX);
+        this.servletInfo = new ServletInfo(this);
     }
 
     @Override
@@ -71,4 +74,9 @@
     {
         return patterns;
     }
+
+    public ServletInfo getServletInfo()
+    {
+        return this.servletInfo;
+    }
 }
diff --git a/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java b/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
index 98d64c1..1c59355 100644
--- a/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
+++ b/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
@@ -692,7 +692,7 @@
             }
             else if ( info instanceof ResourceInfo )
             {
-                final ServletInfo servletInfo = new ServletInfo((ResourceInfo)info);
+                final ServletInfo servletInfo = ((ResourceInfo)info).getServletInfo();
                 final ExtServletContext servletContext = handler.getServletContext(info.getServiceReference().getBundle());
                 if ( servletContext == null )
                 {
@@ -766,7 +766,7 @@
             }
             else if ( info instanceof ResourceInfo )
             {
-                handler.getRegistry().unregisterServlet(new ServletInfo((ResourceInfo)info), true);
+                handler.getRegistry().unregisterServlet(((ResourceInfo)info).getServletInfo(), true);
                 handler.ungetServletContext(info.getServiceReference().getBundle());
             }
 
diff --git a/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/WhiteboardServiceTracker.java b/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/WhiteboardServiceTracker.java
index e19b860..d673d23 100644
--- a/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/WhiteboardServiceTracker.java
+++ b/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/WhiteboardServiceTracker.java
@@ -109,7 +109,7 @@
 
     private void removed(final ServiceReference<T> ref)
     {
-        final WhiteboardServiceInfo<T> info = this.allInfos.get(ref.getProperty(Constants.SERVICE_ID));
+        final WhiteboardServiceInfo<T> info = this.allInfos.remove(ref.getProperty(Constants.SERVICE_ID));
         if ( info != null )
         {
             this.contextManager.removeWhiteboardService(info);