Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-3073 Address Java compiler warning

Sebastian Nagel1db41198f524
diff --git a/src/java/org/apache/nutch/fetcher/FetcherThread.java b/src/java/org/apache/nutch/fetcher/FetcherThread.java
index f48f6076a..ebb28aadb 100644
--- a/src/java/org/apache/nutch/fetcher/FetcherThread.java
+++ b/src/java/org/apache/nutch/fetcher/FetcherThread.java
@@ -404,11 +404,6 @@ public class FetcherThread extends Thread {
switch (status.getCode()) {
- case ProtocolStatus.WOULDBLOCK:
- // retry ?
- fetchQueues.addFetchItem(fit);
- break;
-
case ProtocolStatus.SUCCESS: // got a page
pstatus = output(fit.url, fit.datum, content, status,
CrawlDatum.STATUS_FETCH_SUCCESS, fit.outlinkDepth);
@@ -457,8 +452,8 @@ public class FetcherThread extends Thread {
context.getCounter("FetcherStatus",
"AboveExceptionThresholdInQueue").increment(killedURLs);
/* FALLTHROUGH */
+
case ProtocolStatus.RETRY: // retry
- case ProtocolStatus.BLOCKED:
output(fit.url, fit.datum, null, status,
CrawlDatum.STATUS_FETCH_RETRY);
break;
diff --git a/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/HttpFormAuthentication.java b/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/HttpFormAuthentication.java
index 868e73822..966ab6522 100644
--- a/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/HttpFormAuthentication.java
+++ b/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/HttpFormAuthentication.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.CookieHandler;
import java.net.CookieManager;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -132,7 +133,8 @@ public class HttpFormAuthentication {
LOG.debug("Response headers : " + header);
}
}
- String rst = IOUtils.toString(post.getResponseBodyAsStream());
+ String rst = IOUtils.toString(post.getResponseBodyAsStream(),
+ StandardCharsets.UTF_8);
LOG.debug("login post result: " + rst);
} finally {
if (post != null) {
@@ -194,7 +196,8 @@ public class HttpFormAuthentication {
if (cookieHeader != null) {
setCookies(cookieHeader.getValue());
}
- String rst = IOUtils.toString(get.getResponseBodyAsStream());
+ String rst = IOUtils.toString(get.getResponseBodyAsStream(),
+ StandardCharsets.UTF_8);
return rst;
} finally {
get.releaseConnection();
diff --git a/src/test/org/apache/nutch/fetcher/TestFetcher.java b/src/test/org/apache/nutch/fetcher/TestFetcher.java
index ecc135c52..ad98a4251 100644
--- a/src/test/org/apache/nutch/fetcher/TestFetcher.java
+++ b/src/test/org/apache/nutch/fetcher/TestFetcher.java
@@ -100,7 +100,7 @@ public class TestFetcher {
// generate
Generator g = new Generator(conf);
Path[] generatedSegment = g.generate(crawldbPath, segmentsPath, 1,
- Long.MAX_VALUE, Long.MAX_VALUE, false, false);
+ Long.MAX_VALUE, Long.MAX_VALUE, false, false, false, 1, null);
long time = System.currentTimeMillis();
// fetch