Uninitialized Static Parser Fields Causes Class Cast & Null Pointer Exceptions
------------------------------------------------------------------------------

                 Key: MIME4J-200
                 URL: https://issues.apache.org/jira/browse/MIME4J-200
             Project: JAMES Mime4j
          Issue Type: Bug
          Components: parser (core)
    Affects Versions: 0.6.1
         Environment: Linux & Windows in Java 
            Reporter: Rickard Ekeroth


The main problem is that e.g. the class ContentTypeField contains a static 
variable called 'PARSER' which is used by the class DefaultFieldParser. An 
instance of DefaultFieldParser is created and stored in a static variable in 
the class AbstractField. The class AbstractField is the base class of the class 
ContentTypeField. The effect of this is that under certain circumstances (since 
the static initialization in the base class happens first) the static variable 
'PARSER' will be null (not yet initialized) when the class created in the base 
class reads the value of it.

The above description is valid for all the different field classes that have a 
static 'PARSER' variable in them.

This does not always manifest itself since it seems that in certain 
combinations of Java versions and/or operating systems the static variable 
initialization in the same inheritance hierarchy works differently.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to