Discussed in #3032
Originally posted by yhinnach April 19, 2023
Hi @rbygrave we were using ebean orm 13.17.0 and started noticing this problem in our application after we upgraded to 13.17.1
java.util.ConcurrentModificationException
at java.base/java.util.HashMap$HashIterator.nextNode(HashMap.java:1493)
at java.base/java.util.HashMap$KeyIterator.next(HashMap.java:1516)
at java.base/java.util.AbstractCollection.toString(AbstractCollection.java:472)
at java.base/java.lang.String.valueOf(String.java:2951)
at io.ebeaninternal.server.core.DefaultBeanLoader.loadBean(DefaultBeanLoader.java:134)
at io.ebeaninternal.server.core.DefaultServer.loadBean(DefaultServer.java:475)
at io.ebeaninternal.server.loadcontext.DLoadBeanContext$LoadBuffer.loadBean(DLoadBeanContext.java:217)
at io.ebean.bean.InterceptReadWrite.loadBeanInternal(InterceptReadWrite.java:742)
at io.ebean.bean.InterceptReadWrite.loadBean(InterceptReadWrite.java:724)
at io.ebean.bean.InterceptReadWrite.preGetter(InterceptReadWrite.java:837)
at net.brightback.identity.api.User._ebean_get_email(User.java:6)
at net.brightback.identity.api.User.getEmail(User.java:34)
at com.fasterxml.jackson.module.blackbird.ser.StringPropertyWriter.serializeAsField(StringPropertyWriter.java:53)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:774)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
at com.fasterxml.jackson.module.blackbird.ser.ObjectPropertyWriter.serializeAsField(ObjectPropertyWriter.java:95)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:774)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:119)
at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:79)
at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:18)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
at com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(ObjectMapper.java:4624)
at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:3828)
It looks like a map is getting toStringed and modified at the same time. This seems to be a map that ebean maintains so we are not sure how to resolve this while remaining on 13.17.1. So for now we rolled back to 13.17.0
It wasn't obvious why this problem was happening after the upgrade so we looked at the change log:
13.17.0...13.17.1
There was a change made to DefaultBeanLoader.java in 13.17.1 which is probably related. This was added: final String batchBefore = String.valueOf(batch); and used below:
if (result.markedDeleted() && CoreLog.markedAsDeleted.isLoggable(DEBUG)) {
CoreLog.markedAsDeleted.log(DEBUG, "Loaded bean batch BEFORE {0}", batchBefore);
CoreLog.markedAsDeleted.log(DEBUG, "Loaded bean batch AFTER {0}", batch);
Would it be possible to make a change on your end to wrap final String batchBefore = String.valueOf(batch); inside an if condition that checks if DEBUG is enabled for "markAsDeleted" ? Presumably DEBUG would not be enabled in our environment so we wouldn't try to serialize the map to a String and not execute the problematic codepath. It's also probably a good thing for performance to not incur the cost of that line regardless of whether DEBUG is on or not. This wouldn't resolve the root cause, but it would probably address our problem if by default ebean orm doesn't run in DEBUG mode for "markAsDeleted".
Please let me know if it makes sense and if a fix could be released for this.
Thank you,
Yassine
Discussed in #3032
Originally posted by yhinnach April 19, 2023
Hi @rbygrave we were using ebean orm 13.17.0 and started noticing this problem in our application after we upgraded to 13.17.1
It looks like a map is getting toStringed and modified at the same time. This seems to be a map that ebean maintains so we are not sure how to resolve this while remaining on 13.17.1. So for now we rolled back to 13.17.0
It wasn't obvious why this problem was happening after the upgrade so we looked at the change log:
13.17.0...13.17.1
There was a change made to DefaultBeanLoader.java in 13.17.1 which is probably related. This was added:
final String batchBefore = String.valueOf(batch);and used below:Would it be possible to make a change on your end to wrap
final String batchBefore = String.valueOf(batch);inside an if condition that checks if DEBUG is enabled for "markAsDeleted" ? Presumably DEBUG would not be enabled in our environment so we wouldn't try to serialize the map to a String and not execute the problematic codepath. It's also probably a good thing for performance to not incur the cost of that line regardless of whether DEBUG is on or not. This wouldn't resolve the root cause, but it would probably address our problem if by default ebean orm doesn't run in DEBUG mode for "markAsDeleted".Please let me know if it makes sense and if a fix could be released for this.
Thank you,
Yassine