This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch exchange-factory in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/exchange-factory by this push: new b18bbcf CAMEL-16222: PooledExchangeFactory experiment b18bbcf is described below commit b18bbcf852e86db6a1467f76a60178a65b5a4bd1 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu Feb 18 20:54:42 2021 +0100 CAMEL-16222: PooledExchangeFactory experiment --- .../jgroups/CamelJGroupsReceiverTest.java | 58 ---------------------- .../camel/impl/engine/PooledExchangeFactory.java | 5 +- 2 files changed, 4 insertions(+), 59 deletions(-) diff --git a/components/camel-jgroups/src/test/java/org/apache/camel/component/jgroups/CamelJGroupsReceiverTest.java b/components/camel-jgroups/src/test/java/org/apache/camel/component/jgroups/CamelJGroupsReceiverTest.java deleted file mode 100644 index b81c436..0000000 --- a/components/camel-jgroups/src/test/java/org/apache/camel/component/jgroups/CamelJGroupsReceiverTest.java +++ /dev/null @@ -1,58 +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.jgroups; - -import org.apache.camel.Processor; -import org.jgroups.Message; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.ArgumentMatchers; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.BDDMockito.willThrow; - -@ExtendWith(MockitoExtension.class) -public class CamelJGroupsReceiverTest { - - // Fixtures - - @InjectMocks - CamelJGroupsReceiver receiver; - - @Mock - JGroupsEndpoint jGroupsEndpoint; - - @Mock - Processor processor; - - // Tests - - @Test - public void shouldHandleProcessingException() throws Exception { - // Given - willThrow(Exception.class).given(processor).process(ArgumentMatchers.isNull()); - Message message = new Message(null, "someMessage"); - message.setSrc(null); - // When - assertThrows(JGroupsException.class, - () -> receiver.receive(message)); - } - -} diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java index c70a591..e1d45fa 100644 --- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java +++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java @@ -118,8 +118,11 @@ public class PooledExchangeFactory extends ServiceSupport if (statisticsEnabled) { acquired.incrementAndGet(); } + // the exchange is reused but update the created to now + ExtendedExchange ee = exchange.adapt(ExtendedExchange.class); + ee.setCreated(System.currentTimeMillis()); // need to mark this exchange from the given endpoint - exchange.adapt(ExtendedExchange.class).setFromEndpoint(fromEndpoint); + ee.setFromEndpoint(fromEndpoint); } if (autoRelease) { // add on completion which will return the exchange when done