You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2013/09/16 05:42:16 UTC
[1/3] git commit: CAMEL-6754 Fixed the UnitUtilsTest error in
no-english locale with thanks to Alessandro
Updated Branches:
refs/heads/master b544ac298 -> 961413cca
CAMEL-6754 Fixed the UnitUtilsTest error in no-english locale with thanks to Alessandro
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a370257b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a370257b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a370257b
Branch: refs/heads/master
Commit: a370257be9b2ffa86ecf461d9bb29aec8ddabc0b
Parents: b544ac2
Author: Willem Jiang <ni...@apache.org>
Authored: Mon Sep 16 11:00:30 2013 +0800
Committer: Willem Jiang <ni...@apache.org>
Committed: Mon Sep 16 11:00:30 2013 +0800
----------------------------------------------------------------------
.../java/org/apache/camel/util/UnitUtilsTest.java | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/a370257b/camel-core/src/test/java/org/apache/camel/util/UnitUtilsTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/UnitUtilsTest.java b/camel-core/src/test/java/org/apache/camel/util/UnitUtilsTest.java
index e73d5cd..6e087b7 100644
--- a/camel-core/src/test/java/org/apache/camel/util/UnitUtilsTest.java
+++ b/camel-core/src/test/java/org/apache/camel/util/UnitUtilsTest.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.util;
+import java.text.DecimalFormatSymbols;
+
import junit.framework.TestCase;
import static org.apache.camel.util.UnitUtils.printUnitFromBytes;
@@ -23,14 +25,18 @@ import static org.apache.camel.util.UnitUtils.printUnitFromBytes;
public class UnitUtilsTest extends TestCase {
public void testPrintUnitFromBytes() throws Exception {
+
+ // needed for the locales that have a decimal separator other than comma
+ char decimalSeparator = DecimalFormatSymbols.getInstance().getDecimalSeparator();
+
assertEquals("999 B", printUnitFromBytes(999));
- assertEquals("1.0 kB", printUnitFromBytes(1000));
- assertEquals("1.0 kB", printUnitFromBytes(1001));
+ assertEquals("1" + decimalSeparator + "0 kB", printUnitFromBytes(1000));
+ assertEquals("1" + decimalSeparator + "0 kB", printUnitFromBytes(1001));
- assertEquals("1000.0 kB", printUnitFromBytes(999999));
- assertEquals("1.0 MB", printUnitFromBytes(1000000));
- assertEquals("1.0 MB", printUnitFromBytes(1000001));
+ assertEquals("1000" + decimalSeparator + "0 kB", printUnitFromBytes(999999));
+ assertEquals("1" + decimalSeparator + "0 MB", printUnitFromBytes(1000000));
+ assertEquals("1" + decimalSeparator + "0 MB", printUnitFromBytes(1000001));
- assertEquals("1.5 MB", printUnitFromBytes(1500001));
+ assertEquals("1" + decimalSeparator + "5 MB", printUnitFromBytes(1500001));
}
}
[2/3] git commit: Fixed null issue when using camel-cdi with weld SE
2.0 with thanks to Shay
Posted by ni...@apache.org.
Fixed null issue when using camel-cdi with weld SE 2.0 with thanks to Shay
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/56ae0c42
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/56ae0c42
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/56ae0c42
Branch: refs/heads/master
Commit: 56ae0c42765efa934737991f2b2c8590736630fa
Parents: a370257
Author: Willem Jiang <ni...@apache.org>
Authored: Mon Sep 16 11:04:34 2013 +0800
Committer: Willem Jiang <ni...@apache.org>
Committed: Mon Sep 16 11:04:34 2013 +0800
----------------------------------------------------------------------
.../main/java/org/apache/camel/cdi/internal/CamelContextBean.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/56ae0c42/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextBean.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextBean.java
index 3411d3d..7e97f66 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextBean.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextBean.java
@@ -115,7 +115,7 @@ public class CamelContextBean implements Bean<CdiCamelContext> {
@Override
public Set<Class<? extends Annotation>> getStereotypes() {
- return null;
+ return new HashSet<Class<? extends Annotation>>();
}
@Override
[3/3] git commit: CAMEL-6752 Fixed the Bean binding to covariant
methods issue with thanks to Guy
Posted by ni...@apache.org.
CAMEL-6752 Fixed the Bean binding to covariant methods issue with thanks to Guy
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/961413cc
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/961413cc
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/961413cc
Branch: refs/heads/master
Commit: 961413cca9b8c8c6b0c2f0c640f18fa540587b68
Parents: 56ae0c4
Author: Willem Jiang <ni...@apache.org>
Authored: Mon Sep 16 11:41:24 2013 +0800
Committer: Willem Jiang <ni...@apache.org>
Committed: Mon Sep 16 11:41:24 2013 +0800
----------------------------------------------------------------------
.../apache/camel/component/bean/BeanInfo.java | 41 ++++++++++++++++----
.../apache/camel/component/bean/MethodInfo.java | 14 +++++++
2 files changed, 47 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/961413cc/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
index 6f91720..98d0c8b 100644
--- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
+++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
@@ -549,7 +549,11 @@ public class BeanInfo {
answer = chooseMethodWithMatchingParameters(exchange, parameters, possibleOperations);
}
}
-
+
+ if (answer == null && possibleOperations.size() > 1) {
+ answer = getSingleCovariantMethod(possibleOperations);
+ }
+
if (answer == null) {
throw new AmbiguousMethodCallException(exchange, possibleOperations);
} else {
@@ -611,11 +615,26 @@ public class BeanInfo {
}
if (candidates.size() > 1) {
- throw new AmbiguousMethodCallException(exchange, candidates);
+ MethodInfo answer = getSingleCovariantMethod(candidates);
+ if (answer == null) {
+ throw new AmbiguousMethodCallException(exchange, candidates);
+ }
+ return answer;
}
return candidates.size() == 1 ? candidates.get(0) : null;
}
+ private MethodInfo getSingleCovariantMethod(Collection<MethodInfo> candidates) {
+ // if all the candidates are actually covariant, it doesn't matter which one we call
+ MethodInfo firstCandidate = candidates.iterator().next();
+ for (MethodInfo candidate: candidates) {
+ if (!firstCandidate.isCovariantWith(candidate)) {
+ return null;
+ }
+ }
+ return firstCandidate;
+ }
+
private MethodInfo chooseMethodWithMatchingBody(Exchange exchange, Collection<MethodInfo> operationList,
List<MethodInfo> operationsWithCustomAnnotation)
throws AmbiguousMethodCallException {
@@ -711,8 +730,17 @@ public class BeanInfo {
LOG.trace("There are only one method with annotations so we choose it: {}", answer);
return answer;
}
- // phew try to choose among multiple methods with annotations
- return chooseMethodWithCustomAnnotations(exchange, possibles);
+ // try to choose among multiple methods with annotations
+ MethodInfo chosen = chooseMethodWithCustomAnnotations(exchange, possibles);
+ if (chosen != null) {
+ return chosen;
+ }
+ // just make sure the methods aren't all actually the same
+ chosen = getSingleCovariantMethod(possibles);
+ if (chosen != null) {
+ return chosen;
+ }
+ throw new AmbiguousMethodCallException(exchange, possibles);
}
// cannot find a good method to use
@@ -783,10 +811,7 @@ public class BeanInfo {
}
}
}
- if (chosen != null) {
- return chosen;
- }
- throw new AmbiguousMethodCallException(exchange, possibles);
+ return chosen;
}
/**
http://git-wip-us.apache.org/repos/asf/camel/blob/961413cc/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java
index cc58c50..a4dd2e0 100644
--- a/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java
+++ b/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java
@@ -389,6 +389,20 @@ public class MethodInfo {
public boolean isStaticMethod() {
return Modifier.isStatic(method.getModifiers());
}
+
+ /**
+ * Returns true if this method is covariant with the specified method
+ * (this method may above or below the specified method in the class hierarchy)
+ * @param method
+ * @return
+ */
+ public boolean isCovariantWith(MethodInfo method) {
+ return
+ method.getMethod().getName().equals(this.getMethod().getName())
+ && (method.getMethod().getReturnType().isAssignableFrom(this.getMethod().getReturnType())
+ || this.getMethod().getReturnType().isAssignableFrom(method.getMethod().getReturnType()))
+ && Arrays.deepEquals(method.getMethod().getParameterTypes(), this.getMethod().getParameterTypes());
+ }
protected Object invoke(Method mth, Object pojo, Object[] arguments, Exchange exchange) throws InvocationTargetException {
try {