[
https://issues.apache.org/jira/browse/SYNCOPE-1520?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16986113#comment-16986113
]
Francesco Chicchiriccò commented on SYNCOPE-1520:
-------------------------------------------------
By rewriting the following code block:
{code}
any.getPlainAttrs().stream().
filter(attr -> attr.getUniqueValue() != null).
map(JSONPlainAttr.class::cast).
forEach(attr -> {
PlainSchema schema = attr.getSchema();
Optional<A> other = findByPlainAttrUniqueValue(table,
anyUtils, schema, attr.getUniqueValue(), false);
if (!other.isPresent() ||
other.get().getKey().equals(any.getKey())) {
LOG.debug("No duplicate value found for {}",
attr.getUniqueValue().getValueAsString());
} else {
throw new DuplicateException(
"Value " +
attr.getUniqueValue().getValueAsString()
+ " existing for " + schema.getKey());
}
});
{code}
as old-style
{code}
for (PlainAttr<?> attr : any.getPlainAttrs()) {
if (attr.getUniqueValue() != null && attr instanceof JSONPlainAttr)
{
PlainSchema schema = attr.getSchema();
Optional<A> other = findByPlainAttrUniqueValue(table, anyUtils,
schema, attr.getUniqueValue(), false);
if (!other.isPresent() ||
other.get().getKey().equals(any.getKey())) {
LOG.debug("No duplicate value found for {}",
attr.getUniqueValue().getValueAsString());
} else {
throw new DuplicateException(
"Value " + attr.getUniqueValue().getValueAsString()
+ " existing for " + schema.getKey());
}
}
}
{code}
the problem disappears.
The case seems the same as presented in
https://medium.com/xiumeteo-labs/stream-and-concurrentmodificationexception-2d14ed8ff4b2
> Exception when updating Group unique attribute with JPA JSON
> ------------------------------------------------------------
>
> Key: SYNCOPE-1520
> URL: https://issues.apache.org/jira/browse/SYNCOPE-1520
> Project: Syncope
> Issue Type: Bug
> Components: core
> Affects Versions: 2.1.5
> Reporter: Francesco Chicchiriccò
> Assignee: Francesco Chicchiriccò
> Priority: Major
> Labels: jpa-json
> Fix For: 2.1.6, 3.0.0
>
>
> When updating a Group's unique attribute, the following exception is logged:
> {code}
> java.util.ConcurrentModificationException: null
> at
> java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1388)
> ~[?:1.8.0_232]
> at
> java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
> ~[?:1.8.0_232]
> at
> java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
> ~[?:1.8.0_232]
> at
> java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
> ~[?:1.8.0_232]
> at
> java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
> ~[?:1.8.0_232]
> at
> java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
> ~[?:1.8.0_232]
> at
> java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:485)
> ~[?:1.8.0_232]
> at
> org.apache.syncope.core.persistence.jpa.dao.AbstractJPAJSONAnyDAO.checkBeforeSave(AbstractJPAJSONAnyDAO.java:317)
> ~[dao/:?]
> at
> org.apache.syncope.core.persistence.jpa.dao.PGJPAJSONAnyDAO.checkBeforeSave(PGJPAJSONAnyDAO.java:37)
> ~[dao/:?]
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)