From b26bb62a63b818f924d1b92ff8ba8a8be37c0c77 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Wed, 23 Nov 2011 12:48:39 +0100 Subject: [PATCH] DATAMONGO-305 - Removed synchronization from Query class. As Query is not intended to be thread-safe at all, we can safely remove the synchronized blocks from sort() and fields(). --- .../data/mongodb/core/query/Query.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Query.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Query.java index 60926f918..104abde43 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Query.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Query.java @@ -63,10 +63,8 @@ public class Query { } public Field fields() { - synchronized (this) { - if (fieldSpec == null) { - this.fieldSpec = new Field(); - } + if (fieldSpec == null) { + this.fieldSpec = new Field(); } return this.fieldSpec; } @@ -82,11 +80,10 @@ public class Query { } public Sort sort() { - synchronized (this) { - if (this.sort == null) { - this.sort = new Sort(); - } + if (this.sort == null) { + this.sort = new Sort(); } + return this.sort; }