You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Guangtai Liang (Created) (JIRA)" <xe...@xml.apache.org> on 2012/02/13 09:02:59 UTC

[jira] [Created] (XERCESJ-1554) An incomplete fix for the NPE bugs in IdentityConstraint.java

An incomplete fix for the NPE bugs in IdentityConstraint.java
-------------------------------------------------------------

                 Key: XERCESJ-1554
                 URL: https://issues.apache.org/jira/browse/XERCESJ-1554
             Project: Xerces2-J
          Issue Type: Bug
          Components: Other
            Reporter: Guangtai Liang
            Priority: Critical


The fix revision 320527 was aimed to remove an NPE bug on the "this.fSelector" in the method "getSelectorStr" of the file 

"/xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/IdentityConstraint.java" , but it is incomplete. 
Since the "this.fSelector" is a class field and also could be null during the run-time execution, it should also be null-checked before being dereferenced in other methods. 

The buggy code locations the same fix needs to be applied at are as bellows: 

Line 148  of the method "equals"; 

public boolean equals(IdentityConstraint id) {
        boolean areEqual = fIdentityConstraintName.equals(id.fIdentityConstraintName);
        if(!areEqual) return false;
        areEqual = fSelector.toString().equals(id.fSelector.toString());
        if(!areEqual) return false;
        areEqual = (fFieldCount == id.fFieldCount);
        if(!areEqual) return false;
        for(int i=0; i<fFieldCount; i++)
            if(!fFields[i].toString().equals(id.fFields[i].toString())) return false;
        return true;
    } // equals


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] [Commented] (XERCESJ-1554) An incomplete fix for the NPE bugs in IdentityConstraint.java

Posted by "Guangtai Liang (Commented) (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESJ-1554?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13207497#comment-13207497 ] 

Guangtai Liang commented on XERCESJ-1554:
-----------------------------------------

Please refer to the invalid schema file which was provided for reproducing the NPE issue ( https://issues.apache.org/jira/browse/XERCESJ-1078)  

The detailed description about this issue is copied here : 

"in case of an invalid schema file with the error "s4s-elt-must-match.2"
(The content of 'identity constraint' must match (annotation?, selector, field+). Not enough elements were found.) the attribute fSelector might be null and thus the method getSelectorStr() causes a NPE.

In my case, anylsing invalid schema files (as good as possible) it is important not to have this exception, so I'm working with my own patched version of Xerces2-J. It would be nice if you would fix this somewhen.

Example from schema test suite to preproduce:
msxsdtest\identityConstraint\idB059.xsd

My fix is quite simple: just check on null:

Old:
        return fSelector.toString();

New:
        return fSelector == null ? null : fSelector.toString();
"

If fSelector can be null in such case, I think the null-check should also be made before the dereference on fSelector in the method "equals". 


                
> An incomplete fix for the NPE bugs in IdentityConstraint.java
> -------------------------------------------------------------
>
>                 Key: XERCESJ-1554
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1554
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: Other
>            Reporter: Guangtai Liang
>            Priority: Critical
>              Labels: incomplete_fix, missing_fixes
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> The fix revision 320527 was aimed to remove an NPE bug on the "this.fSelector" in the method "getSelectorStr" of the file 
> "/xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/IdentityConstraint.java" , but it is incomplete. 
> Since the "this.fSelector" is a class field and also could be null during the run-time execution, it should also be null-checked before being dereferenced in other methods. 
> The buggy code locations the same fix needs to be applied at are as bellows: 
> Line 148  of the method "equals"; 
> public boolean equals(IdentityConstraint id) {
>         boolean areEqual = fIdentityConstraintName.equals(id.fIdentityConstraintName);
>         if(!areEqual) return false;
>         areEqual = fSelector.toString().equals(id.fSelector.toString());
>         if(!areEqual) return false;
>         areEqual = (fFieldCount == id.fFieldCount);
>         if(!areEqual) return false;
>         for(int i=0; i<fFieldCount; i++)
>             if(!fFields[i].toString().equals(id.fFields[i].toString())) return false;
>         return true;
>     } // equals

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] [Reopened] (XERCESJ-1554) An incomplete fix for the NPE bugs in IdentityConstraint.java

