Skip to content

Conversation

@Sanne
Copy link
Member

@Sanne Sanne commented Jan 18, 2023

@Sanne
Copy link
Member Author

Sanne commented Jan 19, 2023

@yrodiere would you like to review this one?

Copy link
Member

@yrodiere yrodiere left a comment

Choose a reason for hiding this comment

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

Well that does looks dangerous, but I guess we like to live dangerously :) A few comments below.

By the way, does this also solve https://hibernate.atlassian.net/browse/HHH-12193 ?

public EnhancingClassTransformerImpl(EnhancementContext enhancementContext) {
Objects.requireNonNull( enhancementContext );
this.enhancementContext = enhancementContext;
this.bytecodeProvider = BytecodeProviderInitiator.buildDefaultBytecodeProvider();
Copy link
Member

Choose a reason for hiding this comment

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

Isn't that possibly introducing another problem? You won't be using the same bytecode provider as Hibernate ORM...

But I must admit I don't know what this class is used for anyway :/

Copy link
Member Author

Choose a reason for hiding this comment

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

This is used by JPA's "enhance at deployment time" capability, used on EE servers.

And yes I'd like to make the BytecodeProvider implementation pluggable, but it really isn't today: choices are exclusively bytebuddy or none. Clearly this use case can't use none.

(there are other areas too in which it's implied that it needs to be the ByteBuddy one - I'd certainly like to improve that but I'm considering that a different issue)

Copy link
Member

Choose a reason for hiding this comment

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

And yes I'd like to make the BytecodeProvider implementation pluggable

I was thinking more that you're not using the same instance of BytecodeProvider, whereas before this patch, you were. I have no idea what kind of impact this can have, but since the bytecode provider is stateful, it might be a problem?

private final EnhancementContext enhancementContext;
private final BytecodeProvider bytecodeProvider;

public EnhancingClassTransformerImpl(EnhancementContext enhancementContext) {
Copy link
Member

@yrodiere yrodiere Jan 20, 2023

Choose a reason for hiding this comment

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

There is something weird going on.

This constructor is only ever called from here:

@Override
public void pushClassTransformer(EnhancementContext enhancementContext) {
persistenceUnitInfo.addTransformer( new EnhancingClassTransformerImpl( enhancementContext ) );
}

But then all implementations of PersistenceUnitInfo#addTransformer are no-ops...

This component is probably not being tested. I'd suggest trying your patch in WildFly before merging?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea, yes WildFly has a similar implementation but it's a different one.

//we're going to need the UUID even if we the SessionFactory configuration doesn't
// allow any operations on it, as we need it to match deserialized objects with
// the originating SessionFactory: at very least it's useful to actually get
// such configuration, so to know if such operation isn't allowed or configured otherwise.
Copy link
Member

Choose a reason for hiding this comment

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

Looks like you've changed the purpose of this method; maybe it should be renamed?

I don't know if this class is API or "looks like API but actually is not", though...

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, I've amended the javadoc to clarify.

}

private static SessionFactoryImplementor retrieveMatchingSessionFactory(final String sessionFactoryUuid) {
Objects.requireNonNull( sessionFactoryUuid );
Copy link
Member

Choose a reason for hiding this comment

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

We won't be able to deserialize entities serialized before this patch, since the uuid will be missing.

Not sure what the backwards compatibility expectations of serialization are, though.

Copy link
Member Author

Choose a reason for hiding this comment

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

The UUID was always supposed to be there in practice - I only noticed this wasn't happening consistently because we have some proxy serialization tests which were performing this while in the odd configuration of not having set the sessionFactoryUuid first.
However in a "real" scenario this would have failed as the proxy can't be initialized.

@Sanne
Copy link
Member Author

Sanne commented Jan 20, 2023

By the way, does this also solve https://hibernate.atlassian.net/browse/HHH-12193 ?

Right, thanks for finding that one.

@hibernate-github-bot
Copy link

hibernate-github-bot bot commented Jan 20, 2023

Thanks for your pull request!

This pull request appears to follow the contribution rules.

› This message was automatically generated.

@Sanne
Copy link
Member Author

Sanne commented Jan 20, 2023

pushed a reviewed version

Copy link
Member

@yrodiere yrodiere left a comment

Choose a reason for hiding this comment

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

Thanks. LGTM as long as you're confident about the impact on EnhancingClassTransformerImpl.java and WildFly.
EDIT: And serialization :)

@Sanne
Copy link
Member Author

Sanne commented Jan 20, 2023

👍 still checking WildFly, will merge if I spot no issues there.

@Sanne
Copy link
Member Author

Sanne commented Jan 20, 2023

All good on the WildFly side - if we bypass the lack of an upodated Infinispan 2LC module.

Merging

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