This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-validation-core.git
The following commit(s) were added to refs/heads/master by this push:
new 9a603e4 SLING-7289 correctly remove validator references in map
9a603e4 is described below
commit 9a603e4605faa771417759cd1fc67210d92751f5
Author: Konrad Windszus <[email protected]>
AuthorDate: Thu Dec 7 17:39:12 2017 +0100
SLING-7289 correctly remove validator references in map
This closes #1
---
src/main/java/org/apache/sling/validation/impl/ValidatorMap.java | 5 +++--
.../java/org/apache/sling/validation/impl/ValidatorMapTest.java | 7 +++++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/sling/validation/impl/ValidatorMap.java
b/src/main/java/org/apache/sling/validation/impl/ValidatorMap.java
index 5c226aa..71d80d5 100644
--- a/src/main/java/org/apache/sling/validation/impl/ValidatorMap.java
+++ b/src/main/java/org/apache/sling/validation/impl/ValidatorMap.java
@@ -209,8 +209,8 @@ public class ValidatorMap {
String validatorId = getValidatorIdFromServiceProperties(properties,
validator.getClass(), serviceReference);
return remove(validatorId, serviceReference);
}
-
- public boolean remove(String id, ServiceReference<Validator<?>>
serviceReference) {
+
+ boolean remove(String id, ServiceReference<Validator<?>> serviceReference)
{
// only actually remove if the service reference is equal
if (id == null) {
// find by service reference
@@ -222,6 +222,7 @@ public class ValidatorMap {
} else {
// only actually remove if the service reference is equal
if (entry.serviceReference.equals(serviceReference)) {
+ //validatorMap.remove(id);
return true;
} else {
LOG.warn("Could not remove validator with id '{}' from map
because it is only contained with a different service reference!", id);
diff --git
a/src/test/java/org/apache/sling/validation/impl/ValidatorMapTest.java
b/src/test/java/org/apache/sling/validation/impl/ValidatorMapTest.java
index 479761e..dfe696c 100644
--- a/src/test/java/org/apache/sling/validation/impl/ValidatorMapTest.java
+++ b/src/test/java/org/apache/sling/validation/impl/ValidatorMapTest.java
@@ -107,4 +107,11 @@ public class ValidatorMapTest {
// make sure that the old validator id is no longer in the list
Assert.assertNull(validatorMap.get(DATE_VALIDATOR_ID));
}
+
+ @Test
+ public void testRemoveValidator() {
+ Assert.assertTrue("Previously bound validator could not be removed",
validatorMap.remove(DATE_VALIDATOR_ID, validatorServiceReference));
+ // make sure that the old validator id is no longer in the list
+ Assert.assertNull("Could not remove previously bound validator",
validatorMap.get(DATE_VALIDATOR_ID));
+ }
}
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].