Skip to content

Commit b08990c

Browse files
committed
DATAMONGO-1380 - Polishing.
Add credits, use message formatting instead string concatenation. Original pull request: #317.
1 parent f3770a4 commit b08990c

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

spring-data-mongodb-cross-store/src/main/java/org/springframework/data/mongodb/crossstore/MongoChangeSetPersister.java

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2015 the original author or authors.
2+
* Copyright 2011-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,6 +37,8 @@
3737
/**
3838
* @author Thomas Risberg
3939
* @author Oliver Gierke
40+
* @author Alex Vengrovsk
41+
* @author Mark Paluch
4042
*/
4143
public class MongoChangeSetPersister implements ChangeSetPersister<Object> {
4244

@@ -76,14 +78,14 @@ public void getPersistentState(Class<? extends ChangeSetBacked> entityClass, Obj
7678
dbk.put(ENTITY_ID, id);
7779
dbk.put(ENTITY_CLASS, entityClass.getName());
7880
if (log.isDebugEnabled()) {
79-
log.debug("Loading MongoDB data for " + dbk);
81+
log.debug("Loading MongoDB data for {}", dbk);
8082
}
8183
mongoTemplate.execute(collName, new CollectionCallback<Object>() {
8284
public Object doInCollection(DBCollection collection) throws MongoException, DataAccessException {
8385
for (DBObject dbo : collection.find(dbk)) {
8486
String key = (String) dbo.get(ENTITY_FIELD_NAME);
8587
if (log.isDebugEnabled()) {
86-
log.debug("Processing key: " + key);
88+
log.debug("Processing key: {}", key);
8789
}
8890
if (!changeSet.getValues().containsKey(key)) {
8991
String className = (String) dbo.get(ENTITY_FIELD_CLASS);
@@ -94,7 +96,7 @@ public Object doInCollection(DBCollection collection) throws MongoException, Dat
9496
Class<?> clazz = ClassUtils.resolveClassName(className, ClassUtils.getDefaultClassLoader());
9597
Object value = mongoTemplate.getConverter().read(clazz, dbo);
9698
if (log.isDebugEnabled()) {
97-
log.debug("Adding to ChangeSet: " + key);
99+
log.debug("Adding to ChangeSet: {}", key);
98100
}
99101
changeSet.set(key, value);
100102
}
@@ -109,9 +111,9 @@ public Object doInCollection(DBCollection collection) throws MongoException, Dat
109111
* @see org.springframework.data.crossstore.ChangeSetPersister#getPersistentId(org.springframework.data.crossstore.ChangeSetBacked, org.springframework.data.crossstore.ChangeSet)
110112
*/
111113
public Object getPersistentId(ChangeSetBacked entity, ChangeSet cs) throws DataAccessException {
112-
if (log.isDebugEnabled()) {
113-
log.debug("getPersistentId called on " + entity);
114-
}
114+
if (log.isDebugEnabled()) {
115+
log.debug("getPersistentId called on {}", entity);
116+
}
115117
if (entityManagerFactory == null) {
116118
throw new DataAccessResourceFailureException("EntityManagerFactory cannot be null");
117119
}
@@ -130,7 +132,7 @@ public Object persistState(ChangeSetBacked entity, ChangeSet cs) throws DataAcce
130132
}
131133

132134
if (log.isDebugEnabled()) {
133-
log.debug("Flush: changeset: " + cs.getValues());
135+
log.debug("Flush: changeset: {}", cs.getValues());
134136
}
135137

136138
String collName = getCollectionNameForEntity(entity.getClass());
@@ -152,7 +154,7 @@ public DBObject doInCollection(DBCollection collection) throws MongoException, D
152154
});
153155
if (value == null) {
154156
if (log.isDebugEnabled()) {
155-
log.debug("Flush: removing: " + dbQuery);
157+
log.debug("Flush: removing: {}", dbQuery);
156158
}
157159
mongoTemplate.execute(collName, new CollectionCallback<Object>() {
158160
public Object doInCollection(DBCollection collection) throws MongoException, DataAccessException {
@@ -164,7 +166,7 @@ public Object doInCollection(DBCollection collection) throws MongoException, Dat
164166
final DBObject dbDoc = new BasicDBObject();
165167
dbDoc.putAll(dbQuery);
166168
if (log.isDebugEnabled()) {
167-
log.debug("Flush: saving: " + dbQuery);
169+
log.debug("Flush: saving: {}", dbQuery);
168170
}
169171
mongoTemplate.getConverter().write(value, dbDoc);
170172
dbDoc.put(ENTITY_FIELD_CLASS, value.getClass().getName());

0 commit comments

Comments
 (0)