Skip to content

Commit 146a3d1

Browse files
committed
synchronized access to encoder/decoder
1 parent 9eacf18 commit 146a3d1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/main/com/mongodb/DBCollection.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -655,13 +655,13 @@ public final DBObject findOne( DBObject o, DBObject fields, ReadPreference readP
655655
// Only create a new decoder if there is a decoder factory explicitly set on the collection. Otherwise return null
656656
// so that DBPort will use a cached decoder from the default factory.
657657
private DBDecoder getDecoder() {
658-
return _decoderFactory != null ? _decoderFactory.create() : null;
658+
return getDBDecoderFactory() != null ? getDBDecoderFactory().create() : null;
659659
}
660660

661661
// Only create a new encoder if there is an encoder factory explicitly set on the collection. Otherwise return null
662662
// to allow DB to create its own or use a cached one.
663663
private DBEncoder getDBEncoder() {
664-
return _encoderFactory != null ? _encoderFactory.create() : null;
664+
return getDBEncoderFactory() != null ? getDBEncoderFactory().create() : null;
665665
}
666666

667667

@@ -1429,7 +1429,7 @@ public int getOptions(){
14291429
* Set a customer decoder factory for this collection. Set to null to use the default from MongoOptions.
14301430
* @param fact the factory to set.
14311431
*/
1432-
public void setDBDecoderFactory(DBDecoderFactory fact) {
1432+
public synchronized void setDBDecoderFactory(DBDecoderFactory fact) {
14331433
_decoderFactory = fact;
14341434
}
14351435

@@ -1438,15 +1438,15 @@ public void setDBDecoderFactory(DBDecoderFactory fact) {
14381438
* is being used.
14391439
* @return the factory
14401440
*/
1441-
public DBDecoderFactory getDBDecoderFactory() {
1441+
public synchronized DBDecoderFactory getDBDecoderFactory() {
14421442
return _decoderFactory;
14431443
}
14441444

14451445
/**
14461446
* Set a customer encoder factory for this collection. Set to null to use the default from MongoOptions.
14471447
* @param fact the factory to set.
14481448
*/
1449-
public void setDBEncoderFactory(DBEncoderFactory fact) {
1449+
public synchronized void setDBEncoderFactory(DBEncoderFactory fact) {
14501450
_encoderFactory = fact;
14511451
}
14521452

@@ -1455,7 +1455,7 @@ public void setDBEncoderFactory(DBEncoderFactory fact) {
14551455
* is being used.
14561456
* @return the factory
14571457
*/
1458-
public DBEncoderFactory getDBEncoderFactory() {
1458+
public synchronized DBEncoderFactory getDBEncoderFactory() {
14591459
return _encoderFactory;
14601460
}
14611461

0 commit comments

Comments
 (0)