commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1781676 - /commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
Date Sat, 04 Feb 2017 14:49:00 GMT
Author: sebb
Date: Sat Feb  4 14:49:00 2017
New Revision: 1781676

URL: http://svn.apache.org/viewvc?rev=1781676&view=rev
Log:
Use constant instead of magic number

Modified:
    commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java

Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java?rev=1781676&r1=1781675&r2=1781676&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
(original)
+++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
Sat Feb  4 14:49:00 2017
@@ -78,6 +78,8 @@ public class UrlValidator implements Ser
 
     private static final long serialVersionUID = 7557161713937335013L;
 
+    private static final int MAX_UNSIGNED_16_BIT_INT = 0xFFFF; // port max
+
     /**
      * Allows all validly formatted schemes to pass validation instead of
      * supplying a set of valid schemes.
@@ -416,7 +418,7 @@ public class UrlValidator implements Ser
             if (port != null && port.length() > 0) {
             	try {
             		int iPort = Integer.parseInt(port);
-            		if (iPort < 0 || iPort > 0xFFFF) {
+            		if (iPort < 0 || iPort > MAX_UNSIGNED_16_BIT_INT) {
             			return false;
             		}
             	} catch (NumberFormatException nfe) {



Mime
View raw message