[
https://issues.apache.org/jira/browse/NUTCH-2533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16435126#comment-16435126
]
ASF GitHub Bot commented on NUTCH-2533:
---------------------------------------
sebastian-nagel closed pull request #313: NUTCH-2533 Injector:
NullPointerException if seed URL dir contains non-file entries
URL: https://github.com/apache/nutch/pull/313
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/Injector.java
b/src/java/org/apache/nutch/crawl/Injector.java
index 093d483fd..1f3098905 100644
--- a/src/java/org/apache/nutch/crawl/Injector.java
+++ b/src/java/org/apache/nutch/crawl/Injector.java
@@ -18,6 +18,7 @@
package org.apache.nutch.crawl;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.FloatWritable;
@@ -41,6 +42,7 @@
import org.apache.nutch.scoring.ScoringFilterException;
import org.apache.nutch.scoring.ScoringFilters;
import org.apache.nutch.service.NutchServer;
+import org.apache.nutch.util.LockUtil;
import org.apache.nutch.util.NutchConfiguration;
import org.apache.nutch.util.NutchJob;
import org.apache.nutch.util.NutchTool;
@@ -409,7 +411,24 @@ public void inject(Path crawlDb, Path urlDir, boolean
overwrite,
// set input and output paths of the job
MultipleInputs.addInputPath(job, current, SequenceFileInputFormat.class);
- MultipleInputs.addInputPath(job, urlDir, KeyValueTextInputFormat.class);
+ FileStatus[] seedFiles =
urlDir.getFileSystem(getConf()).listStatus(urlDir);
+ int numSeedFiles = 0;
+ for (FileStatus seedFile : seedFiles) {
+ if (seedFile.isFile()) {
+ MultipleInputs.addInputPath(job, seedFile.getPath(),
+ KeyValueTextInputFormat.class);
+ numSeedFiles++;
+ LOG.info("Injecting seed URL file {}", seedFile.getPath());
+ } else {
+ LOG.warn("Skipped non-file input in {}: {}", urlDir,
+ seedFile.getPath());
+ }
+ }
+ if (numSeedFiles == 0) {
+ LOG.error("No seed files to inject found in {}", urlDir);
+ LockUtil.removeLockFile(fs, lock);
+ return;
+ }
FileOutputFormat.setOutputPath(job, tempCrawlDb);
try {
@@ -461,8 +480,8 @@ public void inject(Path crawlDb, Path urlDir, boolean
overwrite,
LOG.info("Injector: finished at " + sdf.format(end) + ", elapsed: "
+ TimingUtil.elapsedTime(start, end));
}
- } catch (IOException | InterruptedException | ClassNotFoundException e) {
- LOG.error("Injector job failed", e);
+ } catch (IOException | InterruptedException | ClassNotFoundException |
NullPointerException e) {
+ LOG.error("Injector job failed: {}", e.getMessage());
NutchJob.cleanupAfterFailure(tempCrawlDb, lock, fs);
throw e;
}
----------------------------------------------------------------
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:
[email protected]
> Injector: NullPointerException if seed URL dir contains non-file entries
> ------------------------------------------------------------------------
>
> Key: NUTCH-2533
> URL: https://issues.apache.org/jira/browse/NUTCH-2533
> Project: Nutch
> Issue Type: Bug
> Components: injector
> Affects Versions: 2.3.1, 1.14
> Reporter: Krzysztof Madejski
> Assignee: Sebastian Nagel
> Priority: Minor
> Fix For: 2.4, 1.15
>
>
> I'm following https://wiki.apache.org/nutch/Nutch2Tutorial
>
> I've run `./nutch inject /` and I've got the following error:
> {noformat}
> InjectorJob: starting at 2018-03-12 11:59:05
> InjectorJob: Injecting urlDir: /
> InjectorJob: Using class org.apache.gora.hbase.store.HBaseStore as the Gora
> storage class.
> InjectorJob: java.lang.NullPointerException
> at
> org.apache.hadoop.mapreduce.lib.input.FileInputFormat.getBlockIndex(FileInputFormat.java:442)
> at
> org.apache.hadoop.mapreduce.lib.input.FileInputFormat.getSplits(FileInputFormat.java:411)
> at
> org.apache.hadoop.mapreduce.JobSubmitter.writeNewSplits(JobSubmitter.java:493)
> at org.apache.hadoop.mapreduce.JobSubmitter.writeSplits(JobSubmitter.java:510)
> at
> org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:394)
> at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1285)
> at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1282)
> at java.security.AccessController.doPrivileged(Native Method)
> at javax.security.auth.Subject.doAs(Subject.java:422)
> at
> org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1614)
> at org.apache.hadoop.mapreduce.Job.submit(Job.java:1282)
> at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:1303)
> at org.apache.nutch.util.NutchJob.waitForCompletion(NutchJob.java:115)
> at org.apache.nutch.crawl.InjectorJob.run(InjectorJob.java:231)
> at org.apache.nutch.crawl.InjectorJob.inject(InjectorJob.java:252)
> at org.apache.nutch.crawl.InjectorJob.run(InjectorJob.java:275)
> at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70){noformat}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)