CAMEL-11848: Check for null value when getting key "capped" of collection stats (key/value might not exist in MongoDB 2.6)
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3af062ba Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3af062ba Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3af062ba Branch: refs/heads/camel-2.19.x Commit: 3af062ba39059fab2f834c8a06b34b704d8dc944 Parents: 2ad2cc0 Author: Frank Wein <frank.w...@fau.de> Authored: Wed Sep 27 15:17:09 2017 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed Sep 27 15:41:51 2017 +0200 ---------------------------------------------------------------------- .../apache/camel/component/mongodb/MongoDbTailingProcess.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/3af062ba/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbTailingProcess.java ---------------------------------------------------------------------- diff --git a/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbTailingProcess.java b/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbTailingProcess.java index 2a1d574..a93cd11 100644 --- a/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbTailingProcess.java +++ b/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbTailingProcess.java @@ -94,7 +94,9 @@ public class MongoDbTailingProcess implements Runnable { } private Boolean isCollectionCapped() { - return endpoint.getMongoDatabase().runCommand(createCollStatsCommand()).getBoolean(CAPPED_KEY); + // A non-capped collection does not return a "capped" key/value, so we have to deal with null here + Boolean result = endpoint.getMongoDatabase().runCommand(createCollStatsCommand()).getBoolean(CAPPED_KEY); + return (result != null ? result : false); } private BasicDBObject createCollStatsCommand() {