Author: mreutegg
Date: Thu Sep 22 12:34:19 2016
New Revision: 1761930

URL: http://svn.apache.org/viewvc?rev=1761930&view=rev
Log:
OAK-4841: Error during MongoDB initialization

Modified:
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java?rev=1761930&r1=1761929&r2=1761930&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
 Thu Sep 22 12:34:19 2016
@@ -234,7 +234,7 @@ public class MongoDocumentStore implemen
 
     public MongoDocumentStore(DB db, DocumentMK.Builder builder) {
         CommandResult serverStatus = db.command("serverStatus");
-        String version = checkVersion(serverStatus);
+        String version = checkVersion(db, serverStatus);
         metadata = ImmutableMap.<String,String>builder()
                 .put("type", "mongo")
                 .put("version", version)
@@ -301,8 +301,13 @@ public class MongoDocumentStore implemen
     }
 
     @Nonnull
-    private static String checkVersion(CommandResult serverStatus) {
+    private static String checkVersion(DB db, CommandResult serverStatus) {
         String version = serverStatus.getString("version");
+        if (version == null) {
+            // OAK-4841: serverStatus was probably unauthorized,
+            // use buildInfo command to get version
+            version = db.command("buildInfo").getString("version");
+        }
         Matcher m = Pattern.compile("^(\\d+)\\.(\\d+)\\..*").matcher(version);
         if (!m.matches()) {
             throw new IllegalArgumentException("Malformed MongoDB version: " + 
version);


Reply via email to