You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by mi...@apache.org on 2019/12/26 15:03:03 UTC

[httpcomponents-core] 04/06: Use Args for argument check

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch consistency-fixes
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git

commit dc6b3e5aa5520c7d70ba3a1db0f0f2262b87d4ec
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Wed Dec 25 16:46:22 2019 +0100

    Use Args for argument check
---
 .../java/org/apache/hc/core5/http/message/ParserCursor.java    | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/message/ParserCursor.java b/httpcore5/src/main/java/org/apache/hc/core5/http/message/ParserCursor.java
index 70082dc..fcbd2e4 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/message/ParserCursor.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/message/ParserCursor.java
@@ -27,6 +27,8 @@
 
 package org.apache.hc.core5.http.message;
 
+import org.apache.hc.core5.util.Args;
+
 /**
  * This class represents a context of a parsing operation:
  * <ul>
@@ -44,12 +46,8 @@ public class ParserCursor {
 
     public ParserCursor(final int lowerBound, final int upperBound) {
         super();
-        if (lowerBound < 0) {
-            throw new IndexOutOfBoundsException("Lower bound cannot be negative");
-        }
-        if (lowerBound > upperBound) {
-            throw new IndexOutOfBoundsException("Lower bound cannot be greater then upper bound");
-        }
+        Args.notNegative(lowerBound, "lowerBound");
+        Args.check(lowerBound <= upperBound, "lowerBound cannot be greater than upperBound");
         this.lowerBound = lowerBound;
         this.upperBound = upperBound;
         this.pos = lowerBound;