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

[2.7] fix 1957: Presize HashMap allocations in UnitOfWorkImpl - backport from master #1959

Merged
merged 1 commit into from
Oct 11, 2023

Conversation

Zuplyx
Copy link
Contributor

@Zuplyx Zuplyx commented Oct 6, 2023

add initial size to map creation where expected size is known or can be estimated

Signed-off-by: Patrick Schmitt <[email protected]>
@Zuplyx
Copy link
Contributor Author

Zuplyx commented Oct 9, 2023

@rfelcman I am unsure how to deal with the test failure.
I cannot reproduce it locally and the jenkins log does not provide me with enough information about the cause.

Copy link
Contributor

@rfelcman rfelcman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (I re-verified test locally and they passing)

@rfelcman rfelcman merged commit e712276 into eclipse-ee4j:2.7 Oct 11, 2023
5 of 6 checks passed
@Zuplyx Zuplyx deleted the 2.7_presize-collections branch October 11, 2023 07:59
rfelcman added a commit that referenced this pull request Oct 11, 2023
It seems, that code change introduced in #1959 doesn't work correctly on JDK 11 (17 and 21 works).
It's about following line
Map visitedObjects = new IdentityHashMap(values.stream().collect(Collectors.summingInt(Set::size)));

Issue is presented by following EL test error:

NestedUnitOfWorkDeleteNestedNewObjectTest

Exception Description: Fatal error occurred. Internal Exception: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.util.Map (java.lang.Integer and java.util.Map are in module java.base of loader 'bootstrap')

Local Exception Stack:
Exception [EclipseLink-0] (Eclipse Persistence Services - 2.7.14.qualifier): org.eclipse.persistence.testing.framework.TestErrorException
Exception Description: Fatal error occurred.
Internal Exception: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.util.Map (java.lang.Integer and java.util.Map are in module java.base of loader 'bootstrap')
at org.eclipse.persistence.testing.framework.TestCase.execute(TestCase.java:168)
at org.eclipse.persistence.testing.framework.TestCase.runBare(TestCase.java:267)
at org.eclipse.persistence.testing.framework.TestExecutor.execute(TestExecutor.java:250)
at org.eclipse.persistence.testing.framework.TestSuite.execute(TestSuite.java:82)
at org.eclipse.persistence.testing.framework.TestCollection.run(TestCollection.java:315)
at org.eclipse.persistence.testing.framework.TestExecutor.execute(TestExecutor.java:250)
at org.eclipse.persistence.testing.framework.TestModel.execute(TestModel.java:213)
at org.eclipse.persistence.testing.framework.TestCollection.run(TestCollection.java:315)
at org.eclipse.persistence.testing.framework.TestExecutor.execute(TestExecutor.java:250)
at org.eclipse.persistence.testing.framework.TestModel.execute(TestModel.java:213)
at org.eclipse.persistence.testing.framework.TestCollection.run(TestCollection.java:315)
Caused by: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.util.Map (java.lang.Integer and java.util.Map are in module java.base of loader 'bootstrap')
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.calculateChanges(UnitOfWorkImpl.java:812)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitNestedUnitOfWork(UnitOfWorkImpl.java:1389)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commit(UnitOfWorkImpl.java:1184)
at org.eclipse.persistence.testing.tests.unitofwork.NestedUnitOfWorkDeleteNestedNewObjectTest.test(NestedUnitOfWorkDeleteNestedNewObjectTest.java:44)
at org.eclipse.persistence.testing.framework.TestCase.executeTest(TestCase.java:547)
at org.eclipse.persistence.testing.framework.TestCase.execute(TestCase.java:158) 

it happens only if product (EclipseLink) is build by JDK 11.
Test itself should be called with any JDK (11, 17, 21).
Origin lambda is refactored into more "classical" style.

Signed-off-by: Radek Felcman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants