You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Kai Burjack (JIRA)" <ji...@apache.org> on 2008/04/24 15:05:21 UTC

[jira] Created: (LANG-429) NullPointerException (NPE) in FastDateFormat.getInstance(FastDateFormat.java:211)

NullPointerException (NPE) in FastDateFormat.getInstance(FastDateFormat.java:211)
---------------------------------------------------------------------------------

                 Key: LANG-429
                 URL: https://issues.apache.org/jira/browse/LANG-429
             Project: Commons Lang
          Issue Type: Bug
    Affects Versions: 2.2
         Environment: MS Windows XP (SP 2), Java 1.5.0 Update 11
            Reporter: Kai Burjack


Sometimes (sadly this is not reproducible) the following method call results in a NullPointerException (NPE):

Stacktrace:

java.lang.NullPointerException
        at org.apache.commons.lang.time.FastDateFormat.getInstance(FastDateFormat.java:211)
        at org.apache.commons.lang.time.DateFormatUtils.format(DateFormatUtils.java:258)
        at org.apache.commons.lang.time.DateFormatUtils.format(DateFormatUtils.java:232)

I don't know how this is actually possible, since the exception is being raised when accessing a static field 'cInstanceCache' that will be implicitly initialized...

Could this have something to do with class gc?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (LANG-429) NullPointerException (NPE) in FastDateFormat.getInstance(FastDateFormat.java:211)

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-429?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell closed LANG-429.
------------------------------

    Resolution: Duplicate

Closing with the assumption that this fixed things.

> NullPointerException (NPE) in FastDateFormat.getInstance(FastDateFormat.java:211)
> ---------------------------------------------------------------------------------
>
>                 Key: LANG-429
>                 URL: https://issues.apache.org/jira/browse/LANG-429
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 2.2
>         Environment: MS Windows XP (SP 2), Java 1.5.0 Update 11
>            Reporter: Kai Burjack
>
> Sometimes (sadly this is not reproducible) the following method call results in a NullPointerException (NPE):
> Stacktrace:
> java.lang.NullPointerException
>         at org.apache.commons.lang.time.FastDateFormat.getInstance(FastDateFormat.java:211)
>         at org.apache.commons.lang.time.DateFormatUtils.format(DateFormatUtils.java:258)
>         at org.apache.commons.lang.time.DateFormatUtils.format(DateFormatUtils.java:232)
> I don't know how this is actually possible, since the exception is being raised when accessing a static field 'cInstanceCache' that will be implicitly initialized...
> Could this have something to do with class gc?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-429) NullPointerException (NPE) in FastDateFormat.getInstance(FastDateFormat.java:211)

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12595887#action_12595887 ] 

Henri Yandell commented on LANG-429:
------------------------------------

Did 2.4 fix things Kai?

> NullPointerException (NPE) in FastDateFormat.getInstance(FastDateFormat.java:211)
> ---------------------------------------------------------------------------------
>
>                 Key: LANG-429
>                 URL: https://issues.apache.org/jira/browse/LANG-429
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 2.2
>         Environment: MS Windows XP (SP 2), Java 1.5.0 Update 11
>            Reporter: Kai Burjack
>
> Sometimes (sadly this is not reproducible) the following method call results in a NullPointerException (NPE):
> Stacktrace:
> java.lang.NullPointerException
>         at org.apache.commons.lang.time.FastDateFormat.getInstance(FastDateFormat.java:211)
>         at org.apache.commons.lang.time.DateFormatUtils.format(DateFormatUtils.java:258)
>         at org.apache.commons.lang.time.DateFormatUtils.format(DateFormatUtils.java:232)
> I don't know how this is actually possible, since the exception is being raised when accessing a static field 'cInstanceCache' that will be implicitly initialized...
> Could this have something to do with class gc?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-429) NullPointerException (NPE) in FastDateFormat.getInstance(FastDateFormat.java:211)

Posted by "Sebb (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12592053#action_12592053 ] 

Sebb commented on LANG-429:
---------------------------

I think it's possible because the cInstanceCache field is not final - see LANG-367.

Updating to version 2.4 should fix the problem.

> NullPointerException (NPE) in FastDateFormat.getInstance(FastDateFormat.java:211)
> ---------------------------------------------------------------------------------
>
>                 Key: LANG-429
>                 URL: https://issues.apache.org/jira/browse/LANG-429
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 2.2
>         Environment: MS Windows XP (SP 2), Java 1.5.0 Update 11
>            Reporter: Kai Burjack
>
> Sometimes (sadly this is not reproducible) the following method call results in a NullPointerException (NPE):
> Stacktrace:
> java.lang.NullPointerException
>         at org.apache.commons.lang.time.FastDateFormat.getInstance(FastDateFormat.java:211)
>         at org.apache.commons.lang.time.DateFormatUtils.format(DateFormatUtils.java:258)
>         at org.apache.commons.lang.time.DateFormatUtils.format(DateFormatUtils.java:232)
> I don't know how this is actually possible, since the exception is being raised when accessing a static field 'cInstanceCache' that will be implicitly initialized...
> Could this have something to do with class gc?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-429) NullPointerException (NPE) in FastDateFormat.getInstance(FastDateFormat.java:211)

Posted by "Julien Aymé (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12592064#action_12592064 ] 

Julien Aymé commented on LANG-429:
----------------------------------

Ugh, my comment came in late :-), this issue is indeed the same as LANG-37.

> NullPointerException (NPE) in FastDateFormat.getInstance(FastDateFormat.java:211)
> ---------------------------------------------------------------------------------
>
>                 Key: LANG-429
>                 URL: https://issues.apache.org/jira/browse/LANG-429
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 2.2
>         Environment: MS Windows XP (SP 2), Java 1.5.0 Update 11
>            Reporter: Kai Burjack
>
> Sometimes (sadly this is not reproducible) the following method call results in a NullPointerException (NPE):
> Stacktrace:
> java.lang.NullPointerException
>         at org.apache.commons.lang.time.FastDateFormat.getInstance(FastDateFormat.java:211)
>         at org.apache.commons.lang.time.DateFormatUtils.format(DateFormatUtils.java:258)
>         at org.apache.commons.lang.time.DateFormatUtils.format(DateFormatUtils.java:232)
> I don't know how this is actually possible, since the exception is being raised when accessing a static field 'cInstanceCache' that will be implicitly initialized...
> Could this have something to do with class gc?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-429) NullPointerException (NPE) in FastDateFormat.getInstance(FastDateFormat.java:211)

Posted by "Julien Aymé (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12592062#action_12592062 ] 

Julien Aymé commented on LANG-429:
----------------------------------

IMHO, this is rather an example of a data-race issue due to the cInstanceCache field not being final and not being synchronized in <clinit> in FastDateFormat in Lang 2.2.

I suppose that the following scenario could explain your problem:
- at least two Threads concurrently access to FastDateFormat.getInstance() method, while FastDateFormat is not being loaded by the current classloader:
- Thread A loads FastDateFormat.class, and creates cInstanceCache.
- Thread B enters the FastDateFormat.getInstance() method, BUT FastDateFormat.class is in a incoherent state (cInstanceCache is null) because of memory synchronization and/or compiler optimizations
     => this causes the NullPointerException in Thread B
- Thread A enters in FastDateFormat.getInstance() method and everything is correct.

I suggest you to upgrade to Lang 2.4 in which the cInstanceCache field has been made final, and see if this problem still occurs.

Furthermore, the semantic of final keyword has been strengthen due to JSR-133 , which is part of Java 5.
I encourage you to read the following section: http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html#finalWrong
and the Final Fields paragraph in JSR-133: http://www.cs.umd.edu/~pugh/java/memoryModel/jsr133.pdf


> NullPointerException (NPE) in FastDateFormat.getInstance(FastDateFormat.java:211)
> ---------------------------------------------------------------------------------
>
>                 Key: LANG-429
>                 URL: https://issues.apache.org/jira/browse/LANG-429
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 2.2
>         Environment: MS Windows XP (SP 2), Java 1.5.0 Update 11
>            Reporter: Kai Burjack
>
> Sometimes (sadly this is not reproducible) the following method call results in a NullPointerException (NPE):
> Stacktrace:
> java.lang.NullPointerException
>         at org.apache.commons.lang.time.FastDateFormat.getInstance(FastDateFormat.java:211)
>         at org.apache.commons.lang.time.DateFormatUtils.format(DateFormatUtils.java:258)
>         at org.apache.commons.lang.time.DateFormatUtils.format(DateFormatUtils.java:232)
> I don't know how this is actually possible, since the exception is being raised when accessing a static field 'cInstanceCache' that will be implicitly initialized...
> Could this have something to do with class gc?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-429) NullPointerException (NPE) in FastDateFormat.getInstance(FastDateFormat.java:211)

Posted by "Kai Burjack (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12592319#action_12592319 ] 

Kai Burjack commented on LANG-429:
----------------------------------

Thanks for your VERY fast answers!
I will give it a try with 2.4

> NullPointerException (NPE) in FastDateFormat.getInstance(FastDateFormat.java:211)
> ---------------------------------------------------------------------------------
>
>                 Key: LANG-429
>                 URL: https://issues.apache.org/jira/browse/LANG-429
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 2.2
>         Environment: MS Windows XP (SP 2), Java 1.5.0 Update 11
>            Reporter: Kai Burjack
>
> Sometimes (sadly this is not reproducible) the following method call results in a NullPointerException (NPE):
> Stacktrace:
> java.lang.NullPointerException
>         at org.apache.commons.lang.time.FastDateFormat.getInstance(FastDateFormat.java:211)
>         at org.apache.commons.lang.time.DateFormatUtils.format(DateFormatUtils.java:258)
>         at org.apache.commons.lang.time.DateFormatUtils.format(DateFormatUtils.java:232)
> I don't know how this is actually possible, since the exception is being raised when accessing a static field 'cInstanceCache' that will be implicitly initialized...
> Could this have something to do with class gc?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.