I assume the reason you moved it in the first place was because the null 
check in its original position in the method could never produce a 
NullPointerException. Calling s.length() would have already thrown the NPE 
if lexicalRepresentation was null. The explicit throwing of the NPE was 
unreachable code. 

Michael Glavassevich
XML Technologies and WAS Development
IBM Toronto Lab
E-mail: mrgla...@ca.ibm.com
E-mail: mrgla...@apache.org

muk...@apache.org wrote on 06/10/2016 12:44:24 AM:

> Author: mukulg
> Date: Fri Jun 10 04:44:24 2016
> New Revision: 1747631
> 
> URL: http://svn.apache.org/viewvc?rev=1747631&view=rev
> Log:
> I am reverting a change I did long time ago to this file. I am 
> restoring the logic in this file, that was in the original revision 
> 906803. I think, the original code that I had changed in this file 
> is not really wrong. I started looking at the code in this file, 
> while studying the bug report XERCESJ-1669.
> 
> Modified:
> xerces/java/trunk/src/org/apache/xerces/jaxp/datatype/DurationImpl.java
> 
> Modified: xerces/java/trunk/src/org/apache/xerces/jaxp/datatype/
> DurationImpl.java
> URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/
> xerces/jaxp/datatype/DurationImpl.java?
> rev=1747631&r1=1747630&r2=1747631&view=diff
> 
==============================================================================
> --- xerces/java/trunk/src/org/apache/xerces/jaxp/datatype/
> DurationImpl.java (original)
> +++ xerces/java/trunk/src/org/apache/xerces/jaxp/datatype/
> DurationImpl.java Fri Jun 10 04:44:24 2016
> @@ -420,16 +420,16 @@ class DurationImpl
>      protected DurationImpl(String lexicalRepresentation)
>          throws IllegalArgumentException {
>          // only if I could use the JDK1.4 regular expression ....
> -
> -        if (lexicalRepresentation == null) {
> -           throw new NullPointerException();
> -        }
> - 
> + 
>          final String s = lexicalRepresentation;
>          boolean positive;
>          int[] idx = new int[1];
>          int length = s.length();
>          boolean timeRequired = false;
> + 
> +        if (lexicalRepresentation == null) {
> +            throw new NullPointerException();
> +        }
> 
>          idx[0] = 0;
>          if (length != idx[0] && s.charAt(idx[0]) == '-') {
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commits-unsubscr...@xerces.apache.org
> For additional commands, e-mail: commits-h...@xerces.apache.org



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

Reply via email to