Marko Lukša commented on Bug WELD-1498

A little more background on this issue:

the actual type of the instance is AdvancedCache, not Cache. The method Cache.getAdvancedCache() looks like this:

public AdvancedCache getAdvancedCache() {
    return this;
}

When a method of the proxied instance returns the proxied instance (i.e. return this), the Weld proxy's method handler replaces the returned value with the proxy, to prevent the bean instance from escaping.

Since the producer's return type is Cache, the proxy only implements Cache. It does not implement AdvancedCache. When getAdvancedCache() tries to return this, the method handler tries to return the proxy, which obviously results in a CCE.

Not sure what we can do about it in Weld. The example can work around this problem by either changing the producer to be @Dependent scoped, or by changing the producer's return type to AdvancedCache.

We could maybe change Weld's method handler to check if the proxy instance it tries to return is assignable to the method's return type. If it isn't, we could return the original instance instead of the proxy.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
weld-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/weld-issues

Reply via email to