Fix typo in transactional contains()
This commit is contained in:
@@ -164,11 +164,15 @@ public class TransactionAwareProxyFactory<T> {
|
||||
}
|
||||
|
||||
Object result = invocation.getMethod().invoke(cache, invocation.getArguments());
|
||||
|
||||
String methodName = invocation.getMethod().getName();
|
||||
if (appendOnly && result==null && (methodName.equals("get") || methodName.equals("contains"))) {
|
||||
// In appendOnly mode the result of a get might not be in the cache...
|
||||
return invocation.proceed();
|
||||
|
||||
if (appendOnly) {
|
||||
String methodName = invocation.getMethod().getName();
|
||||
if ((result == null && methodName.equals("get"))
|
||||
|| (Boolean.FALSE.equals(result) && methodName.startsWith("contains"))) {
|
||||
// In appendOnly mode the result of a get might not be
|
||||
// in the cache...
|
||||
return invocation.proceed();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.batch.support.transaction;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -84,6 +85,17 @@ public class ConcurrentTransactionAwareProxyTests {
|
||||
testMap(map);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionalContains() throws Exception {
|
||||
final Map<Long, Map<String, String>> map = TransactionAwareProxyFactory.createAppendOnlyTransactionalMap();
|
||||
boolean result = (Boolean) new TransactionTemplate(transactionManager).execute(new TransactionCallback() {
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
return map.containsKey("foo");
|
||||
}
|
||||
});
|
||||
assertFalse(result);
|
||||
}
|
||||
|
||||
private void testSet(final Set<String> set) throws Exception {
|
||||
|
||||
CompletionService<List<String>> completionService = new ExecutorCompletionService<List<String>>(Executors
|
||||
|
||||
Reference in New Issue
Block a user