Skip to content

Commit e7d1b5e

Browse files
committed
JDO PersistenceManager synchronization performs close attempt after completion (if necessary; SPR-8846)
1 parent c9b36fb commit e7d1b5e

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

org.springframework.orm/src/main/java/org/springframework/orm/jdo/PersistenceManagerFactoryUtils.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2009 the original author or authors.
2+
* Copyright 2002-2011 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.
@@ -323,6 +323,11 @@ protected boolean shouldUnbindAtCompletion() {
323323
return this.newPersistenceManager;
324324
}
325325

326+
@Override
327+
protected boolean shouldReleaseAfterCompletion(PersistenceManagerHolder resourceHolder) {
328+
return !resourceHolder.getPersistenceManager().isClosed();
329+
}
330+
326331
@Override
327332
protected void releaseResource(PersistenceManagerHolder resourceHolder, PersistenceManagerFactory resourceKey) {
328333
releasePersistenceManager(resourceHolder.getPersistenceManager(), resourceKey);

org.springframework.transaction/src/main/java/org/springframework/transaction/support/ResourceHolderSynchronization.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2009 the original author or authors.
2+
* Copyright 2002-2011 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.
@@ -92,7 +92,7 @@ public void afterCompletion(int status) {
9292
releaseNecessary = true;
9393
}
9494
else {
95-
releaseNecessary = !shouldReleaseBeforeCompletion();
95+
releaseNecessary = shouldReleaseAfterCompletion(this.resourceHolder);
9696
}
9797
if (releaseNecessary) {
9898
releaseResource(this.resourceHolder, this.resourceKey);
@@ -128,6 +128,17 @@ protected boolean shouldReleaseBeforeCompletion() {
128128
return true;
129129
}
130130

131+
/**
132+
* Return whether this holder's resource should be released after
133+
* transaction completion (<code>true</code>).
134+
* <p>The default implementation returns <code>!shouldReleaseBeforeCompletion()</code>,
135+
* releasing after completion if no attempt was made before completion.
136+
* @see #releaseResource
137+
*/
138+
protected boolean shouldReleaseAfterCompletion(H resourceHolder) {
139+
return !shouldReleaseBeforeCompletion();
140+
}
141+
131142
/**
132143
* Flush callback for the given resource holder.
133144
* @param resourceHolder the resource holder to flush

0 commit comments

Comments
 (0)