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 2020/12/21 12:13:31 UTC

[camel-karaf] branch master updated: CAMEL-13443: camel-test-blueprint use DOM factory from camel-support which is secured out of the box. Polished

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-karaf.git


The following commit(s) were added to refs/heads/master by this push:
     new ccbb134  CAMEL-13443: camel-test-blueprint use DOM factory from camel-support which is secured out of the box. Polished
ccbb134 is described below

commit ccbb1348356903c78b8cd8b795c4ad09b852641c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Dec 21 13:08:52 2020 +0100

    CAMEL-13443: camel-test-blueprint use DOM factory from camel-support which is secured out of the box. Polished
---
 .../org/apache/camel/blueprint/CamelBlueprintHelper.java    |  5 ++---
 .../camel/test/blueprint/CamelBlueprintTestSupport.java     | 13 ++++++-------
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/components/camel-blueprint-main/src/main/java/org/apache/camel/blueprint/CamelBlueprintHelper.java b/components/camel-blueprint-main/src/main/java/org/apache/camel/blueprint/CamelBlueprintHelper.java
index a716201..eebba97 100644
--- a/components/camel-blueprint-main/src/main/java/org/apache/camel/blueprint/CamelBlueprintHelper.java
+++ b/components/camel-blueprint-main/src/main/java/org/apache/camel/blueprint/CamelBlueprintHelper.java
@@ -265,7 +265,6 @@ public final class CamelBlueprintHelper {
                         config.update(props);
                     }
                 }
-
             }
         }
     }
@@ -283,7 +282,7 @@ public final class CamelBlueprintHelper {
     }
 
     public static <T> T getOsgiService(BundleContext bundleContext, Class<T> type, String filter, long timeout) {
-        ServiceTracker<T, T> tracker = null;
+        ServiceTracker<T, T> tracker;
         try {
             String flt;
             if (filter != null) {
@@ -581,7 +580,7 @@ public final class CamelBlueprintHelper {
             IOHelper.close(is, fos);
         }
 
-        BundleDescriptor answer = null;
+        BundleDescriptor answer;
         FileInputStream fis = null;
         JarInputStream jis = null;
         try {
diff --git a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
index fd56e92..7c35a87 100644
--- a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
+++ b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.test.blueprint;
 
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
@@ -34,9 +36,6 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -47,6 +46,7 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.blueprint.CamelBlueprintHelper;
 import org.apache.camel.component.properties.PropertiesComponent;
 import org.apache.camel.model.ModelCamelContext;
+import org.apache.camel.support.builder.xml.XMLConverterHelper;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.KeyValueHolder;
@@ -164,7 +164,7 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
         // - ManagedServiceUpdate is scheduled in felix.cm
         // - org.apache.felix.cm.impl.ConfigurationImpl.setDynamicBundleLocation() is called
         // - CM_LOCATION_CHANGED event is fired
-        // - if BP was alredy created, it's <cm:property-placeholder> receives the event and
+        // - if BP was already created, it's <cm:property-placeholder> receives the event and
         // - org.apache.aries.blueprint.compendium.cm.CmPropertyPlaceholder.updated() is called,
         //   but no BP reload occurs
         // we will however wait for BP container of the test bundle to become CREATED for the first time
@@ -283,8 +283,7 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
      */
     protected boolean expectBlueprintContainerReloadOnConfigAdminUpdate() {
         boolean expectedReload = false;
-        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-        dbf.setNamespaceAware(true);
+        DocumentBuilderFactory dbf = new XMLConverterHelper().createDocumentBuilderFactory();
         try {
             // cm-1.0 doesn't define update-strategy attribute
             Set<String> cmNamesaces = new HashSet<>(Arrays.asList(
@@ -498,7 +497,7 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
     
     @Override
     protected CamelContext createCamelContext() throws Exception {
-        CamelContext answer = null;
+        CamelContext answer;
         Long timeout = getCamelContextCreationTimeout();
         if (timeout == null) {
             answer = CamelBlueprintHelper.getOsgiService(bundleContext, CamelContext.class);