@@ -40,7 +40,9 @@ static OutMessage query( Mongo m , int options , String ns , int numToSkip , int
40
40
41
41
static OutMessage query ( Mongo m , int options , String ns , int numToSkip , int batchSize , DBObject query , DBObject fields , ReadPreference readPref , DBEncoder enc ){
42
42
OutMessage out = new OutMessage ( m , 2004 , enc );
43
+
43
44
out ._appendQuery ( options , ns , numToSkip , batchSize , query , fields , readPref );
45
+
44
46
return out ;
45
47
}
46
48
@@ -69,15 +71,15 @@ private void _appendQuery( int options , String ns , int numToSkip , int batchSi
69
71
_readPref = readPref ;
70
72
71
73
//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 ;
74
76
75
77
writeInt ( _queryOptions );
76
78
writeCString ( ns );
77
79
78
80
writeInt ( numToSkip );
79
81
writeInt ( batchSize );
80
-
82
+
81
83
putObject ( query );
82
84
if ( fields != null )
83
85
putObject ( fields );
@@ -88,7 +90,7 @@ private void reset( int op ){
88
90
done ();
89
91
_buffer .reset ();
90
92
set ( _buffer );
91
-
93
+
92
94
_id = ID .getAndIncrement ();
93
95
94
96
writeInt ( 0 ); // length: will set this later
@@ -118,7 +120,7 @@ byte[] toByteArray(){
118
120
void doneWithMessage (){
119
121
if ( _buffer != null && _mongo != null )
120
122
_mongo ._bufferPool .done ( _buffer );
121
-
123
+
122
124
_buffer = null ;
123
125
_mongo = null ;
124
126
}
@@ -127,7 +129,7 @@ boolean hasOption( int option ){
127
129
return ( _queryOptions & option ) != 0 ;
128
130
}
129
131
130
- int getId (){
132
+ int getId (){
131
133
return _id ;
132
134
}
133
135
0 commit comments