camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Hodgson <gary.s.hodg...@gmail.com>
Subject Re: Possible bug in camel-ignite Component
Date Tue, 06 Jun 2017 21:47:46 GMT
Thanks Claus,

PR: https://github.com/apache/camel/pull/1742
JIRA: https://issues.apache.org/jira/browse/CAMEL-11382

Regards,
Gary

On 6 June 2017 at 08:23, Claus Ibsen <claus.ibsen@gmail.com> wrote:

> Hi Gary
>
> Yeah a fix on github PR is much appreciated.
>
>
> On Mon, Jun 5, 2017 at 11:55 PM, Gary Hodgson <gary.s.hodgson@gmail.com>
> wrote:
> > Hi
> >
> > I was playing with the camel-ignite component and ran into what appears
> to
> > be a bug.
> >
> > Creating an IgniteComponent from configuration works fine, but when I try
> > and create one from an existing Ignite instance it throws an exception
> when
> > starting the component.  Looking at the code here
> > https://github.com/apache/camel/blob/master/components/
> camel-ignite/src/main/java/org/apache/camel/component/ignite/
> AbstractIgniteComponent.java#L77
> > it appears the lifecycleMode is ignored as it is only set to
> > COMPONENT_MANAGED and cannot be altered outside of the class.
> >
> > The following patch sets the lifecycleMode USER_MANAGED when an ignite
> > instance is set, which appears to resolve the problem.
> >
> >   diff --git
> > a/components/camel-ignite/src/main/java/org/apache/camel/
> component/ignite/AbstractIgniteComponent.java
> > b/components/camel-ignite/src/main/java/org/apache/camel/
> component/ignite/AbstractIgniteComponent.java
> >   index eaf6583..e9efc79 100644
> >   ---
> > a/components/camel-ignite/src/main/java/org/apache/camel/
> component/ignite/AbstractIgniteComponent.java
> >   +++
> > b/components/camel-ignite/src/main/java/org/apache/camel/
> component/ignite/AbstractIgniteComponent.java
> >   @@ -121,6 +108,7 @@
> >         */
> >        public void setIgnite(Ignite ignite) {
> >            this.ignite = ignite;
> >   +        lifecycleMode = IgniteLifecycleMode.USER_MANAGED;
> >        }
> >
> >        /**
> >
> > I can happily create a pull request via github if you like.
> >
> > Regards,
> > Gary
> >
> > ps. for reference, the following test reproduces the problem:
> >
> > diff --git
> > a/components/camel-ignite/src/test/java/org/apache/camel/
> component/ignite/IgniteCreationTest.java
> > b/components/camel-ignite/src/test/java/org/apache/camel/
> component/ignite/IgniteCreationTest.java
> > new file mode 100644
> > index 0000000..e0c41b0
> > --- /dev/null
> > +++
> > b/components/camel-ignite/src/test/java/org/apache/camel/
> component/ignite/IgniteCreationTest.java
> > @@ -0,0 +1,52 @@
> > +/**
> > + * 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.ignite;
> > +
> > +import static com.google.common.truth.Truth.assert_;
> > +import org.apache.camel.component.ignite.cache.IgniteCacheComponent;
> > +import org.apache.ignite.Ignite;
> > +import org.apache.ignite.Ignition;
> > +import org.apache.ignite.cache.CachePeekMode;
> > +import org.junit.Test;
> > +
> > +public class IgniteCreationTest extends AbstractIgniteTest {
> > +
> > +    @Override
> > +    protected String getScheme() {
> > +        return "ignite-cache";
> > +    }
> > +
> > +    @Override
> > +    protected AbstractIgniteComponent createComponent() {
> > +        Ignite ignite = Ignition.start(createConfiguration());
> > +        return IgniteCacheComponent.fromIgnite(ignite);
> > +    }
> > +
> > +    @Test
> > +    public void testAddEntry() {
> > +
> >  template.requestBodyAndHeader("ignite-cache:testcache1?operation=PUT",
> > "1234", IgniteConstants.IGNITE_CACHE_KEY, "abcd");
> > +
> > +
> >  assert_().that(ignite().cache("testcache1").size(
> CachePeekMode.ALL)).isEqualTo(1);
> > +
> >  assert_().that(ignite().cache("testcache1").get("abcd")).
> isEqualTo("1234");
> > +    }
> > +
> > +    @Override
> > +    public boolean isCreateCamelContextPerClass() {
> > +        return true;
> > +    }
> > +
> > +}
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message