You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Ken Gilmer (JIRA)" <ji...@apache.org> on 2012/11/20 14:36:58 UTC

[jira] [Commented] (FELIX-3547) NPE in httplite on android creating Locale.

    [ https://issues.apache.org/jira/browse/FELIX-3547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13501185#comment-13501185 ] 

Ken Gilmer commented on FELIX-3547:
-----------------------------------

I'm sorry but I did not see this when it was filed in June.  I will work on getting it resolved in SVN ASAP, and thanks for the patch Ed!
                
> NPE in httplite on android creating Locale.
> -------------------------------------------
>
>                 Key: FELIX-3547
>                 URL: https://issues.apache.org/jira/browse/FELIX-3547
>             Project: Felix
>          Issue Type: Bug
>          Components: Lightweight HTTP Service
>         Environment: Android 2.3.x
>            Reporter: Ed Schaller
>            Assignee: Ken Gilmer
>              Labels: patch
>         Attachments: HttpServletRequestImpl.3547.patch
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> httplite/core/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java contains the following at line 86:
> private final Locale m_locale = new Locale( System.getProperty( "user.language" ), System.getProperty( "user.country" ) );
> On Android (at least 2.3, other versions not tried) this produces a NullPointerException when HttpServletRequestImpl is constructed because the Locale constructor cannot handle null and neither property is defined by default on Android.
> This is trivial to work around with code like:
> if(System.getProperty("user.language")==null)
>         System.setProperty("user.language", Locale.getDefault().getLanguage());
> if(System.getProperty("user.country")==null)
>         System.setProperty("user.country", Locale.getDefault().getCountry());
> A easy solution is to replace the above line with:
> private final Locale m_locale = Locale.getDefault();
> This would cause each instance to have the same Local object. Although I would be surprised if this is an issue the following would also work:
> private final Locale m_locale = new Locale( System.getProperty( "user.language", Locale.getDefault().getLanguage() ), System.getProperty( "user.country" ) , Locale.getDefault().getCountry());
> I'm using httplite with the felx web console for debugging. Other than this bug and needing to set an uncaught exception handler so android doesn't force close the app all is working well (the memory usage plugin of coarse dose not work because it depends on jmx which android doesn't have.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira