matrei commented on code in PR #16093:
URL: https://github.com/apache/grails-core/pull/16093#discussion_r4133334898


##########
grails-testing-support-core/src/main/groovy/org/grails/testing/ParameterizedGrailsUnitTest.groovy:
##########
@@ -47,12 +47,16 @@ trait ParameterizedGrailsUnitTest<T> extends GrailsUnitTest 
{
             def cutType = getTypeUnderTest()
             if (cutType != null) {
                 mockArtefact(cutType)
-                final String beanName = getBeanName(cutType)
+                def beanName = getBeanName(cutType)
                 if (beanName != null && 
applicationContext.containsBean(beanName)) {
-                    _artefactInstance = applicationContext.getBean(beanName, T)
+                    _artefactInstance = applicationContext.getBean(beanName, 
cutType)
                 } else {
-                    _artefactInstance = cutType.newInstance()

Review Comment:
   Good catch, you're right. The old `T` literal erased to `Object.class`, so 
any bean under that name was accepted, and `cutType.newInstance()` went through 
Groovy's `DefaultGroovyMethods`, which can call non-public constructors. 
Neither was intended in this PR, so I've restored the original behaviour and 
kept only the typing, and added a regression spec for the constructor case.



-- 
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]

Reply via email to