Posted by "Guangtai Liang (Reopened) (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESJ-1554?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Guangtai Liang reopened XERCESJ-1554:
-------------------------------------


Please refer to the invalid schema file which was provided for reproducing the NPE issue ( https://issues.apache.org/jira/browse/XERCESJ-1078) 

If fSelector can be null in that case, I think the null-check should also be made before the dereference on fSelector in the method "equals". 


The detailed description on this issue is copied here : 

"in case of an invalid schema file with the error "s4s-elt-must-match.2" 
(The content of 'identity constraint' must match (annotation?, selector, field+). Not enough elements were found.) the attribute fSelector might be null and thus the method getSelectorStr() causes a NPE. 

In my case, anylsing invalid schema files (as good as possible) it is important not to have this exception, so I'm working with my own patched version of Xerces2-J. It would be nice if you would fix this somewhen. 

Example from schema test suite to preproduce: 
msxsdtest\identityConstraint\idB059.xsd 

My fix is quite simple: just check on null: 

Old: 
        return fSelector.toString(); 

New: 
        return fSelector == null ? null : fSelector.toString(); 
" 

                
> An incomplete fix for the NPE bugs in IdentityConstraint.java
> -------------------------------------------------------------
>
>                 Key: XERCESJ-1554
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1554
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: Other
>            Reporter: Guangtai Liang
>            Priority: Critical
>              Labels: incomplete_fix, missing_fixes
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> The fix revision 320527 was aimed to remove an NPE bug on the "this.fSelector" in the method "getSelectorStr" of the file 
> "/xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/IdentityConstraint.java" , but it is incomplete. 
> Since the "this.fSelector" is a class field and also could be null during the run-time execution, it should also be null-checked before being dereferenced in other methods. 
> The buggy code locations the same fix needs to be applied at are as bellows: 
> Line 148  of the method "equals"; 
> public boolean equals(IdentityConstraint id) {
>         boolean areEqual = fIdentityConstraintName.equals(id.fIdentityConstraintName);
>         if(!areEqual) return false;
>         areEqual = fSelector.toString().equals(id.fSelector.toString());
>         if(!areEqual) return false;
>         areEqual = (fFieldCount == id.fFieldCount);
>         if(!areEqual) return false;
>         for(int i=0; i<fFieldCount; i++)
>             if(!fFields[i].toString().equals(id.fFields[i].toString())) return false;
>         return true;
>     } // equals

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] [Resolved] (XERCESJ-1554) An incomplete fix for the NPE bugs in IdentityConstraint.java

Posted by "Michael Glavassevich (Resolved) (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESJ-1554?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Glavassevich resolved XERCESJ-1554.
-------------------------------------------

    Resolution: Invalid

An identity constraint is required to have a selector. The schema loader will have already verified that before the IdentityConstraint is created.
                
> An incomplete fix for the NPE bugs in IdentityConstraint.java
> -------------------------------------------------------------
>
>                 Key: XERCESJ-1554
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1554
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: Other
>            Reporter: Guangtai Liang
>            Priority: Critical
>              Labels: incomplete_fix, missing_fixes
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> The fix revision 320527 was aimed to remove an NPE bug on the "this.fSelector" in the method "getSelectorStr" of the file 
> "/xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/IdentityConstraint.java" , but it is incomplete. 
> Since the "this.fSelector" is a class field and also could be null during the run-time execution, it should also be null-checked before being dereferenced in other methods. 
> The buggy code locations the same fix needs to be applied at are as bellows: 
> Line 148  of the method "equals"; 
> public boolean equals(IdentityConstraint id) {
>         boolean areEqual = fIdentityConstraintName.equals(id.fIdentityConstraintName);
>         if(!areEqual) return false;
>         areEqual = fSelector.toString().equals(id.fSelector.toString());
>         if(!areEqual) return false;
>         areEqual = (fFieldCount == id.fFieldCount);
>         if(!areEqual) return false;
>         for(int i=0; i<fFieldCount; i++)
>             if(!fFields[i].toString().equals(id.fFields[i].toString())) return false;
>         return true;
>     } // equals

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] [Updated] (XERCESJ-1554) An incomplete fix for the NPE bugs in IdentityConstraint.java

