[ 
https://issues.apache.org/jira/browse/CAMEL-12115?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16331818#comment-16331818
 ] 

ASF GitHub Bot commented on CAMEL-12115:
----------------------------------------

oscerd closed pull request #2166:  "CAMEL-12115:Camel-Consul: Upgrade to 1.0.0 
consul client"
URL: https://github.com/apache/camel/pull/2166
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 1486fe5e5c0..78ff5a1d94b 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
@@ -81,7 +81,7 @@ public Object lookupByName(String key) {
         // Substitute $ character in key
         key = key.replaceAll("\\$", "/");
         kvClient = consul.keyValueClient();
-        Optional<String> result = kvClient.getValueAsString(key);
+        java.util.Optional<String> result = kvClient.getValueAsString(key);
         if (result.isPresent()) {
             byte[] postDecodedValue = 
ConsulRegistryUtils.decodeBase64(result.get());
             return ConsulRegistryUtils.deserialize(postDecodedValue);
diff --git 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/cluster/ConsulClusterView.java
 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/cluster/ConsulClusterView.java
index 74d0b35e1e8..e54f9346882 100644
--- 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/cluster/ConsulClusterView.java
+++ 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/cluster/ConsulClusterView.java
@@ -70,8 +70,8 @@
 
         return Optional.ofNullable(
             keyValueClient.getSession(configuration.getRootPath())
-                .transform(ConsulClusterMember::new)
-                .orNull()
+                .map(ConsulClusterMember::new)
+                .orElse(null)
         );
     }
 
@@ -137,7 +137,7 @@ private boolean acquireLock() {
             String sid = sessionId.get();
 
             return (sid != null)
-                ? sessionClient.getSessionInfo(sid).transform(si -> 
keyValueClient.acquireLock(path, sid)).or(Boolean.FALSE)
+                ? sessionClient.getSessionInfo(sid).map(si -> 
keyValueClient.acquireLock(path, sid)).orElse(Boolean.FALSE)
                 : false;
         }
     }
