You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2017/10/20 11:40:30 UTC
[1/2] httpcomponents-core git commit: Silence doclint warning about
missing @param and @throws
Repository: httpcomponents-core
Updated Branches:
refs/heads/master f9d8ead68 -> abfca7ed5
Silence doclint warning about missing @param and @throws
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/e948fb1c
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/e948fb1c
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/e948fb1c
Branch: refs/heads/master
Commit: e948fb1cb4090264a7bb078945d63fd31c5793b5
Parents: f9d8ead
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Fri Oct 20 11:35:57 2017 +0200
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Fri Oct 20 11:35:57 2017 +0200
----------------------------------------------------------------------
pom.xml | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e948fb1c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 043c567..e6a8a4a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -152,6 +152,7 @@
</execution>
</executions>
<configuration>
+ <additionalparam>-Xdoclint:-missing</additionalparam>
<!-- reduce console output. Can override with -Dquiet=false -->
<quiet>true</quiet>
<source>${maven.compiler.source}</source>
[2/2] httpcomponents-core git commit: HTTPCORE-495: add context
details to ParseException
Posted by ol...@apache.org.
HTTPCORE-495: add context details to ParseException
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/abfca7ed
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/abfca7ed
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/abfca7ed
Branch: refs/heads/master
Commit: abfca7ed590b54d0e24e154e432181876ec53a85
Parents: e948fb1
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Fri Oct 20 13:36:42 2017 +0200
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Fri Oct 20 13:36:42 2017 +0200
----------------------------------------------------------------------
.../apache/hc/core5/http/ParseException.java | 32 +++++++++++++++++++
.../hc/core5/http/message/BasicLineParser.java | 33 +++++++++++++-------
.../hc/core5/http/message/BufferedHeader.java | 6 ++--
3 files changed, 57 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/abfca7ed/httpcore5/src/main/java/org/apache/hc/core5/http/ParseException.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/ParseException.java b/httpcore5/src/main/java/org/apache/hc/core5/http/ParseException.java
index 3f78759..66895d5 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/ParseException.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/ParseException.java
@@ -36,11 +36,14 @@ public class ParseException extends ProtocolException {
private static final long serialVersionUID = -7288819855864183578L;
+ private final int errorOffset;
+
/**
* Creates a {@link ParseException} without details.
*/
public ParseException() {
super();
+ this.errorOffset = -1;
}
/**
@@ -50,6 +53,35 @@ public class ParseException extends ProtocolException {
*/
public ParseException(final String message) {
super(message);
+ this.errorOffset = -1;
+ }
+
+ /**
+ * Creates a {@link ParseException} with parsing context details.
+ *
+ * @since 5.0
+ */
+ public ParseException(final String description, final CharSequence text, final int off, final int len, final int errorOffset) {
+ super(description +
+ (errorOffset >= 0 ? "; error at offset " + errorOffset : "") +
+ (text != null && len < 1024 ? ": " + text.subSequence(off, off + len) : ""));
+ this.errorOffset = errorOffset;
+ }
+
+ /**
+ * Creates a {@link ParseException} with parsing context details.
+ *
+ * @since 5.0
+ */
+ public ParseException(final String description, final CharSequence text, final int off, final int len) {
+ this(description, text, off, len, -1);
+ }
+
+ /**
+ * @since 5.0
+ */
+ public int getErrorOffset() {
+ return errorOffset;
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/abfca7ed/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicLineParser.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicLineParser.java b/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicLineParser.java
index 2810d8d..5b4ce79 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicLineParser.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicLineParser.java
@@ -93,7 +93,8 @@ public class BasicLineParser implements LineParser {
// long enough for "HTTP/1.1"?
if (pos + protolength + 4 > cursor.getUpperBound()) {
- throw new ParseException("Invalid protocol version: " + buffer.toString());
+ throw new ParseException("Invalid protocol version",
+ buffer, cursor.getLowerBound(), cursor.getUpperBound(), cursor.getPos());
}
// check the protocol name and slash
@@ -105,7 +106,8 @@ public class BasicLineParser implements LineParser {
ok = buffer.charAt(pos + protolength) == '/';
}
if (!ok) {
- throw new ParseException("Invalid protocol version: " + buffer.toString());
+ throw new ParseException("Invalid protocol version",
+ buffer, cursor.getLowerBound(), cursor.getUpperBound(), cursor.getPos());
}
cursor.updatePos(pos + protolength + 1);
@@ -115,10 +117,12 @@ public class BasicLineParser implements LineParser {
try {
major = Integer.parseInt(token1);
} catch (final NumberFormatException e) {
- throw new ParseException("Invalid protocol major version number: " + buffer.toString());
+ throw new ParseException("Invalid protocol major version number",
+ buffer, cursor.getLowerBound(), cursor.getUpperBound(), cursor.getPos());
}
if (cursor.atEnd()) {
- throw new ParseException("Invalid protocol version: " + buffer.toString());
+ throw new ParseException("Invalid protocol version",
+ buffer, cursor.getLowerBound(), cursor.getUpperBound(), cursor.getPos());
}
cursor.updatePos(cursor.getPos() + 1);
final String token2 = this.tokenParser.parseToken(buffer, cursor, BLANKS);
@@ -126,7 +130,8 @@ public class BasicLineParser implements LineParser {
try {
minor = Integer.parseInt(token2);
} catch (final NumberFormatException e) {
- throw new ParseException("Invalid protocol minor version number: " + buffer.toString());
+ throw new ParseException("Invalid protocol minor version number",
+ buffer, cursor.getLowerBound(), cursor.getUpperBound(), cursor.getPos());
}
return new HttpVersion(major, minor);
}
@@ -148,17 +153,20 @@ public class BasicLineParser implements LineParser {
this.tokenParser.skipWhiteSpace(buffer, cursor);
final String method = this.tokenParser.parseToken(buffer, cursor, BLANKS);
if (TextUtils.isEmpty(method)) {
- throw new ParseException("Invalid request line: " + buffer.toString());
+ throw new ParseException("Invalid request line",
+ buffer, cursor.getLowerBound(), cursor.getUpperBound(), cursor.getPos());
}
this.tokenParser.skipWhiteSpace(buffer, cursor);
final String uri = this.tokenParser.parseToken(buffer, cursor, BLANKS);
if (TextUtils.isEmpty(uri)) {
- throw new ParseException("Invalid request line: " + buffer.toString());
+ throw new ParseException("Invalid request line",
+ buffer, cursor.getLowerBound(), cursor.getUpperBound(), cursor.getPos());
}
final ProtocolVersion ver = parseProtocolVersion(buffer, cursor);
this.tokenParser.skipWhiteSpace(buffer, cursor);
if (!cursor.atEnd()) {
- throw new ParseException("Invalid request line: " + buffer.toString());
+ throw new ParseException("Invalid request line",
+ buffer, cursor.getLowerBound(), cursor.getUpperBound(), cursor.getPos());
}
return new RequestLine(method, uri, ver);
}
@@ -174,14 +182,16 @@ public class BasicLineParser implements LineParser {
final String s = this.tokenParser.parseToken(buffer, cursor, BLANKS);
for (int i = 0; i < s.length(); i++) {
if (!Character.isDigit(s.charAt(i))) {
- throw new ParseException("Status line contains invalid status code: " + buffer.toString());
+ throw new ParseException("Status line contains invalid status code",
+ buffer, cursor.getLowerBound(), cursor.getUpperBound(), cursor.getPos());
}
}
final int statusCode;
try {
statusCode = Integer.parseInt(s);
} catch (final NumberFormatException e) {
- throw new ParseException("Status line contains invalid status code: " + buffer.toString());
+ throw new ParseException("Status line contains invalid status code",
+ buffer, cursor.getLowerBound(), cursor.getUpperBound(), cursor.getPos());
}
final String text = buffer.substringTrimmed(cursor.getPos(), cursor.getUpperBound());
return new StatusLine(ver, statusCode, text);
@@ -198,7 +208,8 @@ public class BasicLineParser implements LineParser {
buffer.charAt(cursor.getPos()) != ':' ||
TextUtils.isEmpty(name) ||
TokenParser.isWhitespace(buffer.charAt(cursor.getPos() - 1))) {
- throw new ParseException("Invalid header: " + buffer.toString());
+ throw new ParseException("Invalid header",
+ buffer, cursor.getLowerBound(), cursor.getUpperBound(), cursor.getPos());
}
final String value = buffer.substringTrimmed(cursor.getPos() + 1, cursor.getUpperBound());
return new BasicHeader(name, value);
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/abfca7ed/httpcore5/src/main/java/org/apache/hc/core5/http/message/BufferedHeader.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/message/BufferedHeader.java b/httpcore5/src/main/java/org/apache/hc/core5/http/message/BufferedHeader.java
index 65fb363..10099b9 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/message/BufferedHeader.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/message/BufferedHeader.java
@@ -88,14 +88,14 @@ public class BufferedHeader implements FormattedHeader, Serializable {
Args.notNull(buffer, "Char array buffer");
final int colon = buffer.indexOf(':');
if (colon <= 0) {
- throw new ParseException("Invalid header: " + buffer.toString());
+ throw new ParseException("Invalid header", buffer, 0, buffer.length());
}
if (strict && TokenParser.isWhitespace(buffer.charAt(colon - 1))) {
- throw new ParseException("Invalid header: " + buffer.toString());
+ throw new ParseException("Invalid header", buffer, 0, buffer.length(), colon - 1);
}
final String s = buffer.substringTrimmed(0, colon);
if (s.length() == 0) {
- throw new ParseException("Invalid header: " + buffer.toString());
+ throw new ParseException("Invalid header", buffer, 0, buffer.length(), colon);
}
this.buffer = buffer;
this.name = s;