Posted by "Guangtai Liang (Updated) (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESJ-1554?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Guangtai Liang updated XERCESJ-1554:
------------------------------------

    Comment: was deleted

(was: Please refer to the invalid schema file which was provided for reproducing the NPE issue ( https://issues.apache.org/jira/browse/XERCESJ-1078)  

The detailed description about this issue is copied here : 

"in case of an invalid schema file with the error "s4s-elt-must-match.2"
(The content of 'identity constraint' must match (annotation?, selector, field+). Not enough elements were found.) the attribute fSelector might be null and thus the method getSelectorStr() causes a NPE.

In my case, anylsing invalid schema files (as good as possible) it is important not to have this exception, so I'm working with my own patched version of Xerces2-J. It would be nice if you would fix this somewhen.

Example from schema test suite to preproduce:
msxsdtest\identityConstraint\idB059.xsd

My fix is quite simple: just check on null:

Old:
        return fSelector.toString();

New:
        return fSelector == null ? null : fSelector.toString();
"

If fSelector can be null in such case, I think the null-check should also be made before the dereference on fSelector in the method "equals". 

)
    
> An incomplete fix for the NPE bugs in IdentityConstraint.java
> -------------------------------------------------------------
>
>                 Key: XERCESJ-1554
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1554
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: Other
>            Reporter: Guangtai Liang
>            Priority: Critical
>              Labels: incomplete_fix, missing_fixes
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> The fix revision 320527 was aimed to remove an NPE bug on the "this.fSelector" in the method "getSelectorStr" of the file 
> "/xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/IdentityConstraint.java" , but it is incomplete. 
> Since the "this.fSelector" is a class field and also could be null during the run-time execution, it should also be null-checked before being dereferenced in other methods. 
> The buggy code locations the same fix needs to be applied at are as bellows: 
> Line 148  of the method "equals"; 
> public boolean equals(IdentityConstraint id) {
>         boolean areEqual = fIdentityConstraintName.equals(id.fIdentityConstraintName);
>         if(!areEqual) return false;
>         areEqual = fSelector.toString().equals(id.fSelector.toString());
>         if(!areEqual) return false;
>         areEqual = (fFieldCount == id.fFieldCount);
>         if(!areEqual) return false;
>         for(int i=0; i<fFieldCount; i++)
>             if(!fFields[i].toString().equals(id.fFields[i].toString())) return false;
>         return true;
>     } // equals

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] [Resolved] (XERCESJ-1554) An incomplete fix for the NPE bugs in IdentityConstraint.java

Posted by "Michael Glavassevich (Resolved) (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESJ-1554?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Glavassevich resolved XERCESJ-1554.
-------------------------------------------

    Resolution: Invalid

You still haven't stated what version of Xerces you're looking at. There have been many changes made to the codebase through out the years, in particular multiple improvements to error handling of invalid schemas [1]. If an error (e.g. a missing selector) occurred while processing an identity constraint it's never added to the schema model.

[1] https://issues.apache.org/jira/browse/XERCESJ-1372
                
> An incomplete fix for the NPE bugs in IdentityConstraint.java
> -------------------------------------------------------------
>
>                 Key: XERCESJ-1554
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1554
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: Other
>            Reporter: Guangtai Liang
>            Priority: Critical
>              Labels: incomplete_fix, missing_fixes
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> The fix revision 320527 was aimed to remove an NPE bug on the "this.fSelector" in the method "getSelectorStr" of the file 
> "/xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/IdentityConstraint.java" , but it is incomplete. 
> Since the "this.fSelector" is a class field and also could be null during the run-time execution, it should also be null-checked before being dereferenced in other methods. 
> The buggy code locations the same fix needs to be applied at are as bellows: 
> Line 148  of the method "equals"; 
> public boolean equals(IdentityConstraint id) {
>         boolean areEqual = fIdentityConstraintName.equals(id.fIdentityConstraintName);
>         if(!areEqual) return false;
>         areEqual = fSelector.toString().equals(id.fSelector.toString());
>         if(!areEqual) return false;
>         areEqual = (fFieldCount == id.fFieldCount);
>         if(!areEqual) return false;
>         for(int i=0; i<fFieldCount; i++)
>             if(!fFields[i].toString().equals(id.fFields[i].toString())) return false;
>         return true;
>     } // equals

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] [Updated] (XERCESJ-1554) An incomplete fix for the NPE bugs in IdentityConstraint.java

