felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ken Gilmer (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FELIX-3547) NPE in httplite on android creating Locale.
Date Wed, 21 Nov 2012 01:42:58 GMT

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

Ken Gilmer commented on FELIX-3547:

Patch committed in revision 1411974.  Thanks again 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

View raw message