[JAVA-412] NPE in DBTCPConnector#_error method Created: 11/Aug/11  Updated: 19/Oct/16  Resolved: 09/Sep/11

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: 2.6.3
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Roman Pichlik Assignee: Antoine Girbal
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates JAVA-384 NPE in case of IOException with a sin... Closed

 Description   

Steps to reproduce:

  • stop mongod service (single machine deployment)
  • use a driver

java.lang.NullPointerException
	at com.mongodb.DBTCPConnector._error(DBTCPConnector.java:287)
	at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:213)
	at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:296)
	at com.mongodb.DBCursor._check(DBCursor.java:356)
	at com.mongodb.DBCursor._hasNext(DBCursor.java:486)
	at com.mongodb.DBCursor.hasNext(DBCursor.java:511)

The _error method doesn't count that _rsStatus might be null.

    boolean _error( Throwable t, boolean slaveOk )
        throws MongoException {
        if ( _rsStatus.hasServerUp() ){
            // the replset has at least 1 server up, try to see if should switch master
            checkMaster( true , !slaveOk );
        }
        return _rsStatus.hasServerUp();
    }



 Comments   
Comment by Scott Hernandez (Inactive) [ 09/Sep/11 ]

JAVA-384

Generated at Thu Feb 08 08:52:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.