Posted by "Guangtai Liang (Updated) (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESJ-1554?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Guangtai Liang updated XERCESJ-1554:
------------------------------------

    Labels: incomplete_fix missing_fixes  (was: )
    
> An incomplete fix for the NPE bugs in IdentityConstraint.java
> -------------------------------------------------------------
>
>                 Key: XERCESJ-1554
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1554
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: Other
>            Reporter: Guangtai Liang
>            Priority: Critical
>              Labels: incomplete_fix, missing_fixes
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> The fix revision 320527 was aimed to remove an NPE bug on the "this.fSelector" in the method "getSelectorStr" of the file 
> "/xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/IdentityConstraint.java" , but it is incomplete. 
> Since the "this.fSelector" is a class field and also could be null during the run-time execution, it should also be null-checked before being dereferenced in other methods. 
> The buggy code locations the same fix needs to be applied at are as bellows: 
> Line 148  of the method "equals"; 
> public boolean equals(IdentityConstraint id) {
>         boolean areEqual = fIdentityConstraintName.equals(id.fIdentityConstraintName);
>         if(!areEqual) return false;
>         areEqual = fSelector.toString().equals(id.fSelector.toString());
>         if(!areEqual) return false;
>         areEqual = (fFieldCount == id.fFieldCount);
>         if(!areEqual) return false;
>         for(int i=0; i<fFieldCount; i++)
>             if(!fFields[i].toString().equals(id.fFields[i].toString())) return false;
>         return true;
>     } // equals

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] [Updated] (XERCESJ-1554) An incomplete fix for the NPE bugs in IdentityConstraint.java

Posted by "Guangtai Liang (Updated) (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESJ-1554?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Guangtai Liang updated XERCESJ-1554:
------------------------------------

    Affects Version/s: 2.6.2
    
> An incomplete fix for the NPE bugs in IdentityConstraint.java
> -------------------------------------------------------------
>
>                 Key: XERCESJ-1554
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1554
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 2.6.2
>            Reporter: Guangtai Liang
>            Priority: Critical
>              Labels: incomplete_fix, missing_fixes
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> The fix revision 320527 was aimed to remove an NPE bug on the "this.fSelector" in the method "getSelectorStr" of the file 
> "/xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/IdentityConstraint.java" , but it is incomplete. 
> Since the "this.fSelector" is a class field and also could be null during the run-time execution, it should also be null-checked before being dereferenced in other methods. 
> The buggy code locations the same fix needs to be applied at are as bellows: 
> Line 148  of the method "equals"; 
> public boolean equals(IdentityConstraint id) {
>         boolean areEqual = fIdentityConstraintName.equals(id.fIdentityConstraintName);
>         if(!areEqual) return false;
>         areEqual = fSelector.toString().equals(id.fSelector.toString());
>         if(!areEqual) return false;
>         areEqual = (fFieldCount == id.fFieldCount);
>         if(!areEqual) return false;
>         for(int i=0; i<fFieldCount; i++)
>             if(!fFields[i].toString().equals(id.fFields[i].toString())) return false;
>         return true;
>     } // equals

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] [Resolved] (XERCESJ-1554) An incomplete fix for the NPE bugs in IdentityConstraint.java

Posted by "Michael Glavassevich (Resolved) (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESJ-1554?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Glavassevich resolved XERCESJ-1554.
-------------------------------------------

    Resolution: Won't Fix

Xerces 2.6.2 was released in 2004. You're looking at something which is now 8 years old. The community moved on from that long ago. We do not patch old releases.

What you are claiming is an issue is not possible with the current codebase.
                
