You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by ng...@apache.org on 2011/06/01 15:09:02 UTC

svn commit: r1130141 - in /mina/ftpserver/branches/1.0.x/core/src: main/java/org/apache/ftpserver/impl/PassivePorts.java test/java/org/apache/ftpserver/impl/PassivePortsTest.java

Author: ngn
Date: Wed Jun  1 13:09:02 2011
New Revision: 1130141

URL: http://svn.apache.org/viewvc?rev=1130141&view=rev
Log:
Doing an explicit null check in PassivePorts (FTPSERVER-415)

Modified:
    mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/impl/PassivePorts.java
    mina/ftpserver/branches/1.0.x/core/src/test/java/org/apache/ftpserver/impl/PassivePortsTest.java

Modified: mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/impl/PassivePorts.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/impl/PassivePorts.java?rev=1130141&r1=1130140&r2=1130141&view=diff
==============================================================================
--- mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/impl/PassivePorts.java (original)
+++ mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/impl/PassivePorts.java Wed Jun  1 13:09:02 2011
@@ -156,11 +156,11 @@ public class PassivePorts {
     }
 
     public PassivePorts(final int[] passivePorts, boolean checkIfBound) {
-        if (passivePorts != null) {
-            this.passivePorts = passivePorts.clone();
-        } else {
-            this.passivePorts = null;
-        }
+    	if(passivePorts == null) {
+    		throw new NullPointerException("passivePorts can not be null");
+    	}
+    	
+        this.passivePorts = passivePorts.clone();
 
         reservedPorts = new boolean[passivePorts.length];
         this.checkIfBound = checkIfBound;

Modified: mina/ftpserver/branches/1.0.x/core/src/test/java/org/apache/ftpserver/impl/PassivePortsTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/branches/1.0.x/core/src/test/java/org/apache/ftpserver/impl/PassivePortsTest.java?rev=1130141&r1=1130140&r2=1130141&view=diff
==============================================================================
--- mina/ftpserver/branches/1.0.x/core/src/test/java/org/apache/ftpserver/impl/PassivePortsTest.java (original)
+++ mina/ftpserver/branches/1.0.x/core/src/test/java/org/apache/ftpserver/impl/PassivePortsTest.java Wed Jun  1 13:09:02 2011
@@ -202,4 +202,12 @@ public class PassivePortsTest extends Te
         assertEquals(-1, ports.reserveNextPort());
     }
 
+    public void testNullPorts() {
+    	try {
+    		new PassivePorts((int[])null, false);
+    		fail("Must throw NPE");
+    	} catch(NullPointerException e) {
+    		// ok
+    	}
+    }
 }