Return-Path: X-Original-To: apmail-felix-dev-archive@www.apache.org Delivered-To: apmail-felix-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C995DD6DC for ; Wed, 21 Nov 2012 01:42:58 +0000 (UTC) Received: (qmail 17729 invoked by uid 500); 21 Nov 2012 01:42:58 -0000 Delivered-To: apmail-felix-dev-archive@felix.apache.org Received: (qmail 17563 invoked by uid 500); 21 Nov 2012 01:42:58 -0000 Mailing-List: contact dev-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list dev@felix.apache.org Received: (qmail 17488 invoked by uid 99); 21 Nov 2012 01:42:58 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Nov 2012 01:42:58 +0000 Date: Wed, 21 Nov 2012 01:42:58 +0000 (UTC) From: "Ken Gilmer (JIRA)" To: dev@felix.apache.org Message-ID: <1619526830.10249.1353462178156.JavaMail.jiratomcat@arcas> In-Reply-To: <1025574106.10877.1339559982689.JavaMail.jiratomcat@issues-vm> Subject: [jira] [Commented] (FELIX-3547) NPE in httplite on android creating Locale. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ 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