You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/01/22 14:56:37 UTC

[camel] branch master updated: CAMEL-13077: Fix polling return for empty OData ClientEntitySets (#2719)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 7ee9007  CAMEL-13077: Fix polling return for empty OData ClientEntitySets (#2719)
7ee9007 is described below

commit 7ee9007ac72054dde06340f5dc45bba2464c98ee
Author: phantomjinx <p....@phantomjinx.co.uk>
AuthorDate: Tue Jan 22 14:56:26 2019 +0000

    CAMEL-13077: Fix polling return for empty OData ClientEntitySets (#2719)
    
    * ApiConsumerHelper does not recognise ClientEntitySets and thus defaults
      to return a constant 1. This means that the scheduling polling is never
      concluded to be idle and the backoffXXX consumer properties do not work.
    
    * If the ClientEntitySet is empty then return 0 to allow for backoffXXX
      properties to correctly handle the scheduling of the polling.
---
 .../org/apache/camel/component/olingo4/Olingo4Consumer.java   | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Consumer.java b/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Consumer.java
index afcb20d..8763fd8 100644
--- a/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Consumer.java
+++ b/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Consumer.java
@@ -26,6 +26,7 @@ import org.apache.camel.component.olingo4.api.Olingo4ResponseHandler;
 import org.apache.camel.component.olingo4.internal.Olingo4ApiName;
 import org.apache.camel.support.component.AbstractApiConsumer;
 import org.apache.camel.support.component.ApiConsumerHelper;
+import org.apache.olingo.client.api.domain.ClientEntitySet;
 
 /**
  * The Olingo4 consumer.
@@ -82,7 +83,15 @@ public class Olingo4Consumer extends AbstractApiConsumer<Olingo4ApiName, Olingo4
                 throw error[0];
             }
 
-            return ApiConsumerHelper.getResultsProcessed(this, result[0], isSplitResult());
+            //
+            // Allow consumer idle properties to properly handle an empty polling response
+            //
+            if (result[0] instanceof ClientEntitySet && (((ClientEntitySet) result[0]).getEntities().isEmpty())) {
+                return 0;
+            } else {
+                int processed = ApiConsumerHelper.getResultsProcessed(this, result[0], isSplitResult());
+                return processed;
+            }
 
         } catch (Throwable t) {
             throw RuntimeCamelException.wrapRuntimeCamelException(t);