[seam-issues] [JBoss JIRA] (SOLDER-334) NullPointerException in ImplicitHttpServletObjectsProducer.getCookies if not Cookies

Thomas Frühbeck (JIRA) jira-events at lists.jboss.org
Tue Aug 14 03:51:14 EDT 2012


Thomas Frühbeck created SOLDER-334:
--------------------------------------

             Summary: NullPointerException in ImplicitHttpServletObjectsProducer.getCookies if not Cookies
                 Key: SOLDER-334
                 URL: https://issues.jboss.org/browse/SOLDER-334
             Project: Solder
          Issue Type: Bug
    Affects Versions: 3.1.0.Final
            Reporter: Thomas Frühbeck


If no Cookies in Request, request.getCookies() returns null.

>   @Produces
>   @RequestScoped
>   protected List<Cookie> getCookies() {
>       return Arrays.asList(getHttpServletRequest().getCookies());
>   }

When using the Producer, there is no possibility to identify, if cookies are set or not, the proxy will not be null:

So by simply invoking :

	@Inject
	private List<Cookie> cookies;
	
	public void handleInit(@Observes HttpServletRequest request) {
		log.info("handling Request: "+request.getRequestURI());
		if (cookies != null) {
				for (Cookie cookie : cookies) { 
					System.out.println("Found Cookie: "+cookie);
				}
        ...

I get:

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NullPointerException
	java.util.Arrays$ArrayList.<init>(Arrays.java:2842)
	java.util.Arrays.asList(Arrays.java:2828)
	org.jboss.solder.servlet.http.ImplicitHttpServletObjectsProducer.getCookies(ImplicitHttpServletObjectsProducer.java:93)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke(Method.java:601)
	org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:264)
	org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
	org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
	org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:260)
	org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:170)
	org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstance(MethodInjectionPoint.java:137)
	org.jboss.weld.bean.ProducerMethod$1.produce(ProducerMethod.java:133)
	org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:299)
	org.jboss.weld.context.AbstractContext.get(AbstractContext.java:107)
	org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:90)
	org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:104)
	org.jboss.weld.proxies.Collection$Iterable$List$1103886743$Proxy$_$$_WeldClientProxy.iterator(Collection$Iterable$List$1103886743$Proxy$_$$_WeldClientProxy.java)
	at.tfr.web.SolderEventHandler.handleInit(SolderEventHandler.java:28)
	at.tfr.web.SolderEventHandler$Proxy$_$$_WeldClientProxy.handleInit(SolderEventHandler$Proxy$_$$_WeldClientProxy.java)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke(Method.java:601)



--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the seam-issues mailing list