karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject karaf git commit: [KARAF-4964] Can't convert wrap URL used in shell commands
Date Thu, 09 Feb 2017 14:15:30 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-4.0.x a9dc711c6 -> 9795ed363


[KARAF-4964] Can't convert wrap URL used in shell commands

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/9795ed36
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/9795ed36
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/9795ed36

Branch: refs/heads/karaf-4.0.x
Commit: 9795ed363bfe1e12062ff09195e6eef43de96ae8
Parents: a9dc711
Author: Guillaume Nodet <gnodet@apache.org>
Authored: Thu Feb 9 15:13:44 2017 +0100
Committer: Guillaume Nodet <gnodet@apache.org>
Committed: Thu Feb 9 15:15:20 2017 +0100

----------------------------------------------------------------------
 .../karaf/shell/support/converter/DefaultConverter.java  | 11 +++++++++++
 1 file changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/9795ed36/shell/core/src/main/java/org/apache/karaf/shell/support/converter/DefaultConverter.java
----------------------------------------------------------------------
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/support/converter/DefaultConverter.java
b/shell/core/src/main/java/org/apache/karaf/shell/support/converter/DefaultConverter.java
index a4b402c..8492542 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/support/converter/DefaultConverter.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/support/converter/DefaultConverter.java
@@ -26,6 +26,7 @@ import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Dictionary;
@@ -200,11 +201,21 @@ public class DefaultConverter
             return Byte.valueOf(value);
         } else if (Enum.class.isAssignableFrom(toType)) {
             return Enum.valueOf((Class<Enum>) toType, value);
+        } else if (URI.class == toType) {
+            return createUri(value);
         } else {
             return createObject(value, toType);
         }
     }
 
+    /**
+     * Escape quote marks in order to allow bnd instructions that require it.
+     * <p>See jira issue KARAF-4964</p>
+     */
+    private static URI createUri(String value) throws Exception {
+        return URI.create(value.replaceAll("\"", "%22"));
+    }
+
     private static Object createObject(String value, Class type) throws Exception {
         if (type.isInterface() || Modifier.isAbstract(type.getModifiers())) {
             throw new Exception("Unable to convert value " + value + " to type " + type +
". Type " + type + " is an interface or an abstract class");


Mime
View raw message