You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by fe...@apache.org on 2010/05/15 08:17:29 UTC
svn commit: r944577 -
/directory/shared/trunk/cursor/src/main/java/org/apache/directory/shared/ldap/cursor/ListCursor.java
Author: felixk
Date: Sat May 15 06:17:29 2010
New Revision: 944577
URL: http://svn.apache.org/viewvc?rev=944577&view=rev
Log:
Avoid NPE
>From FireBug report
RCN: Nullcheck of value previously dereferenced (RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE)
A value is checked here to see whether it is null, but this value can't be null because it was previously dereferenced and if it were null a null pointer exception would have occurred at the earlier dereference. Essentially, this code and the previous dereference disagree as to whether this value is allowed to be null. Either the check is redundant or the previous dereference is erroneous.
Modified:
directory/shared/trunk/cursor/src/main/java/org/apache/directory/shared/ldap/cursor/ListCursor.java
Modified: directory/shared/trunk/cursor/src/main/java/org/apache/directory/shared/ldap/cursor/ListCursor.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/cursor/src/main/java/org/apache/directory/shared/ldap/cursor/ListCursor.java?rev=944577&r1=944576&r2=944577&view=diff
==============================================================================
--- directory/shared/trunk/cursor/src/main/java/org/apache/directory/shared/ldap/cursor/ListCursor.java (original)
+++ directory/shared/trunk/cursor/src/main/java/org/apache/directory/shared/ldap/cursor/ListCursor.java Sat May 15 06:17:29 2010
@@ -67,6 +67,10 @@ public class ListCursor<E> extends Abstr
*/
public ListCursor( Comparator<E> comparator, int start, List<E> list, int end )
{
+ if ( list == null )
+ {
+ list = Collections.emptyList();
+ }
if ( ( start < 0 )|| ( start > list.size() ) )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_02005, start ) );
@@ -85,16 +89,7 @@ public class ListCursor<E> extends Abstr
}
this.comparator = comparator;
-
- if ( list != null )
- {
- this.list = list;
- }
- else
- {
- this.list = Collections.emptyList();
- }
-
+ this.list = list;
this.start = start;
this.end = end;
}