camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lburgazz...@apache.org
Subject camel git commit: CAMEL-10709: camel-etcd: etcd stats endpoint fails because of a class cast exception
Date Mon, 16 Jan 2017 09:37:51 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.18.x 04549207f -> a35771d0d


CAMEL-10709: camel-etcd: etcd stats endpoint fails because of a class cast exception

(cherry picked from commit e5c45cc209d6103c92a241185bf389f4886d2c2a)


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

Branch: refs/heads/camel-2.18.x
Commit: a35771d0de891e7ecee5e38f2750c34913252c3f
Parents: 0454920
Author: lburgazzoli <lburgazzoli@gmail.com>
Authored: Mon Jan 16 09:59:16 2017 +0100
Committer: lburgazzoli <lburgazzoli@gmail.com>
Committed: Mon Jan 16 10:35:35 2017 +0100

----------------------------------------------------------------------
 .../component/etcd/AbstractEtcdConsumer.java    |  2 +-
 .../component/etcd/AbstractEtcdEndpoint.java    |  6 +++-
 .../etcd/AbstractEtcdPollingConsumer.java       | 24 ++--------------
 .../etcd/AbstractEtcdPollingEndpoint.java       |  6 +++-
 .../component/etcd/AbstractEtcdProducer.java    |  2 +-
 .../camel/component/etcd/EtcdEndpoint.java      | 29 ++++++++++++++++++++
 .../camel/component/etcd/EtcdStatsConsumer.java |  9 +++---
 .../camel/component/etcd/EtcdStatsEndpoint.java |  2 +-
 8 files changed, 48 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a35771d0/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdConsumer.java
