Repository: camel Updated Branches: refs/heads/master f3569374c -> d7347cec8
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/d7347cec Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d7347cec Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d7347cec Branch: refs/heads/master Commit: d7347cec8859ef7142d5017f4d839c7fc9478ffc Parents: f356937 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:17:45 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/d7347cec/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 f858746..3f14c99 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 @@ -428,13 +428,17 @@ public class MongoDbEndpoint extends DefaultEndpoint { LOG.debug("Error setting the read preference. This exception will be ignored.", 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() {