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

WFLY-11870 Do not process resource annotations on abstract classes or … #12217

Merged
merged 1 commit into from Apr 24, 2019

Conversation

@TomasHofman
Copy link
Contributor

TomasHofman commented Apr 10, 2019

…interfaces that do not have concrete subclasses

Issue: https://issues.jboss.org/browse/WFLY-11870
Downstream issue: https://issues.jboss.org/browse/JBEAP-16576
Related to: #11203

This issue comes from a customer case, they are unable to deploy an application to EAP 7.2, which was deployable on EAP 7.1.

The point is that their deployment contains abstract class with @ejb annotated field referencing an interface:

public abstract class AbstractReferencingBean { // doesn't have concrete subclass
    @EJB
    private ReferencedBeanInterface referencedBean; // doesn't have implementing class
}

Neither the referencing abstract class nor the referenced interface have concrete subclasses in this deployment, so theoretically they should be ignored? The deployment fails because a binding processor can't find any bean that would satisfy this injection point.

In the PR, I'm trying to prevent the resource annotations from being processed if an annotated class is an abstract class or an interface and there's no concrete subclass in the deployment.

@TomasHofman

This comment has been minimized.

Copy link
Contributor Author

TomasHofman commented Apr 10, 2019

@stuartwdouglas as this is related to #11203, could you review?

@TomasHofman

This comment has been minimized.

Copy link
Contributor Author

TomasHofman commented Apr 11, 2019

I'm temporarily closing this PR, before I verify that it's passing the TCK.

@TomasHofman TomasHofman reopened this Apr 12, 2019
@TomasHofman TomasHofman force-pushed the TomasHofman:WFLY-11870 branch from b211a9b to 546dc0d Apr 12, 2019
@TomasHofman

This comment has been minimized.

Copy link
Contributor Author

TomasHofman commented Apr 12, 2019

Passes TCK 8 on my machine.

} else {
subclasses = index.getAllKnownSubclasses(classInfo.name());
}
return subclasses.stream().anyMatch(ModuleJndiBindingProcessor::isConcreteClass);

This comment has been minimized.

Copy link
@bstansberry

bstansberry Apr 14, 2019

Contributor

Please use a for loop. The class metadata memory cost of a method reference vs a for loop is too high for us to be using this code pattern in server code.

@@ -158,6 +162,7 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
//were only intended to be installed when running as an app client
boolean appClient = DeploymentTypeMarker.isType(DeploymentType.APPLICATION_CLIENT, deploymentUnit) || this.appclient;

final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);

This comment has been minimized.

Copy link
@bstansberry

bstansberry Apr 14, 2019

Contributor

This should be inside the if (!MetadatdCompleteMarker... block.

@@ -167,6 +172,10 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
if(config.isInvalid()) {
continue;
}
ClassInfo classInfo = index.getClassByName(DotName.createSimple(config.getClassName()));

This comment has been minimized.

Copy link
@bstansberry

bstansberry Apr 14, 2019

Contributor

To ease future maintenance this needs a nice comment before it explaining why this will work; i.e. an Index contains info on all classes in a jar, and the CompositeIndex in the 'index' var aggregates all the Index objects for the jars visible to the deployment unit. So you can scan it for relationships between classes and not miss out on any.

ClassInfo classInfo = index.getClassByName(DotName.createSimple(config.getClassName()));
if (!isConcreteClass(classInfo) && !hasConcreteSubclass(index, classInfo)) {
continue;
}
final Set<BindingConfiguration> classLevelBindings = new HashSet<>(config.getBindingConfigurations());

This comment has been minimized.

Copy link
@bstansberry

bstansberry Apr 14, 2019

Contributor

I recommend moving L175-178 below this line and wrapping it in an 'if (!classLevelBindings.isEmpty())' check. The l175-178 scan is not cheap so it should be avoided whenever possible.

Copy link
Contributor

bstansberry left a comment

Please see comments above.

Thanks for checking this using the TCK!

… interfaces that do not have concrete subclasses
@TomasHofman TomasHofman force-pushed the TomasHofman:WFLY-11870 branch from 546dc0d to 9147300 Apr 15, 2019
@TomasHofman

This comment has been minimized.

Copy link
Contributor Author

TomasHofman commented Apr 15, 2019

I updated according to your comments, thanks for input!

@ivassile

This comment has been minimized.

Copy link
Contributor

ivassile commented Apr 24, 2019

@bstansberry We'll include this fix in EAP 7.2.2 if merged. Can you review the changes? Thanks!

@bstansberry bstansberry merged commit 7d4ba27 into wildfly:master Apr 24, 2019
6 checks passed
6 checks passed
Linux - JDK 11 (Pull Request) - merge TeamCity build finished
Details
Linux - JDK 8 Finished TeamCity Build WildFly / Pull Request / Linux - JDK 8 : Tests passed: 4861, ignored: 134
Details
Linux - elytron - JDK 8 (Pull Request) - merge TeamCity build finished
Details
Linux with security manager - JDK 8 Finished TeamCity Build WildFly / Pull Request / Linux SM - JDK 8 : Tests passed: 4517, ignored: 152
Details
Windows - JDK 11 Finished TeamCity Build WildFly / Pull Request / Windows - JDK 11 : Tests passed: 4852, ignored: 141
Details
Windows - JDK 8 Finished TeamCity Build WildFly / Pull Request / Windows - JDK 8 : Tests passed: 4854, ignored: 139
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.