From larry.streepy at raptorx.org Thu Jun 9 16:53:54 2016 From: larry.streepy at raptorx.org (Larry Streepy) Date: Thu, 9 Jun 2016 15:53:54 -0500 Subject: [weld-dev] Failures on private observer methods on beans with decorators Message-ID: <02a501d1c291$092bb1c0$1b831540$@raptorx.org> I'm just now trying to upgrade to Weld 3.0.0 Alpha 16 (from Alpha10) and I'm finding a significant change in the way the proxies are generated. This seems to be the result of this ticket: https://issues.jboss.org/browse/WELD-2092 In short, it seems that decorated beans that have private methods that @Observe events are invoked on the wrong instance. They get invoked on an uninitialized proxy instance instead of the properly initialized bean instance. I'm still working to put together a small project that reproduces this problem, but that may take me until tomorrow. My actual project is too large. Has anyone else reported this type of problem? Where an @ApplicationScope bean with a decorator and a private method with arguments that @Observe some event are invoked on the wrong object instance? In this case, I'm enabling RunnableDecorator, and one of my AppScope beans implements Runnable, and it has a private observer method. I did my best to search for any other posts on this problem, but didn't find anything relevant (other than the JIRA ticket I referenced above). Thanks, Larry. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20160609/e2635c89/attachment.html From larry.streepy at raptorx.org Thu Jun 9 18:36:35 2016 From: larry.streepy at raptorx.org (Larry Streepy) Date: Thu, 9 Jun 2016 17:36:35 -0500 Subject: [weld-dev] Example project to show private observer failure with decorator Message-ID: <02cd01d1c29f$61b86c80$25294580$@raptorx.org> The attached project (maven and intellij) exhibits the problem with private observer methods when an App scoped bean is decorated. You can rung it from IJ, or from the command line using: mvn compile exec:java -Dexec.mainClass=Main As delivered, you should see output like the following: doSomething decorator, delegate=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 doSomething, this=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 , anInt=5 Got event, this=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_Weld$Proxy$@49139829 <= should be org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass Got event, anInt=0 <= should be 5 Note the "anInt=0" where it should be 5. If you change AppScopeBean#observer from 'private' to 'protected' you will see output like this: doSomething decorator, delegate=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 doSomething, this=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 , anInt=5 Got event, this=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 <= should be org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass Got event, anInt=5 <= should be 5 Note that in the latter case, the member variable is properly initialized. The problem stems from the fact that the proxy implementation doesn't include the private methods. I think that the changes included in https://issues.jboss.org/browse/WELD-2092 have broken decorated beans with private observer methods. It also hinders tests that use things like JMockit Deencapsulation to invoke private methods on bean instances. I don't know how this all reconciles with the CDI spec, but the current implementation seems broken if I can't have a private observer method simply because the class is the target of a Decorator. Thanks for taking the time to review this post. Larry. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20160609/703b8222/attachment-0001.html -------------- next part -------------- A non-text attachment was scrubbed... Name: TestProxy.zip Type: application/x-zip-compressed Size: 14251 bytes Desc: not available Url : http://lists.jboss.org/pipermail/weld-dev/attachments/20160609/703b8222/attachment-0001.bin From manovotn at redhat.com Fri Jun 10 01:26:57 2016 From: manovotn at redhat.com (Matej Novotny) Date: Fri, 10 Jun 2016 01:26:57 -0400 (EDT) Subject: [weld-dev] Example project to show private observer failure with decorator In-Reply-To: <02cd01d1c29f$61b86c80$25294580$@raptorx.org> References: <02cd01d1c29f$61b86c80$25294580$@raptorx.org> Message-ID: <1399264922.58200596.1465536417974.JavaMail.zimbra@redhat.com> Hi, thanks for your report and for the reproducer. We will take a look at it and get back to you soon. As for WELD-2092, that cannot be the cause of this behaviour because it was added in Alpha15 and your reproducer breaks with Alpha14 already. Matej ----- Original Message ----- > From: "Larry Streepy" > To: weld-dev at lists.jboss.org > Sent: Friday, June 10, 2016 12:36:35 AM > Subject: [weld-dev] Example project to show private observer failure with decorator > > > > The attached project (maven and intellij) exhibits the problem with private > observer methods when an App scoped bean is decorated. > > > > You can rung it from IJ, or from the command line using: mvn compile > exec:java -Dexec.mainClass=Main > > > > As delivered, you should see output like the following: > > > > doSomething decorator, > delegate=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 > > doSomething, > this=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 , > anInt=5 > > Got event, > this=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_Weld$Proxy$@49139829 <= > should be org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass > > Got event, anInt=0 <= should be 5 > > > > Note the ?anInt=0? where it should be 5. If you change AppScopeBean#observer > from ?private? to ?protected? you will see output like this: > > > > doSomething decorator, > delegate=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 > > doSomething, > this=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 , > anInt=5 > > Got event, > this=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 <= > should be org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass > > Got event, anInt=5 <= should be 5 > > > > Note that in the latter case, the member variable is properly initialized. > The problem stems from the fact that the proxy implementation doesn?t > include the private methods. I think that the changes included in > https://issues.jboss.org/browse/WELD-2092 have broken decorated beans with > private observer methods. It also hinders tests that use things like JMockit > Deencapsulation to invoke private methods on bean instances. > > > > I don?t know how this all reconciles with the CDI spec, but the current > implementation seems broken if I can?t have a private observer method simply > because the class is the target of a Decorator. > > > > Thanks for taking the time to review this post. > > > > Larry. > > > > _______________________________________________ > weld-dev mailing list > weld-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/weld-dev From manovotn at redhat.com Fri Jun 10 02:22:51 2016 From: manovotn at redhat.com (Matej Novotny) Date: Fri, 10 Jun 2016 02:22:51 -0400 (EDT) Subject: [weld-dev] Example project to show private observer failure with decorator In-Reply-To: <1399264922.58200596.1465536417974.JavaMail.zimbra@redhat.com> References: <02cd01d1c29f$61b86c80$25294580$@raptorx.org> <1399264922.58200596.1465536417974.JavaMail.zimbra@redhat.com> Message-ID: <1229063318.58203929.1465539771929.JavaMail.zimbra@redhat.com> Alright, we have pinpointed the cause. It is a regression introduced by fix for WELD-2042. We have created an issue to track this problem - https://issues.jboss.org/browse/WELD-2179 Keep an eye on that issue so that you know once it is resolved. Matej ----- Original Message ----- > From: "Matej Novotny" > To: "Larry Streepy" > Cc: weld-dev at lists.jboss.org > Sent: Friday, June 10, 2016 7:26:57 AM > Subject: Re: [weld-dev] Example project to show private observer failure with decorator > > Hi, > > thanks for your report and for the reproducer. We will take a look at it and > get back to you soon. > > As for WELD-2092, that cannot be the cause of this behaviour because it was > added in Alpha15 > and your reproducer breaks with Alpha14 already. > > Matej > > > ----- Original Message ----- > > From: "Larry Streepy" > > To: weld-dev at lists.jboss.org > > Sent: Friday, June 10, 2016 12:36:35 AM > > Subject: [weld-dev] Example project to show private observer failure with > > decorator > > > > > > > > The attached project (maven and intellij) exhibits the problem with private > > observer methods when an App scoped bean is decorated. > > > > > > > > You can rung it from IJ, or from the command line using: mvn compile > > exec:java -Dexec.mainClass=Main > > > > > > > > As delivered, you should see output like the following: > > > > > > > > doSomething decorator, > > delegate=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 > > > > doSomething, > > this=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 , > > anInt=5 > > > > Got event, > > this=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_Weld$Proxy$@49139829 <= > > should be org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass > > > > Got event, anInt=0 <= should be 5 > > > > > > > > Note the ?anInt=0? where it should be 5. If you change > > AppScopeBean#observer > > from ?private? to ?protected? you will see output like this: > > > > > > > > doSomething decorator, > > delegate=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 > > > > doSomething, > > this=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 , > > anInt=5 > > > > Got event, > > this=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 <= > > should be org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass > > > > Got event, anInt=5 <= should be 5 > > > > > > > > Note that in the latter case, the member variable is properly initialized. > > The problem stems from the fact that the proxy implementation doesn?t > > include the private methods. I think that the changes included in > > https://issues.jboss.org/browse/WELD-2092 have broken decorated beans with > > private observer methods. It also hinders tests that use things like > > JMockit > > Deencapsulation to invoke private methods on bean instances. > > > > > > > > I don?t know how this all reconciles with the CDI spec, but the current > > implementation seems broken if I can?t have a private observer method > > simply > > because the class is the target of a Decorator. > > > > > > > > Thanks for taking the time to review this post. > > > > > > > > Larry. > > > > > > > > _______________________________________________ > > weld-dev mailing list > > weld-dev at lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/weld-dev > > _______________________________________________ > weld-dev mailing list > weld-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/weld-dev From manovotn at redhat.com Fri Jun 10 02:25:54 2016 From: manovotn at redhat.com (Matej Novotny) Date: Fri, 10 Jun 2016 02:25:54 -0400 (EDT) Subject: [weld-dev] Example project to show private observer failure with decorator In-Reply-To: <1229063318.58203929.1465539771929.JavaMail.zimbra@redhat.com> References: <02cd01d1c29f$61b86c80$25294580$@raptorx.org> <1399264922.58200596.1465536417974.JavaMail.zimbra@redhat.com> <1229063318.58203929.1465539771929.JavaMail.zimbra@redhat.com> Message-ID: <1774635704.58204131.1465539954061.JavaMail.zimbra@redhat.com> Correction: I meant to say is is caused by fix for WELD-2043 ----- Original Message ----- > From: "Matej Novotny" > To: "Larry Streepy" > Cc: weld-dev at lists.jboss.org > Sent: Friday, June 10, 2016 8:22:51 AM > Subject: Re: [weld-dev] Example project to show private observer failure with decorator > > Alright, we have pinpointed the cause. > It is a regression introduced by fix for WELD-2042. > We have created an issue to track this problem - > https://issues.jboss.org/browse/WELD-2179 > Keep an eye on that issue so that you know once it is resolved. > > Matej > > ----- Original Message ----- > > From: "Matej Novotny" > > To: "Larry Streepy" > > Cc: weld-dev at lists.jboss.org > > Sent: Friday, June 10, 2016 7:26:57 AM > > Subject: Re: [weld-dev] Example project to show private observer failure > > with decorator > > > > Hi, > > > > thanks for your report and for the reproducer. We will take a look at it > > and > > get back to you soon. > > > > As for WELD-2092, that cannot be the cause of this behaviour because it was > > added in Alpha15 > > and your reproducer breaks with Alpha14 already. > > > > Matej > > > > > > ----- Original Message ----- > > > From: "Larry Streepy" > > > To: weld-dev at lists.jboss.org > > > Sent: Friday, June 10, 2016 12:36:35 AM > > > Subject: [weld-dev] Example project to show private observer failure with > > > decorator > > > > > > > > > > > > The attached project (maven and intellij) exhibits the problem with > > > private > > > observer methods when an App scoped bean is decorated. > > > > > > > > > > > > You can rung it from IJ, or from the command line using: mvn compile > > > exec:java -Dexec.mainClass=Main > > > > > > > > > > > > As delivered, you should see output like the following: > > > > > > > > > > > > doSomething decorator, > > > delegate=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 > > > > > > doSomething, > > > this=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 > > > , > > > anInt=5 > > > > > > Got event, > > > this=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_Weld$Proxy$@49139829 > > > <= > > > should be org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass > > > > > > Got event, anInt=0 <= should be 5 > > > > > > > > > > > > Note the ?anInt=0? where it should be 5. If you change > > > AppScopeBean#observer > > > from ?private? to ?protected? you will see output like this: > > > > > > > > > > > > doSomething decorator, > > > delegate=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 > > > > > > doSomething, > > > this=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 > > > , > > > anInt=5 > > > > > > Got event, > > > this=org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass at 4550bb58 > > > <= > > > should be org.jboss.weld.proxies.AppScopeBean$Proxy$_$$_WeldSubclass > > > > > > Got event, anInt=5 <= should be 5 > > > > > > > > > > > > Note that in the latter case, the member variable is properly > > > initialized. > > > The problem stems from the fact that the proxy implementation doesn?t > > > include the private methods. I think that the changes included in > > > https://issues.jboss.org/browse/WELD-2092 have broken decorated beans > > > with > > > private observer methods. It also hinders tests that use things like > > > JMockit > > > Deencapsulation to invoke private methods on bean instances. > > > > > > > > > > > > I don?t know how this all reconciles with the CDI spec, but the current > > > implementation seems broken if I can?t have a private observer method > > > simply > > > because the class is the target of a Decorator. > > > > > > > > > > > > Thanks for taking the time to review this post. > > > > > > > > > > > > Larry. > > > > > > > > > > > > _______________________________________________ > > > weld-dev mailing list > > > weld-dev at lists.jboss.org > > > https://lists.jboss.org/mailman/listinfo/weld-dev > > > > _______________________________________________ > > weld-dev mailing list > > weld-dev at lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/weld-dev > > _______________________________________________ > weld-dev mailing list > weld-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/weld-dev