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

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

oscerd closed pull request #2058: CAMEL-11944: Ensure HBaseConfiguration 
ClassLoader is set correctly
URL: https://github.com/apache/camel/pull/2058
 
 
   

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-hbase/src/main/java/org/apache/camel/component/hbase/HBaseComponent.java
 
b/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseComponent.java
index d690092702a..10ada082beb 100644
--- 
a/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseComponent.java
+++ 
b/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseComponent.java
@@ -19,6 +19,7 @@
 import java.util.Map;
 import java.util.concurrent.Executors;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.UriEndpointComponent;
 import org.apache.camel.spi.Metadata;
@@ -44,13 +45,15 @@ public HBaseComponent() {
         super(HBaseEndpoint.class);
     }
 
+    public HBaseComponent(CamelContext context) {
+        super(context, HBaseEndpoint.class);
+    }
+
     @Override
     protected void doStart() throws Exception {
         if (configuration == null) {
             configuration = HBaseConfiguration.create();
-        }
 
-        if (configuration.getClassLoader() == null) {
             ClassLoader applicationContextClassLoader = 
getCamelContext().getApplicationContextClassLoader();
             if (applicationContextClassLoader != null) {
                 configuration.setClassLoader(applicationContextClassLoader);
diff --git 
a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseComponentTest.java
 
b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseComponentTest.java
index 5cfed5e455b..697bdafa1d6 100644
--- 
a/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseComponentTest.java
+++ 
b/components/camel-hbase/src/test/java/org/apache/camel/component/hbase/HBaseComponentTest.java
@@ -34,7 +34,7 @@ public void 
testHBaseConfigurationClassLoaderSetToAppContextClassLoader() throws
         CamelContext camelContext = new DefaultCamelContext();
         camelContext.setApplicationContextClassLoader(expectedClassLoader);
 
-        HBaseComponent component = new HBaseComponent();
+        HBaseComponent component = new HBaseComponent(new 
DefaultCamelContext());
         component.doStart();
         component.doStop();
 
@@ -49,7 +49,7 @@ public void testHBaseConfigurationClassLoaderNotOverridden() 
throws Exception {
         Configuration configuration = HBaseConfiguration.create();
         configuration.setClassLoader(expectedClassLoader);
 
-        HBaseComponent component = new HBaseComponent();
+        HBaseComponent component = new HBaseComponent(new 
DefaultCamelContext());
         component.setConfiguration(configuration);
         try {
             component.doStart();
@@ -66,7 +66,7 @@ public void testHBaseConfigurationClassLoaderNotOverridden() 
throws Exception {
     public void testHBaseConfigurationClassLoaderSetToDefault() throws 
Exception {
         ClassLoader expectedClassLoader = 
HBaseConfiguration.class.getClassLoader();
 
-        HBaseComponent component = new HBaseComponent();
+        HBaseComponent component = new HBaseComponent(new 
DefaultCamelContext());
         component.doStart();
         component.doStop();
 


 

----------------------------------------------------------------
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]


> Ensure HBaseConfiguration ClassLoader is set correctly
> ------------------------------------------------------
>
>                 Key: CAMEL-11944
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11944
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-hbase
>    Affects Versions: 2.20.0
>            Reporter: James Netherton
>            Assignee: James Netherton
>            Priority: Minor
>
> Follow up on CAMEL-11692, my fix in HBaseComponent isn't quite right because 
> a call to HBaseConfiguration.create() automatically sets the ClassLoader on 
> the HBaseConfiguration object. Hence the conditional logic that follows is 
> always false.
> I think it'd be better to move [this 
> logic|https://github.com/apache/camel/blob/master/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseComponent.java#L53-L59]
>  into the preceding if block where the HBaseConfiguration is created. If 
> folks provide their own configuration, then it's up to them to make sure they 
> have set the ClassLoader correctly.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to