> An incomplete fix for the NPE bugs in IdentityConstraint.java
> -------------------------------------------------------------
>
>                 Key: XERCESJ-1554
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1554
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 2.6.2
>            Reporter: Guangtai Liang
>            Priority: Critical
>              Labels: incomplete_fix, missing_fixes
>         Attachments: attP006.xsd
>
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> The fix revision 320527 was aimed to remove an NPE bug on the "this.fSelector" in the method "getSelectorStr" of the file 
> "/xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/IdentityConstraint.java" , but it is incomplete. 
> Since the "this.fSelector" is a class field and also could be null during the run-time execution, it should also be null-checked before being dereferenced in other methods. 
> The buggy code locations the same fix needs to be applied at are as bellows: 
> Line 148  of the method "equals"; 
> public boolean equals(IdentityConstraint id) {
>         boolean areEqual = fIdentityConstraintName.equals(id.fIdentityConstraintName);
>         if(!areEqual) return false;
>         areEqual = fSelector.toString().equals(id.fSelector.toString());
>         if(!areEqual) return false;
>         areEqual = (fFieldCount == id.fFieldCount);
>         if(!areEqual) return false;
>         for(int i=0; i<fFieldCount; i++)
>             if(!fFields[i].toString().equals(id.fFields[i].toString())) return false;
>         return true;
>     } // equals

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] [Issue Comment Edited] (XERCESJ-1554) An incomplete fix for the NPE bugs in IdentityConstraint.java

Posted by "Guangtai Liang (Issue Comment Edited) (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESJ-1554?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13207498#comment-13207498 ] 

Guangtai Liang edited comment on XERCESJ-1554 at 2/16/12 7:28 AM:
------------------------------------------------------------------

Please refer to the invalid schema file which was provided for reproducing the NPE issue (https://issues.apache.org/jira/browse/XERCESJ-1078) 

If fSelector can be null in that case, I think the null-check should also be made before the dereference on fSelector in the method "equals". 


The detailed description on this issue is copied here : 

"in case of an invalid schema file with the error "s4s-elt-must-match.2" 
(The content of 'identity constraint' must match (annotation?, selector, field+). Not enough elements were found.) the attribute fSelector might be null and thus the method getSelectorStr() causes a NPE. 

In my case, anylsing invalid schema files (as good as possible) it is important not to have this exception, so I'm working with my own patched version of Xerces2-J. It would be nice if you would fix this somewhen. 

Example from schema test suite to preproduce: 
msxsdtest\identityConstraint\idB059.xsd 

My fix is quite simple: just check on null: 

Old: 
        return fSelector.toString(); 

New: 
        return fSelector == null ? null : fSelector.toString(); 
" 

                
      was (Author: guangtai):
    Please refer to the invalid schema file which was provided for reproducing the NPE issue ( https://issues.apache.org/jira/browse/XERCESJ-1078) 

If fSelector can be null in that case, I think the null-check should also be made before the dereference on fSelector in the method "equals". 


The detailed description on this issue is copied here : 

"in case of an invalid schema file with the error "s4s-elt-must-match.2" 
(The content of 'identity constraint' must match (annotation?, selector, field+). Not enough elements were found.) the attribute fSelector might be null and thus the method getSelectorStr() causes a NPE. 

In my case, anylsing invalid schema files (as good as possible) it is important not to have this exception, so I'm working with my own patched version of Xerces2-J. It would be nice if you would fix this somewhen. 

Example from schema test suite to preproduce: 
msxsdtest\identityConstraint\idB059.xsd 

My fix is quite simple: just check on null: 

Old: 
        return fSelector.toString(); 

New: 
        return fSelector == null ? null : fSelector.toString(); 
" 

                  
> An incomplete fix for the NPE bugs in IdentityConstraint.java
> -------------------------------------------------------------
>
>                 Key: XERCESJ-1554
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1554
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: Other
>            Reporter: Guangtai Liang
>            Priority: Critical
>              Labels: incomplete_fix, missing_fixes
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> The fix revision 320527 was aimed to remove an NPE bug on the "this.fSelector" in the method "getSelectorStr" of the file 
> "/xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/IdentityConstraint.java" , but it is incomplete. 
> Since the "this.fSelector" is a class field and also could be null during the run-time execution, it should also be null-checked before being dereferenced in other methods. 
> The buggy code locations the same fix needs to be applied at are as bellows: 
> Line 148  of the method "equals"; 
> public boolean equals(IdentityConstraint id) {
>         boolean areEqual = fIdentityConstraintName.equals(id.fIdentityConstraintName);
>         if(!areEqual) return false;
>         areEqual = fSelector.toString().equals(id.fSelector.toString());
>         if(!areEqual) return false;
>         areEqual = (fFieldCount == id.fFieldCount);
>         if(!areEqual) return false;
>         for(int i=0; i<fFieldCount; i++)
>             if(!fFields[i].toString().equals(id.fFields[i].toString())) return false;
>         return true;
>     } // equals

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] [Reopened] (XERCESJ-1554) An incomplete fix for the NPE bugs in IdentityConstraint.java

Posted by "Guangtai Liang (Reopened) (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESJ-1554?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Guangtai Liang reopened XERCESJ-1554:
-------------------------------------


I have provided the affects version info and an invalid schema file. 
Thanks. 
                
> An incomplete fix for the NPE bugs in IdentityConstraint.java
> -------------------------------------------------------------
>
>                 Key: XERCESJ-1554
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1554
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 2.6.2
>            Reporter: Guangtai Liang
>            Priority: Critical
>              Labels: incomplete_fix, missing_fixes
>         Attachments: attP006.xsd
>
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> The fix revision 320527 was aimed to remove an NPE bug on the "this.fSelector" in the method "getSelectorStr" of the file 
> "/xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/IdentityConstraint.java" , but it is incomplete. 
> Since the "this.fSelector" is a class field and also could be null during the run-time execution, it should also be null-checked before being dereferenced in other methods. 
> The buggy code locations the same fix needs to be applied at are as bellows: 
> Line 148  of the method "equals"; 
> public boolean equals(IdentityConstraint id) {
>         boolean areEqual = fIdentityConstraintName.equals(id.fIdentityConstraintName);
>         if(!areEqual) return false;
>         areEqual = fSelector.toString().equals(id.fSelector.toString());
>         if(!areEqual) return false;
>         areEqual = (fFieldCount == id.fFieldCount);
>         if(!areEqual) return false;
>         for(int i=0; i<fFieldCount; i++)
>             if(!fFields[i].toString().equals(id.fFields[i].toString())) return false;
>         return true;
>     } // equals

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] [Updated] (XERCESJ-1554) An incomplete fix for the NPE bugs in IdentityConstraint.java

