You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2017/02/04 14:49:00 UTC
svn commit: r1781676 -
/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
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) {
Re: svn commit: r1781676 -
/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
Posted by Benedikt Ritter <br...@apache.org>.
Nice!
> Am 04.02.2017 um 15:49 schrieb sebb@apache.org:
>
> 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) {
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org