codeconsole commented on code in PR #15732:
URL: https://github.com/apache/grails-core/pull/15732#discussion_r3423083269


##########
grails-web-core/src/test/groovy/org/grails/web/servlet/HttpServletRequestExtensionSpec.groovy:
##########
@@ -105,6 +105,38 @@ class HttpServletRequestExtensionSpec extends 
Specification {
             request.getAttribute('count', Integer, 7) == 42
     }
 
+    void "Class-typed getAttribute matches proxied values — both JVM proxy 
mechanisms"() {
+        given:
+            HttpServletRequest request = new MockHttpServletRequest()
+
+            // (1) Interface proxy: a JDK dynamic proxy's runtime-generated 
class *implements* the
+            // requested interface, so isInstance(interface) is true — the 
non-obvious runtime case.
+            CharSequence jdkProxy = (CharSequence) 
java.lang.reflect.Proxy.newProxyInstance(

Review Comment:
   Fair point — updated the test to use a real ByteBuddy subclass proxy (`new 
ByteBuddy().subclass(...).make().load(...)`), the same machinery GORM/Hibernate 
use for lazy proxies. It asserts the stored value is a generated subclass 
(`proxy.class != Entity`) yet `getAttribute(name, Entity)` resolves it via 
`isInstance`, and still returns null for an unrelated type. Added 
`net.bytebuddy:byte-buddy` (BOM-managed) as a testImplementation.
   



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