FELIX-3028 Better handle some situations around clearing the bundle location of a configuration.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1143777 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java
index 52f3c0f..4d7fb9e 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java
@@ -149,9 +149,23 @@
         // check for configuration unbinding
         if ( request.getParameter( "unbind" ) != null )
         {
-            config.setBundleLocation( null );
-            response.setContentType("text/plain");
-            response.getWriter().print("true");
+            if ( config != null && config.getBundleLocation() != null )
+            {
+                config.setBundleLocation( null );
+
+                // workaround for Felix Config Admin 1.2.8 not clearing dynamic
+                // bundle location when clearing static bundle location. In
+                // this case we first set the static bundle location to the
+                // dynamic bundle location and then try to set both to null
+                if ( config.getBundleLocation() != null )
+                {
+                    config.setBundleLocation( "??invalid:bundle/location" );
+                    config.setBundleLocation( null );
+                }
+            }
+            response.setContentType( "application/json" );
+            response.setCharacterEncoding( "UTF-8" );
+            response.getWriter().print( "{ \"status\": true }" );
             return;
         }