codeconsole opened a new pull request, #16401:
URL: https://github.com/apache/grails-core/pull/16401
`GrailsASTUtils.isSubclassOfOrImplementsInterface` and the datastore's
`AstUtils.findInterface` walk a class node's interfaces. For the first
interface that has super-interfaces of its own, they returned whatever the
search of those super-interfaces found, and never looked at the interfaces
after it:
```java
ClassNode[] childInterfaces = anInterface.getInterfaces();
if (childInterfaces != null && childInterfaces.length > 0) {
return implementsInterfaceInternal(childInterfaces, interfaceName); //
false ends the search
}
```
So a class declaring `implements Unrelated, Target`, where `Unrelated`
extends anything, was reported as not implementing `Target`. The same happened
to one reaching `Target` through an interface that extends two, when the first
of those has super-interfaces of its own. Both now search every interface.
This came up in #16399. The unit-test detection there needed a check like
this and uses Groovy's own `ClassNode#implementsInterface` instead, so this fix
is separate.
### What the callers decide
- `FactoriesFileWriter`: which classes are listed in `grails.factories` as
`ArtefactHandler` or `TraitInjector` implementations.
- `BootInitializerClassInjector`: whether a class is a
`GrailsPluginApplication`, which gets no generated boot initializer.
- `GormEntityTransformation` (through `AstUtils.findInterface`): whether a
domain class is an `RxEntity`, which gets no injected `id` and `version`.
Each would have missed a class in that position. Nothing in this repository
is in it. I compiled every module that implements `ArtefactHandler` or
`TraitInjector` before and after the change, and all 16 generated
`grails.factories` files are byte-identical.
### Validation
```text
./gradlew :grails-core:codeStyle :grails-datastore-core:codeStyle \
:grails-core:test :grails-datastore-core:test
:grails-datamapping-core:test \
:grails-web-boot:test :grails-controllers:test
:grails-test-suite-uber:test --continue
```
- New cases in `GrailsASTUtilsSpec` (the target after an interface with its
own super-interfaces, the same one level deeper, the same reached through a
superclass, plus direct and negative cases) and in `AstUtilsSpec`. Without the
fix, the three bug cases and the `findInterface` case fail, and the direct and
negative cases pass.
- 3,080 tests, 0 failures, all executed fresh: grails-core 688,
grails-datastore-core 277, grails-datamapping-core 1,333, grails-web-boot 3,
grails-controllers 203, test-suite-uber 576.
- `grails.factories` comparison: `:classes` for grails-codecs, -controllers,
-core, -datamapping-support, -domain-class, -taglib, -web-taglib,
-interceptors, -quartz, -rest-transforms, -web-core, -web-databinding and
-web-boot, before and after. 24 compile tasks re-ran against the fixed
transform, and all 16 main-source `grails.factories` files are byte-identical.
- Checkstyle and CodeNarc: no violations in either module.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]