This is an automated email from the ASF dual-hosted git repository. ilgrosso pushed a commit to branch 4_1_X in repository https://gitbox.apache.org/repos/asf/syncope.git
commit a2c61c5b9877b47c680742f5b05c1832a9ac23e3 Author: Francesco Chicchiriccò <[email protected]> AuthorDate: Tue Apr 21 10:05:28 2026 +0200 [SYNCOPE-1963] Check if null before pattern match --- .../persistence/common/dao/AbstractSearchDAO.java | 23 ++++++++++++---------- .../org/apache/syncope/fit/core/SearchITCase.java | 7 +++++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/core/persistence-common/src/main/java/org/apache/syncope/core/persistence/common/dao/AbstractSearchDAO.java b/core/persistence-common/src/main/java/org/apache/syncope/core/persistence/common/dao/AbstractSearchDAO.java index 03c8dad854..cc61f446b1 100644 --- a/core/persistence-common/src/main/java/org/apache/syncope/core/persistence/common/dao/AbstractSearchDAO.java +++ b/core/persistence-common/src/main/java/org/apache/syncope/core/persistence/common/dao/AbstractSearchDAO.java @@ -27,6 +27,7 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.HashSet; import java.util.List; +import java.util.Optional; import java.util.Set; import java.util.function.Supplier; import java.util.regex.Pattern; @@ -279,18 +280,20 @@ public abstract class AbstractSearchDAO { computed.setSchema(computed.getSchema() + "_id"); schema.setType(AttrSchemaType.String); - if (!SyncopeConstants.UUID_PATTERN.matcher(computed.getExpression()).matches()) { - switch (StringUtils.substringBefore(computed.getSchema(), "_id")) { - case "uManager" -> - userDAO.findKey(computed.getExpression()).ifPresent(computed::setExpression); + Optional.ofNullable(computed.getExpression()). + filter(expression -> !SyncopeConstants.UUID_PATTERN.matcher(expression).matches()). + ifPresent(expression -> { + switch (StringUtils.substringBefore(computed.getSchema(), "_id")) { + case "uManager" -> + userDAO.findKey(expression).ifPresent(computed::setExpression); - case "gManager" -> - groupDAO.findKey(computed.getExpression()).ifPresent(computed::setExpression); + case "gManager" -> + groupDAO.findKey(expression).ifPresent(computed::setExpression); - default -> { - } - } - } + default -> { + } + } + }); } PlainAttrValue attrValue = new PlainAttrValue(); diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java index 1b1b7e5780..e92fef4575 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java @@ -18,6 +18,7 @@ */ package org.apache.syncope.fit.core; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; @@ -1121,4 +1122,10 @@ public class SearchITCase extends AbstractITCase { sce.getMessage().contains("IllegalArgumentException: Cannot search by encrypted schema obscure")); } } + + @Test + void issueSYNCOPE1963() { + assertDoesNotThrow(() -> ANY_OBJECT_SERVICE.search(new AnyQuery.Builder().fiql( + SyncopeClient.getAnyObjectSearchConditionBuilder(PRINTER).isNotNull("gManager").query()).build())); + } }
