Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem noticed in 13.17.1 #3033

Closed
yhinnach opened this issue Apr 19, 2023 Discussed in #3032 · 2 comments · Fixed by #3034
Closed

Problem noticed in 13.17.1 #3033

yhinnach opened this issue Apr 19, 2023 Discussed in #3032 · 2 comments · Fixed by #3034
Assignees
Labels
Milestone

Comments

@yhinnach
Copy link

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

@rob-bygrave
Copy link
Contributor

There is a version 13.17.1.1 which is already released and in maven central that has a fix for this issue.

Note that this is a 4 digit version number (and not the usual 3). I did that to release it quickly and there was no matching release of ebean-agent, ebean-gradle-plugin, ebean-maven-plugin etc - we need to just use 13.17.1 version of those.

I will add that fix and release a full 13.17.2 version of everything shortly.

Also, thanks for the bug report.

Cheers, Rob.

@rob-bygrave rob-bygrave self-assigned this Apr 19, 2023
@yhinnach
Copy link
Author

Thanks for the quick reply

rbygrave added a commit that referenced this issue Apr 20, 2023
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 ...
rbygrave added a commit that referenced this issue Apr 20, 2023
#3033 - Fix for ConcurrentModificationException introduced in 13.17.1
@rbygrave rbygrave added this to the 13.17.2 milestone Apr 20, 2023
@rbygrave rbygrave added the bug label Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants