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

Generate entities in correct class loader #7831

Merged
merged 1 commit into from
Mar 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ private void enhanceEntities(final JpaEntitiesBuildItem domainObjects,
try {
byte[] bytes = IoUtil.readClassAsBytes(HibernateOrmProcessor.class.getClassLoader(), className);
byte[] enhanced = hibernateEntityEnhancer.enhance(className, bytes);
additionalClasses.produce(new GeneratedClassBuildItem(true, className, enhanced != null ? enhanced : bytes));
additionalClasses.produce(new GeneratedClassBuildItem(false, className, enhanced != null ? enhanced : bytes));
Copy link
Member

Choose a reason for hiding this comment

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

We are enhancing application classes and I don't understand why the enhanced classes should not be considered application classes?

Copy link
Member Author

Choose a reason for hiding this comment

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

These are AdditionalJpaModelBuildItem classes, that are for entities defined in extensions. If we generate them in the application class loader then you end up with two copies, one in the runtime class loader and the original unmodified one in the base runtime class loader. Normally this is ok, unless a class in the base runtime CL attempts to use the entity, in which case you get problems.

} catch (IOException e) {
throw new RuntimeException("Failed to read Model class", e);
}
Expand Down