b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdConsumer.java
index 84533d8..1a7fdde 100644
--- a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdConsumer.java
+++ b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdConsumer.java
@@ -50,7 +50,7 @@ public abstract class AbstractEtcdConsumer extends DefaultConsumer {
 
     protected EtcdClient getClient() throws Exception {
         if (client == null) {
-            client = ((AbstractEtcdEndpoint)getEndpoint()).createClient();
+            client = ((EtcdEndpoint)getEndpoint()).createClient();
         }
 
         return client;

http://git-wip-us.apache.org/repos/asf/camel/blob/a35771d0/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdEndpoint.java
b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdEndpoint.java
index 5eb095e..beb72ca 100644
--- a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdEndpoint.java
+++ b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdEndpoint.java
@@ -27,7 +27,7 @@ import org.apache.camel.spi.UriPath;
  * The camel etcd component allows you to work with <a href="https://coreos.com/etcd">Etcd</a>,
a distributed, A distributed, reliable key-value store.
  */
 @UriEndpoint(scheme = "etcd", title = "etcd", syntax = "etcd:namespace/path", consumerClass
= AbstractEtcdConsumer.class, label = "etcd")
-public abstract class AbstractEtcdEndpoint extends DefaultEndpoint {
+public abstract class AbstractEtcdEndpoint extends DefaultEndpoint implements EtcdEndpoint
{
 
     @UriPath(description = "The API namespace to use", enums = "keys,stats,watch")
     @Metadata(required = "true")
@@ -51,18 +51,22 @@ public abstract class AbstractEtcdEndpoint extends DefaultEndpoint {
         return true;
     }
 
+    @Override
     public EtcdConfiguration getConfiguration() {
         return this.configuration;
     }
 
+    @Override
     public EtcdNamespace getNamespace() {
         return this.namespace;
     }
 
+    @Override
     public String getPath() {
         return this.path;
     }
 
+    @Override
     public EtcdClient createClient() throws Exception {
         return configuration.createClient();
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/a35771d0/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdPollingConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdPollingConsumer.java
b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdPollingConsumer.java
index b069c63..bce2354 100644
--- a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdPollingConsumer.java
+++ b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdPollingConsumer.java
@@ -24,18 +24,10 @@ import org.apache.camel.impl.ScheduledPollConsumer;
  * The etcd consumer.
  */
 public abstract class AbstractEtcdPollingConsumer extends ScheduledPollConsumer {
-    private final EtcdConfiguration configuration;
-    private final EtcdNamespace namespace;
-    private final String path;
-
     private EtcdClient client;
 
-    protected AbstractEtcdPollingConsumer(AbstractEtcdPollingEndpoint endpoint, Processor
processor, EtcdConfiguration configuration, EtcdNamespace namespace, String path) {
+    protected AbstractEtcdPollingConsumer(AbstractEtcdPollingEndpoint endpoint, Processor
processor) {
         super(endpoint, processor);
-
-        this.configuration = configuration;
-        this.namespace = namespace;
-        this.path = path;
         this.client = null;
     }
 
@@ -50,21 +42,9 @@ public abstract class AbstractEtcdPollingConsumer extends ScheduledPollConsumer
 
     protected EtcdClient getClient() throws Exception {
         if (client == null) {
-            client = ((AbstractEtcdEndpoint)getEndpoint()).createClient();
+            client = ((EtcdEndpoint)getEndpoint()).createClient();
         }
 
         return client;
     }
-
-    protected EtcdConfiguration getConfiguration() {
-        return configuration;
-    }
-
-    protected EtcdNamespace getNamespace() {
-        return namespace;
-    }
-
-    protected String getPath() {
-        return this.path;
-    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/a35771d0/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdPollingEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdPollingEndpoint.java
b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdPollingEndpoint.java
index f00996e..af2572e 100644
--- a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdPollingEndpoint.java
+++ b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdPollingEndpoint.java
@@ -27,7 +27,7 @@ import org.apache.camel.spi.UriPath;
  * The camel etcd component allows you to work with <a href="https://coreos.com/etcd">Etcd</a>,
a distributed, A distributed, reliable key-value store.
  */
 @UriEndpoint(scheme = "etcd", title = "etcd", syntax = "etcd:namespace/path", consumerClass
= AbstractEtcdConsumer.class, label = "etcd")
-public abstract class AbstractEtcdPollingEndpoint extends DefaultPollingEndpoint {
+public abstract class AbstractEtcdPollingEndpoint extends DefaultPollingEndpoint implements
EtcdEndpoint {
 
     @UriPath(description = "The API namespace to use", enums = "keys,stats,watch")
     @Metadata(required = "true")
@@ -51,18 +51,22 @@ public abstract class AbstractEtcdPollingEndpoint extends DefaultPollingEndpoint
         return true;
     }
 
+    @Override
     public EtcdConfiguration getConfiguration() {
         return this.configuration;
     }
 
+    @Override
     public EtcdNamespace getNamespace() {
         return this.namespace;
     }
 
+    @Override
     public String getPath() {
         return this.path;
     }
 
+    @Override
     public EtcdClient createClient() throws Exception {
         return configuration.createClient();
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/a35771d0/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdProducer.java
b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdProducer.java
index 56d80e6..e93a67e 100644
--- a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdProducer.java
+++ b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/AbstractEtcdProducer.java
@@ -50,7 +50,7 @@ public abstract class AbstractEtcdProducer extends DefaultProducer {
 
     protected EtcdClient getClient() throws Exception {
         if (client == null) {
-            client = ((AbstractEtcdEndpoint)getEndpoint()).createClient();
+            client = ((EtcdEndpoint)getEndpoint()).createClient();
         }
 
         return client;

http://git-wip-us.apache.org/repos/asf/camel/blob/a35771d0/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdEndpoint.java
b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdEndpoint.java
new file mode 100644
index 0000000..b489e07
--- /dev/null
+++ b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdEndpoint.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.etcd;
+
+import mousio.etcd4j.EtcdClient;
+
+interface EtcdEndpoint {
+    EtcdConfiguration getConfiguration();
+
+    EtcdNamespace getNamespace();
+
+    String getPath();
+
+    EtcdClient createClient() throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a35771d0/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdStatsConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdStatsConsumer.java
b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdStatsConsumer.java
index 2959ebf..daf2952 100644
--- a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdStatsConsumer.java
+++ b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdStatsConsumer.java
@@ -20,9 +20,8 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 
 public class EtcdStatsConsumer extends AbstractEtcdPollingConsumer {
-
-    public EtcdStatsConsumer(EtcdStatsEndpoint endpoint, Processor processor, EtcdConfiguration
configuration, EtcdNamespace namespace, String path) {
-        super(endpoint, processor, configuration, namespace, path);
+    public EtcdStatsConsumer(EtcdStatsEndpoint endpoint, Processor processor) {
+        super(endpoint, processor);
     }
 
     @Override
@@ -37,8 +36,8 @@ public class EtcdStatsConsumer extends AbstractEtcdPollingConsumer {
 
         if (answer != null) {
             Exchange exchange = endpoint.createExchange();
-            exchange.getIn().setHeader(EtcdConstants.ETCD_NAMESPACE, getNamespace());
-            exchange.getIn().setHeader(EtcdConstants.ETCD_PATH, getPath());
+            exchange.getIn().setHeader(EtcdConstants.ETCD_NAMESPACE, endpoint.getNamespace());
+            exchange.getIn().setHeader(EtcdConstants.ETCD_PATH, endpoint.getPath());
             exchange.getIn().setBody(answer);
 
             getProcessor().process(exchange);

http://git-wip-us.apache.org/repos/asf/camel/blob/a35771d0/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdStatsEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdStatsEndpoint.java
b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdStatsEndpoint.java
index 7bb41c2..7e6a9ce 100644
--- a/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdStatsEndpoint.java
+++ b/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdStatsEndpoint.java
@@ -35,7 +35,7 @@ public class EtcdStatsEndpoint extends AbstractEtcdPollingEndpoint {
 
     @Override
     public Consumer createConsumer(Processor processor) throws Exception {
-        EtcdStatsConsumer consumer = new EtcdStatsConsumer(this, processor, getConfiguration(),
getNamespace(), getPath());
+        EtcdStatsConsumer consumer = new EtcdStatsConsumer(this, processor);
         configureConsumer(consumer);
         return consumer;
     }


Mime
View raw message