From e0364e7031a0c45b71c11e4471dd1cc68595c975 Mon Sep 17 00:00:00 2001
From: pgamba <pgamba@localhost>
Date: Tue, 17 Nov 2009 08:52:17 +0000
Subject: [PATCH] Improve error handling for #4354 StringIndexOutOfBoundsException while polling ECL
---
opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java | 91 ++++++++++++++++++++++++++++-----------------
1 files changed, 57 insertions(+), 34 deletions(-)
diff --git a/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java b/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
index f7009d5..a3ffd42 100644
--- a/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
+++ b/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
@@ -29,6 +29,7 @@
import static org.opends.messages.CoreMessages.*;
+import static org.opends.server.loggers.ErrorLogger.logError;
import static org.opends.server.loggers.debug.DebugLogger.debugEnabled;
import static org.opends.server.loggers.debug.DebugLogger.getTracer;
import static org.opends.server.util.ServerConstants.*;
@@ -1046,25 +1047,36 @@
uAttrs.put(attributeType, attrList);
pattern = "creatorsName: ";
- int att_cr = clearLDIFchanges.indexOf(pattern);
- if (att_cr>0)
+ try
{
- int start_val_cr = clearLDIFchanges.indexOf(':', att_cr);
- int end_val_cr = clearLDIFchanges.indexOf(EOL, att_cr);
- String creatorsName =
- clearLDIFchanges.substring(start_val_cr+2, end_val_cr);
+ int att_cr = clearLDIFchanges.indexOf(pattern);
+ if (att_cr>0)
+ {
+ int start_val_cr = clearLDIFchanges.indexOf(':', att_cr);
+ int end_val_cr = clearLDIFchanges.indexOf(EOL, att_cr);
+ String creatorsName =
+ clearLDIFchanges.substring(start_val_cr+2, end_val_cr);
- if((attributeType =
- DirectoryServer.getAttributeType("changeInitiatorsName")) == null)
- attributeType =
- DirectoryServer.getDefaultAttributeType("changeInitiatorsName");
- a = Attributes.create(attributeType, creatorsName);
- attrList = new ArrayList<Attribute>(1);
- attrList.add(a);
- if(attributeType.isOperational())
- operationalAttrs.put(attributeType, attrList);
- else
- uAttrs.put(attributeType, attrList);
+ if((attributeType =
+ DirectoryServer.getAttributeType("changeInitiatorsName")) == null)
+ attributeType =
+ DirectoryServer.getDefaultAttributeType("changeInitiatorsName");
+ a = Attributes.create(attributeType, creatorsName);
+ attrList = new ArrayList<Attribute>(1);
+ attrList.add(a);
+ if(attributeType.isOperational())
+ operationalAttrs.put(attributeType, attrList);
+ else
+ uAttrs.put(attributeType, attrList);
+ }
+ }
+ catch(Exception e)
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ logError(Message.raw(Category.SYNC, Severity.MILD_ERROR,
+ "Error in External Change Log when looking for pattern \""
+ + pattern + "\" in string \""+
+ clearLDIFchanges + "\" for change " + dnString));
}
}
else if (changetype.equals("modify")||changetype.equals("modrdn"))
@@ -1087,25 +1099,36 @@
}
pattern = "modifiersName: ";
- int att_cr = clearLDIFchanges.indexOf(pattern);
- if (att_cr>0)
+ try
{
- int start_val_cr = att_cr + pattern.length();
- int end_val_cr = clearLDIFchanges.indexOf(EOL, att_cr);
- String modifiersName =
- clearLDIFchanges.substring(start_val_cr, end_val_cr);
+ int att_cr = clearLDIFchanges.indexOf(pattern);
+ if (att_cr>0)
+ {
+ int start_val_cr = att_cr + pattern.length();
+ int end_val_cr = clearLDIFchanges.indexOf(EOL, att_cr);
+ String modifiersName =
+ clearLDIFchanges.substring(start_val_cr, end_val_cr);
- if((attributeType =
- DirectoryServer.getAttributeType("changeInitiatorsName")) == null)
- attributeType =
- DirectoryServer.getDefaultAttributeType("changeInitiatorsName");
- a = Attributes.create(attributeType, modifiersName);
- attrList = new ArrayList<Attribute>(1);
- attrList.add(a);
- if(attributeType.isOperational())
- operationalAttrs.put(attributeType, attrList);
- else
- uAttrs.put(attributeType, attrList);
+ if((attributeType =
+ DirectoryServer.getAttributeType("changeInitiatorsName")) == null)
+ attributeType =
+ DirectoryServer.getDefaultAttributeType("changeInitiatorsName");
+ a = Attributes.create(attributeType, modifiersName);
+ attrList = new ArrayList<Attribute>(1);
+ attrList.add(a);
+ if(attributeType.isOperational())
+ operationalAttrs.put(attributeType, attrList);
+ else
+ uAttrs.put(attributeType, attrList);
+ }
+ }
+ catch(Exception e)
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ logError(Message.raw(Category.SYNC, Severity.MILD_ERROR,
+ "Error in External Change Log when looking for pattern \""
+ + pattern + "\" in string \""+
+ clearLDIFchanges + "\" for change " + dnString));
}
}
}
--
Gitblit v1.10.0