[seam-issues] [JBoss JIRA] (SOLDER-302) @Inject @CookiePram throws NullPointerException if the client browser does not send any cookie.CookieParamProducer and ImplicitHttpServletObjectsProducer implementations are broken.

Assen Todorov (Updated) (JIRA) jira-events at lists.jboss.org
Fri Nov 11 13:48:45 EST 2011


     [ https://issues.jboss.org/browse/SOLDER-302?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Assen Todorov updated SOLDER-302:
---------------------------------

        Summary: @Inject @CookiePram throws NullPointerException if the client browser does not send any cookie.CookieParamProducer and ImplicitHttpServletObjectsProducer implementations are broken.  (was: @Inject @CookiePram throws NullPointerException if the client browser does not send any cookie.CookieParamProducer implementation broken.)
    Description: 
The following code snippet throws a NullPointerException if the client does not send any cookie.
{code}
@Inject
@CookieParam("lang")
@DefaultValue("en")
private Instance<String> languageResolver;
...
final String language = languageResolver.get();
{code}

The problem is in org.jboss.seam.servlet.http.CookieParamProducer.getCookieValue()
{code:title=CookieParamProducer.java}
for (Cookie c : request.getCookies()) {
{code}

The servlet specification says the following about HttpServletRequest.getCookies():
{quote}
Returns an array containing all of the Cookie objects the client sent with this request. This method returns null if no cookies were sent.
{quote}

So CookieParamProducer.java throws NullPointerException when it try to iterate over NULL.

org.jboss.seam.servlet.http.CookieParamProducer.getCookie() and org.jboss.seam.servlet.http.ImplicitHttpServletObjectsProducer.getCookies() are also broken because of the same reason.

  was:
The following code snippet throws a NullPointerException if the client does not send any cookie.
{code}
@Inject
@CookieParam("lang")
@DefaultValue("en")
private Instance<String> languageResolver;
...
final String language = languageResolver.get();
{code}

The problem is in org.jboss.seam.servlet.http.CookieParamProducer.getCookieValue()
{code:title=CookieParamProducer.java}
for (Cookie c : request.getCookies()) {
{code}

The servlet specification says the following about HttpServletRequest.getCookies():
{quote}
Returns an array containing all of the Cookie objects the client sent with this request. This method returns null if no cookies were sent.
{quote}

So CookieParamProducer.java throws NullPointerException when it try to iterate over NULL.

org.jboss.seam.servlet.http.CookieParamProducer.getCookie() is also broken because of the same reason.


    
> @Inject @CookiePram throws NullPointerException if the client browser does not send any cookie.CookieParamProducer and ImplicitHttpServletObjectsProducer implementations are broken.
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: SOLDER-302
>                 URL: https://issues.jboss.org/browse/SOLDER-302
>             Project: Seam Solder
>          Issue Type: Bug
>          Components: Servlet
>    Affects Versions: 3.0.0.Final
>         Environment: CentOS
>            Reporter: Assen Todorov
>             Fix For: 3.1.0.Final
>
>
> The following code snippet throws a NullPointerException if the client does not send any cookie.
> {code}
> @Inject
> @CookieParam("lang")
> @DefaultValue("en")
> private Instance<String> languageResolver;
> ...
> final String language = languageResolver.get();
> {code}
> The problem is in org.jboss.seam.servlet.http.CookieParamProducer.getCookieValue()
> {code:title=CookieParamProducer.java}
> for (Cookie c : request.getCookies()) {
> {code}
> The servlet specification says the following about HttpServletRequest.getCookies():
> {quote}
> Returns an array containing all of the Cookie objects the client sent with this request. This method returns null if no cookies were sent.
> {quote}
> So CookieParamProducer.java throws NullPointerException when it try to iterate over NULL.
> org.jboss.seam.servlet.http.CookieParamProducer.getCookie() and org.jboss.seam.servlet.http.ImplicitHttpServletObjectsProducer.getCookies() are also broken because of the same reason.

--
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