Permalink
Browse files

GPMONGODB-30 checking for null before version check

  • Loading branch information...
1 parent c1aae5f commit 6061f2ddb437b19d9c32e0eb53e73dbbf4d9ec22 @burtbeckwith burtbeckwith committed Apr 24, 2011
@@ -355,7 +355,7 @@ protected void checkVersion(Region region, EntityAccess access,
currentVersion = ((Number)currentVersion).longValue();
}
- if (!oldVersion.equals(currentVersion)) {
+ if (oldVersion != null && currentVersion != null && !oldVersion.equals(currentVersion)) {
throw new OptimisticLockingException(persistentEntity, id);
}
@@ -208,8 +208,7 @@ public Object doInDB(DB con) throws MongoException, DataAccessException {
}
protected DBCollection getCollection(DB con) {
- DBCollection dbCollection = con.getCollection(getCollectionName(getPersistentEntity()));
- return dbCollection;
+ return con.getCollection(getCollectionName(getPersistentEntity()));
}
});
}
@@ -416,7 +415,7 @@ protected void checkVersion(final EntityAccess ea, final DBObject previous,
oldVersion = ((Number)oldVersion).longValue();
currentVersion = ((Number)currentVersion).longValue();
}
- if (!oldVersion.equals(currentVersion)) {
+ if (oldVersion != null && currentVersion != null && !oldVersion.equals(currentVersion)) {
throw new OptimisticLockingException(persistentEntity, key);
}
incrementVersion(ea);
@@ -317,7 +317,7 @@ private void saveOrUpdate(final String family, final Long id, final Map nativeEn
}
String version = (String)nativeEntry.get("version");
- if (!version.equals(oldVersion)) {
+ if (oldVersion != null && version != null && !version.equals(oldVersion)) {
throw new OptimisticLockingException(persistentEntity, id);
}
@@ -243,7 +243,7 @@ class SimpleMapEntityPersister extends AbstractKeyValueEntityPesister<Map, Objec
oldVersion = existing.version.toLong()
currentVersion = entityAccess.getProperty('version').toLong()
}
- if (!oldVersion.equals(currentVersion)) {
+ if (oldVersion != null && currentVersion != null && !oldVersion.equals(currentVersion)) {
throw new OptimisticLockingException(persistentEntity, key)
}
incrementVersion(entityAccess)

0 comments on commit 6061f2d

Please sign in to comment.