You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by an...@apache.org on 2018/11/22 13:44:33 UTC

[syncope] branch 2_1_X updated: fixes tests and avoids NPE while showing plain attribuest wizard

This is an automated email from the ASF dual-hosted git repository.

andreapatricelli pushed a commit to branch 2_1_X
in repository https://gitbox.apache.org/repos/asf/syncope.git


The following commit(s) were added to refs/heads/2_1_X by this push:
     new ace95c3  fixes tests and avoids NPE while showing plain attribuest wizard
ace95c3 is described below

commit ace95c35795a1b2ee1017fe2b05013b4f6d35fd2
Author: Andrea Patricelli <an...@apache.org>
AuthorDate: Thu Nov 22 14:44:07 2018 +0100

    fixes tests and avoids NPE while showing plain attribuest wizard
---
 .../syncope/client/console/wizards/any/PlainAttrs.java   | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
index fb9c7c6..b767910 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
@@ -410,24 +410,26 @@ public class PlainAttrs extends AbstractAttrs<PlainSchemaTO> {
                         ((MultiFieldPanel) panel).setReadOnly(schemas.get(attrTO.getSchema()).isReadonly());
                     }
                     item.add(panel);
-                    Optional<AttrTO> previousPlainAttr = previousObject.getPlainAttr(attrTO.getSchema());
 
+                    Optional<AttrTO> previousPlainAttr = previousObject == null
+                            ? Optional.empty()
+                            : previousObject.getPlainAttr(attrTO.getSchema());
                     if (previousObject != null
-                            && ((!previousPlainAttr.isPresent() && !isEmptyOrBlank(attrTO.getValues()))
+                            && ((!previousPlainAttr.isPresent() && isNotEmptyOrBlank(attrTO.getValues()))
                             || (previousPlainAttr.isPresent() && !ListUtils.isEqualList(
                             ListUtils.select(previousPlainAttr.get().getValues(),
                                     object -> StringUtils.isNotEmpty(object)),
                             ListUtils.select(attrTO.getValues(), object -> StringUtils.isNotEmpty(object)))))) {
 
-                        List<String> oldValues = !previousPlainAttr.isPresent()
-                                ? Collections.<String>emptyList()
-                                : previousPlainAttr.get().getValues();
+                        List<String> oldValues = previousPlainAttr.isPresent()
+                                ? previousPlainAttr.get().getValues()
+                                : Collections.<String>emptyList();
                         panel.showExternAction(new LabelInfo("externalAction", oldValues));
                     }
                 }
 
-                protected boolean isEmptyOrBlank(final List<String> values) {
-                    return values.stream().allMatch(value -> StringUtils.isBlank(value));
+                protected boolean isNotEmptyOrBlank(final List<String> values) {
+                    return values.stream().anyMatch(value -> StringUtils.isNotBlank(value));
                 }
             });
         }