Repository: camel
Updated Branches:
  refs/heads/master 3a9292317 -> 9675bed97


CAMEL-11794: Remove commons-codec and commons-land deps from the Consul
component

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8217db37
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8217db37
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8217db37

Branch: refs/heads/master
Commit: 8217db37a8c7e553eef7362a3aa7fd1b25c29f64
Parents: a1f25b5
Author: Peter Palaga <ppal...@redhat.com>
Authored: Wed Sep 20 15:28:36 2017 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Wed Sep 20 17:17:58 2017 +0200

----------------------------------------------------------------------
 components/camel-consul/pom.xml                 | 10 -------
 .../camel/component/consul/ConsulRegistry.java  | 30 ++++++++++++++------
 2 files changed, 22 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8217db37/components/camel-consul/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-consul/pom.xml b/components/camel-consul/pom.xml
index 2bee481..914e751 100644
--- a/components/camel-consul/pom.xml
+++ b/components/camel-consul/pom.xml
@@ -101,16 +101,6 @@
       <version>${hamcrest-version}</version>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.apache.directory.studio</groupId>
-      <artifactId>org.apache.commons.lang</artifactId>
-      <version>2.6</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.directory.studio</groupId>
-      <artifactId>org.apache.commons.codec</artifactId>
-      <version>1.8</version>
-    </dependency>
   </dependencies>
 
 

http://git-wip-us.apache.org/repos/asf/camel/blob/8217db37/components/camel-consul/src/main/java/org/apache/camel/component/consul/ConsulRegistry.java
----------------------------------------------------------------------
diff --git 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/ConsulRegistry.java
 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/ConsulRegistry.java
index cd968c2..1486fe5 100644
--- 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/ConsulRegistry.java
+++ 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/ConsulRegistry.java
@@ -16,7 +16,14 @@
  */
 package org.apache.camel.component.consul;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.io.Serializable;
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -35,8 +42,6 @@ import com.orbitz.consul.model.session.SessionCreatedResponse;
 
 import org.apache.camel.NoSuchBeanException;
 import org.apache.camel.spi.Registry;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.lang.SerializationUtils;
 
 /**
  * Apache Camel Plug-in for Consul Registry (Objects stored under kv/key as 
well
@@ -258,7 +263,7 @@ public class ConsulRegistry implements Registry {
          * @return a decoded data as a byte array
          */
         static byte[] decodeBase64(final String base64String) {
-            return Base64.decodeBase64(base64String);
+            return 
Base64.getDecoder().decode(base64String.getBytes(StandardCharsets.ISO_8859_1));
         }
 
         /**
@@ -268,8 +273,8 @@ public class ConsulRegistry implements Registry {
          * @return an encoded data as a {@link String}
          */
         static String encodeBase64(final byte[] binaryData) {
-            final byte[] encoded = Base64.encodeBase64(binaryData);
-            return new String(encoded);
+            final byte[] encoded = Base64.getEncoder().encode(binaryData);
+            return new String(encoded, StandardCharsets.ISO_8859_1);
         }
 
         /**
@@ -279,7 +284,11 @@ public class ConsulRegistry implements Registry {
          * @return an {@link Object} deserialized from the given byte array
          */
         static Object deserialize(byte[] bytes) {
-            return SerializationUtils.deserialize(bytes);
+            try (ObjectInputStream in = new ObjectInputStream(new 
ByteArrayInputStream(bytes))) {
+                return in.readObject();
+            } catch (IOException | ClassNotFoundException e) {
+                throw new RuntimeException(e);
+            }
         }
 
         /**
@@ -289,7 +298,7 @@ public class ConsulRegistry implements Registry {
          * @return a deep clone
          */
         static Object clone(Serializable object) {
-            return SerializationUtils.clone(object);
+            return deserialize(serialize(object));
         }
 
         /**
@@ -298,7 +307,12 @@ public class ConsulRegistry implements Registry {
          * @return the serialized object as a byte array
          */
         static byte[] serialize(Serializable serializable) {
-            return SerializationUtils.serialize(serializable);
+            try (ByteArrayOutputStream baos = new ByteArrayOutputStream(512); 
ObjectOutputStream out = new ObjectOutputStream(baos)) {
+                out.writeObject(serializable);
+                return baos.toByteArray();
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
         }
     }
 

Reply via email to