Repository: camel Updated Branches: refs/heads/camel-2.13.x e4c1f8e0f -> e9f4fb855
Fix the old glitch by MongoDbEndpoint#setReadPreference() which would ALWAYS throw IllegalArgumentException Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e9f4fb85 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e9f4fb85 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e9f4fb85 Branch: refs/heads/camel-2.13.x Commit: e9f4fb8556d5d828166cff41ce9e81483edd580b Parents: e4c1f8e Author: Babak Vahdat <bvah...@apache.org> Authored: Sun Apr 13 11:17:45 2014 +0200 Committer: Babak Vahdat <bvah...@apache.org> Committed: Sun Apr 13 11:19:30 2014 +0200 ---------------------------------------------------------------------- .../apache/camel/component/mongodb/MongoDbEndpoint.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/e9f4fb85/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbEndpoint.java b/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbEndpoint.java index 7dfcbde..0ee3554 100644 --- a/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbEndpoint.java +++ b/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbEndpoint.java @@ -427,13 +427,17 @@ public class MongoDbEndpoint extends DefaultEndpoint { } catch (Exception e) { continue; } + // break the loop as we could successfully set the read preference property break; } } - String msg = "Could not resolve specified ReadPreference of type " + readPreference - + ". Read preferences are resolved from inner classes of com.mongodb.ReadPreference."; - throw new IllegalArgumentException(msg); + // were we able to set the read preference? + if (getReadPreference() == null) { + String msg = "Could not resolve specified ReadPreference of type " + readPreference + + ". Read preferences are resolved from inner classes of com.mongodb.ReadPreference."; + throw new IllegalArgumentException(msg); + } } public ReadPreference getReadPreference() {