From ad1e1e776a8f5386df8237af2bc413446c4d8762 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Fri, 25 Feb 2011 18:47:49 +0000
Subject: [PATCH] Fix for OPENDJ-55: Failing modify operations causing memory leak. The memory leak is happening when PreOperation plugins are aborting an update (like UniqueAttributePlugin). Several issues with the whole plugin manager, preOperation and postOperation plugins. 1/ The postOperation method of a plugin was always called even when the PreOp was skipped. This is due to an error in the ModifyOperationWrapper equals method (A.equals(A) was always false). As a result, the concurrentHashMap of skipped plugins was never cleaned and leaked memory big time. 2/ The postOperation method for most of the registered plugin would not check if the operation was successful or not before processing. This could possibly create issues with Access Controls, Groups or Subentries. 3/ The UniqueAttributePlugin would not clean the concurrentHashMap of attribute values being checked for uniqueness, on errors. On success, it's done in the PostOperation method. On errors, the PostOperation method is not called, so the PreOp needs to cleans it before returning. For this we're now keeping a list of values added to the ConcurrrentHashMap, and remove them before returning an error.
---
opends/src/server/org/opends/server/core/SubentryManager.java | 28 ++++++++++++++++++++++++----
1 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/opends/src/server/org/opends/server/core/SubentryManager.java b/opends/src/server/org/opends/server/core/SubentryManager.java
index df7d46c..adaa624 100644
--- a/opends/src/server/org/opends/server/core/SubentryManager.java
+++ b/opends/src/server/org/opends/server/core/SubentryManager.java
@@ -1166,7 +1166,12 @@
public PostOperation doPostOperation(
PostOperationAddOperation addOperation)
{
- doPostAdd(addOperation.getEntryToAdd());
+ // Only do something if the operation is successful, meaning there
+ // has been a change.
+ if (addOperation.getResultCode() == ResultCode.SUCCESS)
+ {
+ doPostAdd(addOperation.getEntryToAdd());
+ }
// If we've gotten here, then everything is acceptable.
return PluginResult.PostOperation.continueOperationProcessing();
@@ -1179,7 +1184,12 @@
public PostOperation doPostOperation(
PostOperationDeleteOperation deleteOperation)
{
- doPostDelete(deleteOperation.getEntryToDelete());
+ // Only do something if the operation is successful, meaning there
+ // has been a change.
+ if (deleteOperation.getResultCode() == ResultCode.SUCCESS)
+ {
+ doPostDelete(deleteOperation.getEntryToDelete());
+ }
// If we've gotten here, then everything is acceptable.
return PluginResult.PostOperation.continueOperationProcessing();
@@ -1192,8 +1202,13 @@
public PostOperation doPostOperation(
PostOperationModifyOperation modifyOperation)
{
- doPostModify(modifyOperation.getCurrentEntry(),
+ // Only do something if the operation is successful, meaning there
+ // has been a change.
+ if (modifyOperation.getResultCode() == ResultCode.SUCCESS)
+ {
+ doPostModify(modifyOperation.getCurrentEntry(),
modifyOperation.getModifiedEntry());
+ }
// If we've gotten here, then everything is acceptable.
return PluginResult.PostOperation.continueOperationProcessing();
@@ -1206,8 +1221,13 @@
public PostOperation doPostOperation(
PostOperationModifyDNOperation modifyDNOperation)
{
- doPostModifyDN(modifyDNOperation.getOriginalEntry(),
+ // Only do something if the operation is successful, meaning there
+ // has been a change.
+ if (modifyDNOperation.getResultCode() == ResultCode.SUCCESS)
+ {
+ doPostModifyDN(modifyDNOperation.getOriginalEntry(),
modifyDNOperation.getUpdatedEntry());
+ }
// If we've gotten here, then everything is acceptable.
return PluginResult.PostOperation.continueOperationProcessing();
--
Gitblit v1.10.0