You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2016/06/10 12:56:56 UTC
camel git commit: CAMEL-10043: Camel-Jaxb: objectFactory is never
checked. This leads to performance degradation.
Repository: camel
Updated Branches:
refs/heads/master 2331f7c7f -> 014520ca1
CAMEL-10043: Camel-Jaxb: objectFactory is never checked. This leads to performance degradation.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/014520ca
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/014520ca
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/014520ca
Branch: refs/heads/master
Commit: 014520ca1f9f50e7cf24d07374b7f5821f543572
Parents: 2331f7c
Author: Andrea Cosentino <an...@gmail.com>
Authored: Fri Jun 10 14:52:57 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Fri Jun 10 14:52:57 2016 +0200
----------------------------------------------------------------------
.../converter/jaxb/FallbackTypeConverter.java | 18 ++++++++++++------
.../jaxb/CamelJaxbFallbackConverterTest.java | 3 ++-
2 files changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/014520ca/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/FallbackTypeConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/FallbackTypeConverter.java b/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/FallbackTypeConverter.java
index 23e9f54..0ca881a 100644
--- a/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/FallbackTypeConverter.java
+++ b/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/FallbackTypeConverter.java
@@ -70,7 +70,7 @@ public class FallbackTypeConverter extends ServiceSupport implements TypeConvert
private final StaxConverter staxConverter = new StaxConverter();
private TypeConverter parentTypeConverter;
private boolean prettyPrint = true;
- private boolean objectFactory = true;
+ private boolean objectFactory = false;
private CamelContext camelContext;
public boolean isPrettyPrint() {
@@ -154,10 +154,12 @@ public class FallbackTypeConverter extends ServiceSupport implements TypeConvert
if (hasXmlRootElement(value.getClass())) {
return marshall(type, exchange, value, null);
}
- CamelContext context = exchange != null ? exchange.getContext() : camelContext;
- Method objectFactoryMethod = JaxbHelper.getJaxbElementFactoryMethod(context, value.getClass());
- if (objectFactoryMethod != null) {
- return marshall(type, exchange, value, objectFactoryMethod);
+ if (isObjectFactory()) {
+ CamelContext context = exchange != null ? exchange.getContext() : camelContext;
+ Method objectFactoryMethod = JaxbHelper.getJaxbElementFactoryMethod(context, value.getClass());
+ if (objectFactoryMethod != null) {
+ return marshall(type, exchange, value, objectFactoryMethod);
+ }
}
}
} catch (Exception e) {
@@ -211,7 +213,11 @@ public class FallbackTypeConverter extends ServiceSupport implements TypeConvert
}
protected <T> boolean isJaxbType(Class<T> type) {
- return hasXmlRootElement(type) || JaxbHelper.getJaxbElementFactoryMethod(camelContext, type) != null;
+ if (isObjectFactory()) {
+ return hasXmlRootElement(type) || JaxbHelper.getJaxbElementFactoryMethod(camelContext, type) != null;
+ } else {
+ return hasXmlRootElement(type);
+ }
}
private <T> T castJaxbType(Object o, Class<T> type) {
http://git-wip-us.apache.org/repos/asf/camel/blob/014520ca/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbFallbackConverterTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbFallbackConverterTest.java b/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbFallbackConverterTest.java
index c4559b3..2d31403 100644
--- a/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbFallbackConverterTest.java
+++ b/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbFallbackConverterTest.java
@@ -22,6 +22,7 @@ import java.io.InputStream;
import org.apache.camel.Exchange;
import org.apache.camel.TypeConversionException;
import org.apache.camel.TypeConverter;
+import org.apache.camel.converter.jaxb.FallbackTypeConverter;
import org.apache.camel.converter.jaxb.message.Message;
import org.apache.camel.example.Bar;
import org.apache.camel.example.Foo;
@@ -124,7 +125,7 @@ public class CamelJaxbFallbackConverterTest extends CamelTestSupport {
TypeConverter converter = context.getTypeConverter();
String marshalled = converter.convertTo(String.class, in);
Message out = converter.convertTo(Message.class, marshalled);
- assertEquals(in, out);
+ assertNotEquals(in, out);
}
}