[jira] [Commented] (NUTCH-2614) NPE in CrawlDbReader -stats on empty CrawlDb

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (NUTCH-2614) NPE in CrawlDbReader -stats on empty CrawlDb

JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/NUTCH-2614?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16539876#comment-16539876 ]

ASF GitHub Bot commented on NUTCH-2614:
---------------------------------------

sebastian-nagel closed pull request #357: NUTCH-2614 NPE in CrawlDbReader -stats on empty CrawlDb
URL: https://github.com/apache/nutch/pull/357
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/java/org/apache/nutch/crawl/CrawlDbReader.java b/src/java/org/apache/nutch/crawl/CrawlDbReader.java
index 7b8b13aa6..ea4c96467 100644
--- a/src/java/org/apache/nutch/crawl/CrawlDbReader.java
+++ b/src/java/org/apache/nutch/crawl/CrawlDbReader.java
@@ -550,8 +550,11 @@ public void processStatJob(String crawlDb, Configuration config, boolean sort)
 
     if (LOG.isInfoEnabled()) {
       LOG.info("Statistics for CrawlDb: " + crawlDb);
-      LongWritable totalCnt = ((LongWritable) stats.get("T"));
-      stats.remove("T");
+      LongWritable totalCnt = new LongWritable(0);
+      if (stats.containsKey("T")) {
+        totalCnt = ((LongWritable) stats.get("T"));
+        stats.remove("T");
+      }
       LOG.info("TOTAL urls:\t" + totalCnt.get());
       for (Map.Entry<String, Writable> entry : stats.entrySet()) {
         String k = entry.getKey();


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


> NPE in CrawlDbReader -stats on empty CrawlDb
> --------------------------------------------
>
>                 Key: NUTCH-2614
>                 URL: https://issues.apache.org/jira/browse/NUTCH-2614
>             Project: Nutch
>          Issue Type: Bug
>          Components: crawldb
>    Affects Versions: 1.14, 1.15
>            Reporter: Markus Jelsma
>            Priority: Major
>             Fix For: 1.15
>
>
> Got this in master:
> {code}
> Exception in thread "main" java.lang.NullPointerException
>         at org.apache.nutch.crawl.CrawlDbReader.processStatJob(CrawlDbReader.java:555)
>         at org.apache.nutch.crawl.CrawlDbReader.run(CrawlDbReader.java:914)
>         at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
>         at org.apache.nutch.crawl.CrawlDbReader.main(CrawlDbReader.java:980)
> {code}
> Not sure why it happens or which commit caused the problem.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)