@@ -250,7 +250,7 @@ public void 
onComplete(ConsulResponse<com.google.common.base.Optional<Value>> co
             if (isStarting() || isStarted()) {
                 com.google.common.base.Optional<Value> value = 
consulResponse.getResponse();
                 if (value.isPresent()) {
-                    com.google.common.base.Optional<String> sid = 
value.get().getSession();
+                    Optional<String> sid = value.get().getSession();
                     if (!sid.isPresent()) {
                         // If the key is not held by any session, try acquire a
                         // lock (become leader)
@@ -294,8 +294,7 @@ public void watch() {
                 // Watch for changes
                 keyValueClient.getValue(
                     path,
-                    
QueryOptions.blockSeconds(configuration.getSessionRefreshInterval(), 
index.get()).build(),
-                    this
+                    
QueryOptions.blockSeconds(configuration.getSessionRefreshInterval(), 
index.get()).build()
                 );
 
                 if (sessionId.get() != null) {
diff --git 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulEventConsumer.java
 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulEventConsumer.java
index 34327161b17..a3d1c57338e 100644
--- 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulEventConsumer.java
+++ 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulEventConsumer.java
@@ -18,6 +18,7 @@
 
 import java.math.BigInteger;
 import java.util.List;
+import java.util.Optional;
 
 import com.orbitz.consul.Consul;
 import com.orbitz.consul.EventClient;
@@ -98,8 +99,8 @@ private void onEvent(Event event) {
             if (event.getTagFilter().isPresent()) {
                 message.setHeader(ConsulConstants.CONSUL_TAG_FILTER, 
event.getTagFilter().get());
             }
-
-            message.setBody(event.getPayload().orNull());
+            
+            message.setBody(Optional.ofNullable(event.getPayload()));
 
             try {
                 getProcessor().process(exchange);
diff --git 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulKeyValueConsumer.java
 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulKeyValueConsumer.java
index 9e5b3eee0c1..2fc6354794b 100644
--- 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulKeyValueConsumer.java
+++ 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulKeyValueConsumer.java
@@ -85,7 +85,7 @@ protected void onValue(Value value) {
                 message.setHeader(ConsulConstants.CONSUL_SESSION, 
value.getSession().get());
             }
 
-            message.setBody(configuration.isValueAsString() ? 
value.getValueAsString().orNull() : value.getValue().orNull());
+            message.setBody(configuration.isValueAsString() ? 
value.getValueAsString().orElse(null) : value.getValue().orElse(null));
 
             try {
                 getProcessor().process(exchange);
@@ -104,7 +104,7 @@ protected void onValue(Value value) {
 
         @Override
         public void watch(KeyValueClient client) {
-            client.getValue(key, queryOptions(), this);
+            client.getValue(key, queryOptions());
         }
 
         @Override
diff --git 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulKeyValueProducer.java
 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulKeyValueProducer.java
index e74f8fe20ec..615f33e2c81 100644
--- 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulKeyValueProducer.java
+++ 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulKeyValueProducer.java
@@ -53,12 +53,12 @@ protected void getValue(Message message) throws Exception {
         if (asString) {
             result = getClient().getValueAsString(
                 getMandatoryHeader(message, ConsulConstants.CONSUL_KEY, 
getConfiguration().getKey(), String.class)
-            ).orNull();
+            ).orElse(null);
         } else {
             result = getClient().getValue(
                 getMandatoryHeader(message, ConsulConstants.CONSUL_KEY, 
getConfiguration().getKey(), String.class),
                 message.getHeader(ConsulConstants.CONSUL_OPTIONS, 
QueryOptions.BLANK, QueryOptions.class)
-            ).orNull();
+            ).orElse(null);
         }
 
         setBodyAndResult(message, result);
diff --git 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulSessionProducer.java
 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulSessionProducer.java
index 37315f04748..b0da064d7b7 100644
--- 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulSessionProducer.java
+++ 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulSessionProducer.java
@@ -72,7 +72,7 @@ protected void info(Message message) throws Exception {
                 getClient().getSessionInfo(
                     message.getMandatoryBody(String.class),
                     message.getHeader(ConsulConstants.CONSUL_DATACENTER, 
String.class)
-                ).orNull()
+                ).orElse(null)
             );
         } else {
             setBodyAndResult(
@@ -80,7 +80,7 @@ protected void info(Message message) throws Exception {
                 getClient().getSessionInfo(
                     sessionId,
                     message.getHeader(ConsulConstants.CONSUL_DATACENTER, 
String.class)
-                ).orNull()
+                ).orElse(null)
             );
         }
     }
diff --git 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/health/ConsulHealthCheckRepository.java
 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/health/ConsulHealthCheckRepository.java
index e7ca18a4ad6..96dd3c05b06 100644
--- 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/health/ConsulHealthCheckRepository.java
+++ 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/health/ConsulHealthCheckRepository.java
@@ -151,8 +151,8 @@ protected void doCall(HealthCheckResultBuilder builder, 
Map<String, Object> opti
                     builder.down();
                 }
 
-                builder.detail("consul.service.name", 
check.getServiceName().orNull());
-                builder.detail("consul.service.id", 
check.getServiceId().orNull());
+                builder.detail("consul.service.name", 
check.getServiceName().orElse(null));
+                builder.detail("consul.service.id", 
check.getServiceId().orElse(null));
                 builder.detail("consul.check.status", check.getStatus());
                 builder.detail("consul.check.id", check.getCheckId());
             }
diff --git 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/policy/ConsulRoutePolicy.java
 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/policy/ConsulRoutePolicy.java
index a18f42fbed8..a08e86f0369 100644
--- 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/policy/ConsulRoutePolicy.java
+++ 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/policy/ConsulRoutePolicy.java
@@ -323,7 +323,7 @@ public void onComplete(ConsulResponse<Optional<Value>> 
consulResponse) {
             if (isRunAllowed()) {
                 Optional<Value> value = consulResponse.getResponse();
                 if (value.isPresent()) {
-                    Optional<String> sid = value.get().getSession();
+                    java.util.Optional<String> sid = value.get().getSession();
                     if (sid.isPresent() && ObjectHelper.isNotEmpty(sid.get())) 
{
                         // If the key is not held by any session, try acquire a
                         // lock (become leader)
@@ -353,8 +353,7 @@ public void run() {
 
                 keyValueClient.getValue(
                     servicePath,
-                    QueryOptions.blockSeconds(ttl / 3, index.get()).build(),
-                    this
+                    QueryOptions.blockSeconds(ttl / 3, index.get()).build()
                 );
             }
         }
diff --git 
a/components/camel-consul/src/test/java/org/apache/camel/component/consul/ConsulKeyValueTest.java
 
b/components/camel-consul/src/test/java/org/apache/camel/component/consul/ConsulKeyValueTest.java
index 13d257615b8..d55d09b9fd2 100644
--- 
a/components/camel-consul/src/test/java/org/apache/camel/component/consul/ConsulKeyValueTest.java
+++ 
b/components/camel-consul/src/test/java/org/apache/camel/component/consul/ConsulKeyValueTest.java
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.consul;
 
-import com.google.common.base.Optional;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.consul.endpoint.ConsulKeyValueActions;
 import org.apache.camel.component.mock.MockEndpoint;
@@ -43,7 +42,7 @@ public void testKeyPut() throws Exception {
 
         mock.assertIsSatisfied();
 
-        Optional<String> keyVal = 
getConsul().keyValueClient().getValueAsString(key);
+        java.util.Optional<String> keyVal = 
getConsul().keyValueClient().getValueAsString(key);
 
         assertTrue(keyVal.isPresent());
         assertEquals(val, keyVal.get());
diff --git a/parent/pom.xml b/parent/pom.xml
index 1510a92cc4f..f561caf0dae 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -166,8 +166,8 @@
     <commons-text-version>1.2</commons-text-version>
     <commons-vfs2-version>2.0</commons-vfs2-version>
     <compress-lzf-version>1.0.4</compress-lzf-version>
-    <consul-client-version>0.16.3</consul-client-version>
-    <consul-client-bundle-version>0.16.2_1</consul-client-bundle-version>
+    <consul-client-version>1.0.0</consul-client-version>
+    <consul-client-bundle-version>1.0.0_1</consul-client-bundle-version>
     <cobertura-maven-plugin-version>2.7</cobertura-maven-plugin-version>
     <couchbase-client-version>1.4.13</couchbase-client-version>
     <couchbase-client-bundle-version>1.4.13_1</couchbase-client-bundle-version>


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Camel-Consul: Upgrade to 1.0.0 consul client
> --------------------------------------------
>
>                 Key: CAMEL-12115
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12115
>             Project: Camel
>          Issue Type: Task
>          Components: camel-consul
>            Reporter: Andrea Cosentino
>            Priority: Major
>             Fix For: 2.21.0
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to