You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/12/13 18:05:01 UTC

[camel-k-runtime] 04/04: fix https://github.com/apache/camel-k/issues/1119: removing unneeded wrapper for reply processor

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

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git

commit 5fd7e2f4f59e740c98a899872b09ffcf8dc91da7
Author: Nicola Ferraro <ni...@gmail.com>
AuthorDate: Fri Dec 13 17:55:26 2019 +0100

    fix https://github.com/apache/camel-k/issues/1119: removing unneeded wrapper for reply processor
---
 .../camel/component/knative/KnativeEndpoint.java   |  5 +-
 .../component/knative/KnativeReplyProcessor.java   | 53 ----------------------
 2 files changed, 4 insertions(+), 54 deletions(-)

diff --git a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java
index 37f936b..b27b3bb 100644
--- a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java
+++ b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java
@@ -92,7 +92,10 @@ public class KnativeEndpoint extends DefaultEndpoint {
     public Consumer createConsumer(Processor processor) throws Exception {
         final KnativeEnvironment.KnativeServiceDefinition service = lookupServiceDefinition(Knative.EndpointKind.source);
         final Processor ceProcessor = cloudEvent.consumer(this, service);
-        final Processor replyProcessor = new KnativeReplyProcessor(this, service, cloudEvent, configuration.isReplyWithCloudEvent());
+        Processor replyProcessor = null;
+        if (configuration.isReplyWithCloudEvent()) {
+            replyProcessor = cloudEvent.producer(this, service);
+        }
         final Processor pipeline = Pipeline.newInstance(getCamelContext(), ceProcessor, processor, replyProcessor);
         final Consumer consumer = getComponent().getTransport().createConsumer(this, createTransportConfiguration(), service, pipeline);
 
diff --git a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeReplyProcessor.java b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeReplyProcessor.java
deleted file mode 100644
index 30bc548..0000000
--- a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeReplyProcessor.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.knative;
-
-import org.apache.camel.AsyncCallback;
-import org.apache.camel.Exchange;
-import org.apache.camel.component.knative.ce.CloudEventProcessor;
-import org.apache.camel.component.knative.spi.KnativeEnvironment;
-import org.apache.camel.support.processor.DelegateAsyncProcessor;
-
-/**
- * The KnativeReplyProcessor handles the processing of replies returned by the consumer.
- */
-public class KnativeReplyProcessor extends DelegateAsyncProcessor {
-
-    private final boolean cloudEventEnabled;
-
-    private final CloudEventProcessor cloudEventProcessor;
-
-    public KnativeReplyProcessor(KnativeEndpoint endpoint, KnativeEnvironment.KnativeServiceDefinition service, CloudEventProcessor cloudEventProcessor,
-                                 boolean cloudEventEnabled) {
-        super(cloudEventEnabled ? cloudEventProcessor.producer(endpoint, service) : null);
-
-        this.cloudEventEnabled = cloudEventEnabled;
-        this.cloudEventProcessor = cloudEventProcessor;
-    }
-
-    @Override
-    public boolean process(Exchange exchange, AsyncCallback callback) {
-        if (cloudEventEnabled) {
-            // Delegate to CloudEvent processor
-            return processor.process(exchange, callback);
-        }
-
-        callback.done(true);
-        return true;
-    }
-
-}