diff --git a/norconex-collector-filesystem/pom.xml b/norconex-collector-filesystem/pom.xml
index bfba865..08c86f8 100644
--- a/norconex-collector-filesystem/pom.xml
+++ b/norconex-collector-filesystem/pom.xml
@@ -19,14 +19,14 @@
4.0.0
com.norconex.collectors
norconex-collector-filesystem
- 2.8.0
+ 2.8.1-SNAPSHOT
Norconex Filesystem Collector
UTF-8
UTF-8
- 1.14.0
+ 1.14.1-SNAPSHOT
2014
@@ -72,7 +72,7 @@
com.norconex.collectors
norconex-collector-core
- 1.9.0
+ 1.9.1-SNAPSHOT
org.apache.commons
diff --git a/norconex-collector-filesystem/src/changes/changes.xml b/norconex-collector-filesystem/src/changes/changes.xml
index eb27da0..227d26f 100644
--- a/norconex-collector-filesystem/src/changes/changes.xml
+++ b/norconex-collector-filesystem/src/changes/changes.xml
@@ -7,6 +7,17 @@
+
+
+ Dependency updates: Norconex Collector Core 1.9.1,
+ Norconex Commons Lang 1.14.1.
+
+
+ Fixed NullPointerException under some conditions for
+ FilesystemCrawlerConfig#saveToXML(...).
+
+
+
Several new features (new TruncateTagger, ExternalTagger, etc.) are
diff --git a/norconex-collector-filesystem/src/main/java/com/norconex/collector/fs/crawler/FilesystemCrawlerConfig.java b/norconex-collector-filesystem/src/main/java/com/norconex/collector/fs/crawler/FilesystemCrawlerConfig.java
index 47392db..42072db 100644
--- a/norconex-collector-filesystem/src/main/java/com/norconex/collector/fs/crawler/FilesystemCrawlerConfig.java
+++ b/norconex-collector-filesystem/src/main/java/com/norconex/collector/fs/crawler/FilesystemCrawlerConfig.java
@@ -206,16 +206,23 @@ protected void saveCrawlerConfigToXML(Writer out) throws IOException {
writer.writeElementBoolean("keepDownloads", isKeepDownloads());
writer.writeStartElement("startPaths");
- for (String path : getStartPaths()) {
- writer.writeElementString("path", path);
+
+ String[] paths = getStartPaths();
+ if (ArrayUtils.isNotEmpty(paths)) {
+ for (String path : paths) {
+ writer.writeElementString("path", path);
+ }
}
- for (String path : getPathsFiles()) {
- writer.writeElementString("pathsFile", path);
+ String[] files = getPathsFiles();
+ if (ArrayUtils.isNotEmpty(files)) {
+ for (String path : files) {
+ writer.writeElementString("pathsFile", path);
+ }
}
writer.flush();
- IStartPathsProvider[] startPathsProviders = getStartPathsProviders();
- if (startPathsProviders != null) {
- for (IStartPathsProvider provider : startPathsProviders) {
+ IStartPathsProvider[] pathsProviders = getStartPathsProviders();
+ if (ArrayUtils.isNotEmpty(pathsProviders)) {
+ for (IStartPathsProvider provider : pathsProviders) {
writeObject(out, "provider", provider);
}
}
diff --git a/norconex-collector-filesystem/src/test/java/com/norconex/collector/fs/FilesystemCollectorConfigTest.java b/norconex-collector-filesystem/src/test/java/com/norconex/collector/fs/FilesystemCollectorConfigTest.java
index 9ad3699..fbd24f4 100644
--- a/norconex-collector-filesystem/src/test/java/com/norconex/collector/fs/FilesystemCollectorConfigTest.java
+++ b/norconex-collector-filesystem/src/test/java/com/norconex/collector/fs/FilesystemCollectorConfigTest.java
@@ -1,4 +1,4 @@
-/* Copyright 2017 Norconex Inc.
+/* Copyright 2017-2018 Norconex Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,14 +17,20 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.io.StringWriter;
import org.apache.log4j.Level;
import org.junit.Assert;
import org.junit.Test;
import com.norconex.collector.core.crawler.ICrawlerConfig;
+import com.norconex.collector.core.crawler.event.ICrawlerEventListener;
+import com.norconex.collector.core.filter.IDocumentFilter;
+import com.norconex.collector.core.filter.IMetadataFilter;
+import com.norconex.collector.core.filter.IReferenceFilter;
import com.norconex.collector.core.filter.impl.RegexMetadataFilter;
import com.norconex.collector.fs.crawler.FilesystemCrawlerConfig;
+import com.norconex.collector.fs.crawler.IStartPathsProvider;
import com.norconex.collector.fs.crawler.MockStartPathsProvider;
import com.norconex.collector.fs.option.impl.GenericFilesystemOptionsProvider;
import com.norconex.committer.core.impl.FileSystemCommitter;
@@ -74,4 +80,42 @@ public void testValidation() throws IOException {
Assert.assertEquals("Validation warnings/errors were found.",
0, appender.getCount());
}
+
+ // test for: https://github.com/Norconex/collector-filesystem/issues/29
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testNulls() throws IOException {
+ FilesystemCollectorConfig config = new FilesystemCollectorConfig();
+ config.setId("test-fs-collector");
+
+ FilesystemCrawlerConfig crawlerCfg = new FilesystemCrawlerConfig();
+ crawlerCfg.setCrawlDataStoreFactory(null);
+ crawlerCfg.setCommitter(null);
+ crawlerCfg.setCrawlerListeners((ICrawlerEventListener) null);
+ crawlerCfg.setDocumentChecksummer(null);
+ crawlerCfg.setDocumentFetcher(null);
+ crawlerCfg.setDocumentFilters((IDocumentFilter) null);
+ crawlerCfg.setId("testing Nulls");
+ crawlerCfg.setImporterConfig(null);
+ crawlerCfg.setStartPaths(null);
+ crawlerCfg.setStartPathsProviders();
+ crawlerCfg.setMetadataChecksummer(null);
+ crawlerCfg.setMetadataFetcher(null);
+ crawlerCfg.setMetadataFilters((IMetadataFilter) null);
+ crawlerCfg.setOptionsProvider(null);
+ crawlerCfg.setOrphansStrategy(null);
+ crawlerCfg.setPostImportProcessors(null);
+ crawlerCfg.setPathsFiles(null);
+ crawlerCfg.setPreImportProcessors(null);
+ crawlerCfg.setReferenceFilters((IReferenceFilter) null);
+ crawlerCfg.setSpoiledReferenceStrategizer(null);
+ crawlerCfg.setStartPaths(null);
+ crawlerCfg.setStartPathsProviders((IStartPathsProvider) null);
+ crawlerCfg.setStopOnExceptions((Class extends Exception>) null);
+ crawlerCfg.setWorkDir(null);
+ config.setCrawlerConfigs(crawlerCfg);
+
+ // Should not throw NPE:
+ config.saveToXML(new StringWriter());
+ }
}