Skip to content

Commit

Permalink
NUTCH-3073 Address Java compiler warning
Browse files Browse the repository at this point in the history
- replace (do not use) deprecated methods and fields
  • Loading branch information
sebastian-nagel committed Oct 4, 2024
1 parent 83405fb commit 1db4119
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
7 changes: 1 addition & 6 deletions src/java/org/apache/nutch/fetcher/FetcherThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,6 @@ public void run() {

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);
Expand Down Expand Up @@ -457,8 +452,8 @@ public void run() {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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;
Expand Down Expand Up @@ -132,7 +133,8 @@ public boolean getFollowRedirects() {
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) {
Expand Down Expand Up @@ -194,7 +196,8 @@ private String httpGetPageContent(String url) throws IOException {
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();
Expand Down
2 changes: 1 addition & 1 deletion src/test/org/apache/nutch/fetcher/TestFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void testFetch() throws IOException, ClassNotFoundException, InterruptedE
// 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
Expand Down

0 comments on commit 1db4119

Please sign in to comment.