diff --git a/spring-ldap/src/main/java/org/springframework/ldap/core/DirContextAdapter.java b/spring-ldap/src/main/java/org/springframework/ldap/core/DirContextAdapter.java
index ef853b47..2c697ad5 100644
--- a/spring-ldap/src/main/java/org/springframework/ldap/core/DirContextAdapter.java
+++ b/spring-ldap/src/main/java/org/springframework/ldap/core/DirContextAdapter.java
@@ -334,68 +334,6 @@ public class DirContextAdapter implements DirContextOperations {
}
}
- /**
- * Compare the existing attribute name with the value in
- * value.
- *
- * Also handles the case where the value has been reset to the original
- * value after a previous change. For example, changing a to
- * b and then back to a again must result in
- * this method returning true so the first change can be
- * overwritten with the latest change. TODO Do the null checks on the value
- * instead
- *
- * @param name
- * Name of the original attribute.
- * @param value
- * Value to check if it has been changed.
- * @return true if there has been a change compared to original attribute,
- * or a previous update
- */
- private boolean isChanged(String name, Object value) {
- Attribute orig = originalAttrs.get(name);
- Attribute prev = updatedAttrs.get(name);
-
- // FALSE if both are null it is not changed
- // TODO Also include prev in null check
- if (orig == null && value == null) {
- return false;
- }
-
- // TRUE if existing value is null or does not contain one value
- if (orig == null || orig.size() != 1) {
- return true;
- }
-
- // TRUE if existing value is not null and the new one is null
- if (orig != null && value == null) {
- return true;
- }
-
- // TRUE if we can't access the value
- Object obj = null;
- try {
- obj = orig.get(0);
- } catch (NamingException e) {
- return true;
- }
-
- if (prev == null) {
- // TRUE if the value is not equal
- return !value.equals(obj);
- } else {
- // TRUE if we can't access the value
- Object prevObj = null;
- try {
- prevObj = prev.get(0);
- } catch (NamingException e) {
- return true;
- }
- // TRUE if the value is not equal
- return !value.equals(obj) || !value.equals(prevObj);
- }
- }
-
/**
* returns true if the attribute is empty. It is empty if a == null, size ==
* 0 or get() == null or an exception if thrown when accessing the get
@@ -584,7 +522,7 @@ public class DirContextAdapter implements DirContextOperations {
}
// updating entry
- if (updateMode && isChanged(name, value)) {
+ if (updateMode) {
BasicAttribute attribute = new BasicAttribute(name);
if (value != null) {
attribute.add(value);
diff --git a/spring-ldap/src/test/java/org/springframework/ldap/core/DirContextAdapterTest.java b/spring-ldap/src/test/java/org/springframework/ldap/core/DirContextAdapterTest.java
index e823b340..095eebb9 100644
--- a/spring-ldap/src/test/java/org/springframework/ldap/core/DirContextAdapterTest.java
+++ b/spring-ldap/src/test/java/org/springframework/ldap/core/DirContextAdapterTest.java
@@ -987,4 +987,19 @@ public class DirContextAdapterTest extends TestCase {
.getModificationOp());
assertEquals("some person", modificationItem.getAttribute().get());
}
+
+ /**
+ * Test for LDAP-13.
+ */
+ public void testModifyAttributeByteArray() {
+ tested.setAttribute(new BasicAttribute("abc", new byte[] { 1, 2, 3 }));
+
+ tested.setUpdateMode(true);
+
+ // Perform test
+ tested.setAttributeValue("abc", new byte[] { 1, 2, 3 });
+
+ ModificationItem[] modificationItems = tested.getModificationItems();
+ assertEquals(0, modificationItems.length);
+ }
}