Skip to content

Commit c6ed1ed

Browse files
author
Ryan
committed
check for null _readPref - removed whitespace.
1 parent 3202300 commit c6ed1ed

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/main/com/mongodb/OutMessage.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ static OutMessage query( Mongo m , int options , String ns , int numToSkip , int
4040

4141
static OutMessage query( Mongo m , int options , String ns , int numToSkip , int batchSize , DBObject query , DBObject fields, ReadPreference readPref, DBEncoder enc ){
4242
OutMessage out = new OutMessage( m , 2004, enc );
43+
4344
out._appendQuery( options , ns , numToSkip , batchSize , query , fields, readPref);
45+
4446
return out;
4547
}
4648

@@ -69,15 +71,15 @@ private void _appendQuery( int options , String ns , int numToSkip , int batchSi
6971
_readPref = readPref;
7072

7173
//If the readPrefs are non-null and non-primary, set slaveOk query option
72-
if (!(_readPref instanceof ReadPreference.PrimaryReadPreference))
73-
_queryOptions |= Bytes.QUERYOPTION_SLAVEOK;
74+
if (_readPref != null && !(_readPref instanceof ReadPreference.PrimaryReadPreference))
75+
_queryOptions |= Bytes.QUERYOPTION_SLAVEOK;
7476

7577
writeInt( _queryOptions );
7678
writeCString( ns );
7779

7880
writeInt( numToSkip );
7981
writeInt( batchSize );
80-
82+
8183
putObject( query );
8284
if ( fields != null )
8385
putObject( fields );
@@ -88,7 +90,7 @@ private void reset( int op ){
8890
done();
8991
_buffer.reset();
9092
set( _buffer );
91-
93+
9294
_id = ID.getAndIncrement();
9395

9496
writeInt( 0 ); // length: will set this later
@@ -118,7 +120,7 @@ byte[] toByteArray(){
118120
void doneWithMessage(){
119121
if ( _buffer != null && _mongo != null )
120122
_mongo._bufferPool.done( _buffer );
121-
123+
122124
_buffer = null;
123125
_mongo = null;
124126
}
@@ -127,7 +129,7 @@ boolean hasOption( int option ){
127129
return ( _queryOptions & option ) != 0;
128130
}
129131

130-
int getId(){
132+
int getId(){
131133
return _id;
132134
}
133135

0 commit comments

Comments
 (0)