You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "gentboy (JIRA)" <ji...@apache.org> on 2010/12/14 12:48:02 UTC
[jira] Created: (CONFIGURATION-431) Code caused NullPointer error
in XMLConfiguration
Code caused NullPointer error in XMLConfiguration
-------------------------------------------------
Key: CONFIGURATION-431
URL: https://issues.apache.org/jira/browse/CONFIGURATION-431
Project: Commons Configuration
Issue Type: Bug
Affects Versions: 1.6
Reporter: gentboy
Priority: Critical
In class XMLConfiguration there is a code structure like below:
public static void main(String[] args) {
new B();
}
static abstract class A {
A(){
print();
}
abstract void print();
}
static class B extends A{
String s = new String("asdf");
B(){
super();
}
void print(){
System.out.println(s);
}
}
While in B.print the field s is actually not initialized because it is called from the super() method.
In XMLConfiguration the not properly initialized field is registeredEntities, which will defenitly cause nullpointer in some case.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CONFIGURATION-431) Code caused NullPointer error
in XMLConfiguration
Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-431?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12971416#action_12971416 ]
Oliver Heger commented on CONFIGURATION-431:
--------------------------------------------
There are probably other classes which have the same issue. I think the problem is caused by the different constructors of AbstractFileConfiguration which already load the configuration file and call non-final methods which are overridden in subclasses.
A safe solution would be to deprecate all these constructors except for the standard constructor. Client code should create a configuration instance by calling the default constructor and then load the data in a second step.
WDYT, would this solve the problem?
> Code caused NullPointer error in XMLConfiguration
> -------------------------------------------------
>
> Key: CONFIGURATION-431
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-431
> Project: Commons Configuration
> Issue Type: Bug
> Affects Versions: 1.6
> Reporter: gentboy
> Priority: Critical
>
> In class XMLConfiguration there is a code structure like below:
> public static void main(String[] args) {
> new B();
> }
> static abstract class A {
> A(){
> print();
> }
> abstract void print();
> }
>
> static class B extends A{
> String s = new String("asdf");
> B(){
> super();
> }
>
> void print(){
> System.out.println(s);
> }
> }
> While in B.print the field s is actually not initialized because it is called from the super() method.
> In XMLConfiguration the not properly initialized field is registeredEntities, which will defenitly cause nullpointer in some case.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] [Updated] (CONFIGURATION-431) Code caused NullPointer error
in XMLConfiguration
Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-431?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Oliver Heger updated CONFIGURATION-431:
---------------------------------------
Priority: Major (was: Critical)
Fix Version/s: 2.0
Setting fix version to 2.0 because a fix would probably break binary compatibility.
> Code caused NullPointer error in XMLConfiguration
> -------------------------------------------------
>
> Key: CONFIGURATION-431
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-431
> Project: Commons Configuration
> Issue Type: Bug
> Affects Versions: 1.6
> Reporter: gentboy
> Fix For: 2.0
>
>
> In class XMLConfiguration there is a code structure like below:
> public static void main(String[] args) {
> new B();
> }
> static abstract class A {
> A(){
> print();
> }
> abstract void print();
> }
>
> static class B extends A{
> String s = new String("asdf");
> B(){
> super();
> }
>
> void print(){
> System.out.println(s);
> }
> }
> While in B.print the field s is actually not initialized because it is called from the super() method.
> In XMLConfiguration the not properly initialized field is registeredEntities, which will defenitly cause nullpointer in some case.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (CONFIGURATION-431) Code caused NullPointer error
in XMLConfiguration
Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-431?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12996804#comment-12996804 ]
Oliver Heger commented on CONFIGURATION-431:
--------------------------------------------
Any updates on this?
> Code caused NullPointer error in XMLConfiguration
> -------------------------------------------------
>
> Key: CONFIGURATION-431
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-431
> Project: Commons Configuration
> Issue Type: Bug
> Affects Versions: 1.6
> Reporter: gentboy
> Priority: Critical
>
> In class XMLConfiguration there is a code structure like below:
> public static void main(String[] args) {
> new B();
> }
> static abstract class A {
> A(){
> print();
> }
> abstract void print();
> }
>
> static class B extends A{
> String s = new String("asdf");
> B(){
> super();
> }
>
> void print(){
> System.out.println(s);
> }
> }
> While in B.print the field s is actually not initialized because it is called from the super() method.
> In XMLConfiguration the not properly initialized field is registeredEntities, which will defenitly cause nullpointer in some case.
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira