modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java | 23 +++++++--- 1 file changed, 18 insertions(+), 5 deletions(-)
New commits: commit ac2391109a7b141312f95595341a7dabed4551a4 Author: John Mazzitelli mazz@redhat.com Date: Mon Jan 9 15:23:50 2012 -0500
[BZ 771984] is appears that trying to concurrently update a subject's user preferences fails when one of the updates involves inserting a new property. The problem appears from the GWT client, so at the GWT servlet layer, we will now ensure that no two GWT requests can concurrently update a subject.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java index b790b79..e175134 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java @@ -36,6 +36,7 @@ public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements Sub private static final long serialVersionUID = 1L;
private SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager(); + private Object subjectLock = new Object(); // used to lock out concurrent subject updates
public void createPrincipal(String username, String password) throws RuntimeException { try { @@ -57,7 +58,7 @@ public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements Sub public Subject createSubject(Subject subjectToCreate, String password) throws RuntimeException { try { return SerialUtility.prepare(subjectManager.createSubject(getSessionSubject(), subjectToCreate, password), - "SubjectManager.createSubject"); + "SubjectManager.createSubjectPW"); } catch (Throwable t) { throw getExceptionToThrowToClient(t); } @@ -89,8 +90,12 @@ public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements Sub
public Subject updateSubject(Subject subjectToModify) throws RuntimeException { try { - Subject subject = SerialUtility.prepare(subjectManager.updateSubject(getSessionSubject(), subjectToModify), - "SubjectManager.updateSubject"); + Subject sessionSubject = getSessionSubject(); + Subject modifiedSubject; + synchronized (subjectLock) { + modifiedSubject = subjectManager.updateSubject(sessionSubject, subjectToModify); + } + Subject subject = SerialUtility.prepare(modifiedSubject, "SubjectManager.updateSubject"); // Clear the prefs for this subject from the user prefs cache that portal-war uses, in case we just // changed any prefs; otherwise the cache would contain stale prefs. SubjectPreferencesCache.getInstance().clearConfiguration(subject.getId()); @@ -102,8 +107,16 @@ public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements Sub
public Subject updateSubject(Subject subjectToModify, String newPassword) throws RuntimeException { try { - return SerialUtility.prepare(subjectManager - .updateSubject(getSessionSubject(), subjectToModify, newPassword), "SubjectManager.updateSubject"); + Subject sessionSubject = getSessionSubject(); + Subject modifiedSubject; + synchronized (subjectLock) { + modifiedSubject = subjectManager.updateSubject(sessionSubject, subjectToModify, newPassword); + } + Subject subject = SerialUtility.prepare(modifiedSubject, "SubjectManager.updateSubjectPW"); + // Clear the prefs for this subject from the user prefs cache that portal-war uses, in case we just + // changed any prefs; otherwise the cache would contain stale prefs. + SubjectPreferencesCache.getInstance().clearConfiguration(subject.getId()); + return subject; } catch (Throwable t) { throw getExceptionToThrowToClient(t); }
rhq-commits@lists.fedorahosted.org