SLING-2534 : Strings of zero length on update in post servlet delete the property. Apply patch from Hanish Bansal
diff --git a/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java b/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java
index 2530647..11a77a0 100644
--- a/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java
+++ b/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java
@@ -209,14 +209,13 @@
String[] values = prop.getStringValues();
- if (values == null
- || (values.length == 1 && values[0].length() == 0 && getType(parent, prop) != PropertyType.STRING)) {
- // if no value is present or a single empty non string is given,
- // just remove the existing property (if any)
+ // RequestProperty#getStringValues already takes care of the configs ignoreBlanks, defaultValues etc.
+ // and provides values as null, new String[0] etc. accordingly.
+ if (values == null) {
+ // if no value is present, just remove the existing property (if any)
removeProperty(parent, prop);
- } else if (values.length == 0
- || (values.length == 1 && values[0].length() == 0 && getType(parent, prop) == PropertyType.STRING)) {
+ } else if (values.length == 0) {
// do not create new prop here, but clear existing
clearProperty(parent, prop);