This is an automated email from the ASF dual-hosted git repository.
ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/master by this push:
new 5f26f1fa29 [SYNCOPE-1963] Check if null before pattern match
5f26f1fa29 is described below
commit 5f26f1fa29d8e97c7fba6679f82e307f87ac9066
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 ++++++++++++----------
.../notification/DefaultNotificationManager.java | 4 +---
.../org/apache/syncope/fit/core/SearchITCase.java | 7 +++++++
3 files changed, 21 insertions(+), 13 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/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/notification/DefaultNotificationManager.java
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/notification/DefaultNotificationManager.java
index 330a2b4828..0a9c1539ad 100644
---
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/notification/DefaultNotificationManager.java
+++
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/notification/DefaultNotificationManager.java
@@ -358,15 +358,13 @@ public class DefaultNotificationManager implements
NotificationManager {
},
() -> {
switch (before) {
- case null -> {
- }
case UserTO userTO ->
jexlVars.put("user", userTO);
case GroupTO groupTO ->
jexlVars.put("group", groupTO);
case AnyObjectTO anyObjectTO ->
jexlVars.put("anyObject", anyObjectTO);
- default -> {
+ case null, default -> {
}
}
});
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 21177ce1ba..7bb5dccf07 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;
@@ -1043,4 +1044,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()));
+ }
}