Posted by "Guangtai Liang (Updated) (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESJ-1554?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Guangtai Liang updated XERCESJ-1554:
------------------------------------

    Attachment: attP006.xsd

When using this invalid schema file, NPE will be issued in the method "equals" 
It would be nice if you would fix this. Thanks. 
                
> An incomplete fix for the NPE bugs in IdentityConstraint.java
> -------------------------------------------------------------
>
>                 Key: XERCESJ-1554
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1554
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 2.6.2
>            Reporter: Guangtai Liang
>            Priority: Critical
>              Labels: incomplete_fix, missing_fixes
>         Attachments: attP006.xsd
>
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> The fix revision 320527 was aimed to remove an NPE bug on the "this.fSelector" in the method "getSelectorStr" of the file 
> "/xerces/java/trunk/src/org/apache/xerces/impl/xs/identity/IdentityConstraint.java" , but it is incomplete. 
> Since the "this.fSelector" is a class field and also could be null during the run-time execution, it should also be null-checked before being dereferenced in other methods. 
> The buggy code locations the same fix needs to be applied at are as bellows: 
> Line 148  of the method "equals"; 
> public boolean equals(IdentityConstraint id) {
>         boolean areEqual = fIdentityConstraintName.equals(id.fIdentityConstraintName);
>         if(!areEqual) return false;
>         areEqual = fSelector.toString().equals(id.fSelector.toString());
>         if(!areEqual) return false;
>         areEqual = (fFieldCount == id.fFieldCount);
>         if(!areEqual) return false;
>         for(int i=0; i<fFieldCount; i++)
>             if(!fFields[i].toString().equals(id.fFields[i].toString())) return false;
>         return true;
>     } // equals

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org