myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gerhard Petracek <gerhard.petra...@gmail.com>
Subject Re: [MyFaces 2.2] invoke @PreDestroy on (CDI) ViewScoped beans upon session expiration
Date Fri, 18 Oct 2013 20:22:11 GMT
hi howard,

your test confirmed what i saw recently -> we have already what i planned
to do (the confirmation of the issue).

regards,
gerhard

http://www.irian.at

Your JSF/JavaEE powerhouse -
JavaEE Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces



2013/10/18 Howard W. Smith, Jr. <smithh032772@gmail.com>

> Cool! If your test works against Leonardo's latest changes/fixes, please
> post/share your test results (and test steps). Thanks!
>
>
> On Fri, Oct 18, 2013 at 3:45 PM, Gerhard Petracek <
> gerhard.petracek@gmail.com> wrote:
>
> > hi howard,
> >
> > i just planned a short (re-)test for starting a discussion like this one.
> >
> > regards,
> > gerhard
> >
> > http://www.irian.at
> >
> > Your JSF/JavaEE powerhouse -
> > JavaEE Consulting, Development and
> > Courses in English and German
> >
> > Professional Support for Apache MyFaces
> >
> >
> > 2013/10/18 Howard W. Smith, Jr. <smithh032772@gmail.com>
> >
> > > Gerhard, you're welcome. since i don't have bandwidth (right now),
> > > maybe/hopefully, you can develop test case(s) per what we're
> > > discussing/testing/reporting here...if you have bandwidth to do so. :)
> > >
> > >
> > > On Fri, Oct 18, 2013 at 5:14 AM, Gerhard Petracek <
> > > gerhard.petracek@gmail.com> wrote:
> > >
> > > > @howard:
> > > > that's one of the issues i mentioned during the discussion for
> > > MYFACES-3797
> > > > and i was going to test it tomorrow.
> > > > -> thx for testing it and starting this thread.
> > > >
> > > > regards,
> > > > gerhard
> > > >
> > > > http://www.irian.at
> > > >
> > > > Your JSF/JavaEE powerhouse -
> > > > JavaEE Consulting, Development and
> > > > Courses in English and German
> > > >
> > > > Professional Support for Apache MyFaces
> > > >
> > > >
> > > >
> > > > 2013/10/18 Leonardo Uribe <lu4242@gmail.com>
> > > >
> > > > > Hi
> > > > >
> > > > > You can check here:
> > > > >
> > > > >
> > >
> https://builds.apache.org/view/M-R/view/MyFaces/job/myfaces-current22-1/
> > > > >
> > > > > As soon as the job (#1164) is done, you can take the jars from that
> > > > > location (which should be the same).
> > > > >
> > > > > regards,
> > > > >
> > > > > Leonardo Uribe
> > > > >
> > > > >
> > > > > 2013/10/17 Howard W. Smith, Jr. <smithh032772@gmail.com>
> > > > >
> > > > > > Okay, that is great. I'm waiting for the following folders to
be
> > > > updated
> > > > > > with the latest version:
> > > > > >
> > > > > > 1.
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://repository.apache.org/content/repositories/snapshots/org/apache/myfaces/core/myfaces-api/2.2.0-SNAPSHOT/
> > > > > >
> > > > > > 2.
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://repository.apache.org/content/repositories/snapshots/org/apache/myfaces/core/myfaces-impl/2.2.0-SNAPSHOT/
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > On Thu, Oct 17, 2013 at 10:47 PM, Leonardo Uribe <
> lu4242@gmail.com
> > >
> > > > > wrote:
> > > > > >
> > > > > > > Hi
> > > > > > >
> > > > > > > I have found the bug. The problem was caused on a refactor,
> there
> > > was
> > > > > an
> > > > > > > old code that skip state saving when view map is empty,
but now
> > > since
> > > > > > there
> > > > > > > is a proxy for that implementing StateHolder, the map can
be
> > empty
> > > > but
> > > > > it
> > > > > > > holds the view scope key. Since with CDI the beans are
stored
> > > > > internally,
> > > > > > > the map keeps empty but the scope is not, and if the view
scope
> > key
> > > > is
> > > > > > lost
> > > > > > > the bean is recreated every time. But the beans are still
in
> > > session,
> > > > > and
> > > > > > > with the session timeout bug the final result is @PreDestroy
is
> > not
> > > > > > called.
> > > > > > >
> > > > > > > Please try again with the latest code, it should work.
And
> please
> > > > lets
> > > > > us
> > > > > > > know what happened, if it is working or not.
> > > > > > >
> > > > > > > regards,
> > > > > > >
> > > > > > > Leonardo Uribe
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > 2013/10/17 Leonardo Uribe <lu4242@gmail.com>
> > > > > > >
> > > > > > > > Hi
> > > > > > > >
> > > > > > > > I have committed a fix for the problem with the timeout.
But
> > I'm
> > > > > > curious
> > > > > > > > about this problem, because I tested this scope and
> > specifically
> > > > the
> > > > > > > > @PreDestroy stuff. It should work. But maybe there
is a bug
> > > > > > somewhere....
> > > > > > > >
> > > > > > > > regards,
> > > > > > > >
> > > > > > > > Leonardo Uribe
> > > > > > > >
> > > > > > > >
> > > > > > > > 2013/10/17 Howard W. Smith, Jr. <smithh032772@gmail.com>
> > > > > > > >
> > > > > > > >> responses inline below,
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >> On Thu, Oct 17, 2013 at 9:32 PM, Leonardo Uribe
<
> > > lu4242@gmail.com
> > > > >
> > > > > > > wrote:
> > > > > > > >>
> > > > > > > >> >
> > > > > > > >> >     public void onSessionDestroyed()
> > > > > > > >> >     {
> > > > > > > >> >         // In CDI case, the best way to deal
with this is
> > use
> > > a
> > > > > > method
> > > > > > > >> >         // with @PreDestroy annotation on
a session scope
> > bean
> > > > > > > >> >         // ( ViewScopeBeanHolder.destroyBeans()
). There
> is
> > no
> > > > > need
> > > > > > > >> >         // to do anything else in this location,
but it is
> > > > advised
> > > > > > > >> >         // in CDI the beans are destroyed
at the end of
> the
> > > > > request,
> > > > > > > >> >         // not when invalidateSession() is
called.
> > > > > > > >> >         FacesContext facesContext =
> > > > > > FacesContext.getCurrentInstance();
> > > > > > > >> >         if (facesContext != null)
> > > > > > > >> >         {
> > > > > > > >> >
> > > > > > > >> > I suppose what's going on there is in the
context the
> > session
> > > > > > > >> invalidation
> > > > > > > >> > is done, FacesContext is null and @PreDestroy
is ignored.
> > > > > > > >> >
> > > > > > > >>
> > > > > > > >> I can agree with that.
> > > > > > > >>
> > > > > > > >>
> > > > > > > >> >
> > > > > > > >> > To be clear two questions:
> > > > > > > >> >
> > > > > > > >> > 1. Is manual session expiration working ?
I suppose yes.
> > > > > > > >> >
> > > > > > > >>
> > > > > > > >> hmmm does manual session expiration ==
> > HttpSession.invalidate()?
> > > > > > > >>
> > > > > > > >> When user click Logout button, my app execute/triggers
> > > > > > > >> HttpSession.invalidate(), and @PreDestroy (on
CDI
> @ViewScoped
> > > > bean)
> > > > > is
> > > > > > > not
> > > > > > > >> executed.
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >> > 2. Is session invalidation by a timeout working
? I
> suppose
> > > no.
> > > > > > > >> >
> > > > > > > >>
> > > > > > > >> correct, I just verified that in my app. see below.
> > > > > > > >>
> > > > > > > >> - navigated to page that reference CDI @ViewScoped
bean,
> > > > > > @PostConstruct
> > > > > > > >> (below) executed
> > > > > > > >>
> > > > > > > >> Oct 17, 2013 9:45:18 PM jsf.orders.OrderDocumentBean
init
> > > > > > > >> INFO: jsf.orders.OrderDocumentBean@a9faef9
> > > > > > > >>
> > > > > > > >> changed web.xml, session timeout = 1 minute, so
tomee ended
> > > > session
> > > > > > > >> via/after timeout, and @PreDestroy on CDI @SessionScoped
> > (below)
> > > > > > > executed,
> > > > > > > >>
> > > > > > > >> Oct 17, 2013 9:45:53 PM jsf.users.pf_UsersController
> > > > sessionTimeout
> > > > > > > >> INFO: administrator session ended at 10/17/2013
09:45 PM
> > > > > > > >>
> > > > > > > >> but @PreDestroy on CDI @ViewScoped bean was not
executed
> > > > > > > >>
> > > > > > > >>
> > > > > > > >> I will try to provide an example to test.
> > > > > > > >>
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message