You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by st...@apache.org on 2016/06/28 10:00:25 UTC
svn commit: r1750459 -
/jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
Author: stefanegli
Date: Tue Jun 28 10:00:25 2016
New Revision: 1750459
URL: http://svn.apache.org/viewvc?rev=1750459&view=rev
Log:
OAK-4515 : backporting OAK-4107 to 1.4 branch - including another safety check and more details including error message and exception if any
Modified:
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
Modified: jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java?rev=1750459&r1=1750458&r2=1750459&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java (original)
+++ jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java Tue Jun 28 10:00:25 2016
@@ -86,6 +86,7 @@ import com.mongodb.BulkWriteException;
import com.mongodb.BulkWriteOperation;
import com.mongodb.BulkWriteResult;
import com.mongodb.BulkWriteUpsert;
+import com.mongodb.CommandResult;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
@@ -1572,7 +1573,23 @@ public class MongoDocumentStore implemen
final long start = System.currentTimeMillis();
// assumption here: server returns UTC - ie the returned
// date object is correctly taking care of time zones.
- final Date serverLocalTime = db.command("serverStatus").getDate("localTime");
+ final CommandResult serverStatus = db.command("serverStatus");
+ if (serverStatus == null) {
+ // OAK-4107 / OAK-4515 : extra safety
+ LOG.warn("determineServerTimeDifferenceMillis: db.serverStatus returned null - cannot determine time difference - assuming 0ms.");
+ return 0;
+ }
+ final Date serverLocalTime = serverStatus.getDate("localTime");
+ if (serverLocalTime == null) {
+ // OAK-4107 / OAK-4515 : looks like this can happen - at least
+ // has been seen once on mongo 3.0.9
+ // let's handle this gently and issue a log.warn
+ // instead of throwing a NPE
+ LOG.warn("determineServerTimeDifferenceMillis: db.serverStatus.localTime returned null - cannot determine time difference - assuming 0ms. "
+ + "(Result details: server exception=" + serverStatus.getException() + ", server error message=" + serverStatus.getErrorMessage() + ")",
+ serverStatus.getException());
+ return 0;
+ }
final long end = System.currentTimeMillis();
final long midPoint = (start + end) / 2;