2016-08-04 16:19 GMT+02:00 Svetlin Zarev <svetlin.angelov.za...@gmail.com>:

> Notice that when we have web beans context the array length is:
>
> final Object[] newEventListeners = new Object[appEventListeners.length +
> 2];
>
> But when the web beans context is null the new length is:
>
> final Object[] newEventListeners = new Object[appEventListeners.length +
> 1];
>
> In both cases the System.arrayCopy() starts to write from index 1, but in
> the second case (no web beans context) the array is shorter!
> I see two ways to fix that:
>
> 1. Always allocate array with size appEventListeners.length + 2
> 2. When the web beans context is null -> use start index of 0 for system
> array copy.
>
> Also please note that when the web beans context is null, the
> BeginWebBeansListener is not set to the array element with index 0!!!!
>
>
it is fixed


> -----
> I have a question: why the EndWebBeansListener is added to the listeners
> when the web beans context is null ?
>
>
Cause it also enable to push task to be executed after the request and it
is used by other part of the code than CDI


> PS: It's the very same issue with the lifecycle listeners! The case without
> CDI is broken.
>
> Kind regards,
> Svetlin
>
> 2016-08-04 16:59 GMT+03:00 Romain Manni-Bucau <rmannibu...@gmail.com>:
>
> > Ok, the issue only happens when you don't have CDI activated, a
> workaround
> > is to create an empty beans.xml in WEB-INF
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog
> > <http://rmannibucau.wordpress.com> | Github <https://github.com/
> > rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com> | JavaEE Factory
> > <https://javaeefactory-rmannibucau.rhcloud.com>
> >
> > 2016-08-04 15:40 GMT+02:00 Svetlin Zarev <svetlin.angelov.zarev@gmail.
> com
> > >:
> >
> > > Thanks, I've created a JIRA issue and also attached a sample
> application
> > > that demonstrates the issue:
> > > https://issues.apache.org/jira/browse/TOMEE-1896
> > >
> > > 2016-08-04 16:25 GMT+03:00 Romain Manni-Bucau <rmannibu...@gmail.com>:
> > >
> > > > Best is either JIRA with a patch or github with a pull request. In
> both
> > > > cases ensure to provide a test case reproducing the issue you think
> you
> > > > spotted
> > > >
> > > > You probably missed the line just before the arraycopy which init the
> > > first
> > > > index and the copy starts from index 1 so all is done as expected I
> > > think.
> > > >
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > <https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog
> > > > <http://rmannibucau.wordpress.com> | Github <
> > > > https://github.com/rmannibucau> |
> > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > <http://www.tomitribe.com> | JavaEE Factory
> > > > <https://javaeefactory-rmannibucau.rhcloud.com>
> > > >
> > > > 2016-08-04 15:22 GMT+02:00 Svetlin Zarev
> <svetlin.angelov.zarev@gmail.
> > > com
> > > > >:
> > > >
> > > > > Hi,
> > > > >
> > > > > > we set the first and last listeners so it looks right.
> > > > >
> > > > > Notice the initial index of the destination array in the
> > > > System.arraycopy()
> > > > > call. You start from index 1 -> the first element in the new array
> is
> > > > NULL
> > > > > and last one gets overwritten by:
> > > > >
> > > > > newEventListeners[newEventListeners.length - 1] =
> > endWebBeansListener;
> > > > >
> > > > >
> > > > > But if you System.arraycopy() to the destination array with start
> > index
> > > > of
> > > > > 0, the first element of the array will not be NULL, but will
> contain
> > > the
> > > > > first listener as expected. In that case the last element will be
> > NULL
> > > > and
> > > > >
> > > > > newEventListeners[newEventListeners.length - 1] =
> > endWebBeansListener;
> > > > >
> > > > > will not overwrite anything.
> > > > >
> > > > > PS: Is there a better place to report such issues ? Does someone
> > > monitor
> > > > > the github mirror, so I can make pull request which are much easier
> > to
> > > > > review as they have more context ?
> > > > >
> > > > > Kind regards,
> > > > > Svetlin
> > > > >
> > > >
> > >
> >
>

Reply via email to