Bug 474250 - Fix servlet alias unregister to take into account /*
appending

Change-Id: Ia67dd6dbf61c7762c4116122e4697419be6bf81a
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java
index 2a23199..e95db54 100644
--- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java
@@ -1075,6 +1075,21 @@
 		Assert.fail();
 	}
 
+	public void test_unregister() throws Exception {
+		ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService();
+
+		Servlet servlet = new BaseServlet();
+		Filter filter = new TestFilter();
+
+		extendedHttpService.registerServlet("/s1", servlet, null, null);
+		extendedHttpService.registerFilter("/f1", filter, null, null);
+		extendedHttpService.registerResources("/r1", "/resources", null);
+
+		extendedHttpService.unregister("/s1");
+		extendedHttpService.unregisterFilter(filter);
+		extendedHttpService.unregister("/r1");
+	}
+
 	public void test_Registration11() throws Exception {
 		ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService();
 
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java
index d9e7024..d363b69 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java
@@ -691,14 +691,14 @@
 
 		// check the pattern against the original input
 		ContextController.checkPattern(alias);
-		String originalAlias = alias;
 
+		String pattern = alias;
 		// need to make sure exact matching aliases are converted to wildcard pattern matches
-		if (!alias.endsWith(Const.SLASH_STAR) && !alias.startsWith(Const.STAR_DOT) && !alias.contains(Const.SLASH_STAR_DOT)) {
-			if (alias.endsWith(Const.SLASH)) {
-				alias = alias + '*';
+		if (!pattern.endsWith(Const.SLASH_STAR) && !pattern.startsWith(Const.STAR_DOT) && !pattern.contains(Const.SLASH_STAR_DOT)) {
+			if (pattern.endsWith(Const.SLASH)) {
+				pattern = pattern + '*';
 			} else {
-				alias = alias + Const.SLASH_STAR;
+				pattern = pattern + Const.SLASH_STAR;
 			}
 		}
 
@@ -714,7 +714,7 @@
 				String fullAlias = getFullAlias(alias, factory);
 				HttpServiceObjectRegistration existing = legacyMappings.get(fullAlias);
 				if (existing != null) {
-					throw new PatternInUseException(originalAlias);
+					throw new PatternInUseException(alias);
 				}
 				String servletName = servlet.getClass().getName();
 				if ((initparams != null) && (initparams.get(Const.SERVLET_NAME) != null)) {
@@ -723,7 +723,7 @@
 
 				Dictionary<String, Object> props = new Hashtable<String, Object>();
 				props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_TARGET, targetFilter);
-				props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, alias);
+				props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, pattern);
 				props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, servletName);
 				props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, factory.getFilter());
 				props.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);