likely yes, but as i said: if we change it, we have to test it on every version/cdi container.
2015-03-26 18:39 GMT+01:00 Lars-Fredrik Smedberg <[email protected]>: > @Thomas and also remove the isActive call I guess? > On Mar 26, 2015 5:59 PM, "Thomas Andraschko" <[email protected]> > wrote: > > > Hi, > > > > i just added the null check to get sure. > > Removing the check + adding a unit test for it would be a better way. > > > > > > 2015-03-26 17:45 GMT+01:00 Lars-Fredrik Smedberg <[email protected]>: > > > > > Hi > > > > > > Curious, I saw the following in the ContextUtils sourcecode when I was > > > looking for some ideas to solve a problem.... > > > > > > public static boolean isContextActive(Class<? extends Annotation> > > > scopeAnnotationClass, BeanManager beanManager) > > > { > > > try > > > { > > > if (beanManager.getContext(scopeAnnotationClass) == null > > > || > > > !beanManager.getContext(scopeAnnotationClass).isActive()) > > > { > > > return false; > > > } > > > } > > > catch (ContextNotActiveException e) > > > { > > > return false; > > > } > > > > > > return true; > > > } > > > > > > When I looked at the documentation for BeanManager I saw that > getContext > > > always returns a Context or throw a ContextNotActiveException (amongst > > > other exceptions), so the null check should not be needed or? > > > > > > The documenation also mention that the getContext method always return > an > > > active context... > > > > > > Is the code there to solve some compatibility issues or for other > > > historical reasons or should it read (or similar): > > > > > > public static boolean isContextActive(Class<? extends Annotation> > > > scopeAnnotationClass, BeanManager beanManager) > > > { > > > try > > > { > > > beanManager.getContext(scopeAnnotationClass); > > > return true; > > > } > > > catch (ContextNotActiveException e) > > > { > > > return false; > > > } > > > } > > > > > > Regards > > > LF > > > > > >
