Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
essiembre committed Nov 17, 2018
2 parents 870b9be + 292a427 commit d95e617
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 11 deletions.
6 changes: 3 additions & 3 deletions norconex-collector-filesystem/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.norconex.collectors</groupId>
<artifactId>norconex-collector-filesystem</artifactId>
<version>2.8.0</version>
<version>2.8.1-SNAPSHOT</version>
<name>Norconex Filesystem Collector</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<site.baseurl/>
<norconex-commons-lang.version>1.14.0</norconex-commons-lang.version>
<norconex-commons-lang.version>1.14.1-SNAPSHOT</norconex-commons-lang.version>
</properties>
<inceptionYear>2014</inceptionYear>

Expand Down Expand Up @@ -72,7 +72,7 @@
<dependency>
<groupId>com.norconex.collectors</groupId>
<artifactId>norconex-collector-core</artifactId>
<version>1.9.0</version>
<version>1.9.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
11 changes: 11 additions & 0 deletions norconex-collector-filesystem/src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
</properties>
<body>

<release version="2.8.1-SNAPSHOT" date="2018-??-??" description="Maintenance release">
<action dev="essiembre" type="update">
Dependency updates: Norconex Collector Core 1.9.1,
Norconex Commons Lang 1.14.1.
</action>
<action dev="essiembre" type="fix" issue="29">
Fixed NullPointerException under some conditions for
FilesystemCrawlerConfig#saveToXML(...).
</action>
</release>

<release version="2.8.0" date="2017-11-26" description="Feature release">
<action dev="essiembre" type="add">
Several new features (new TruncateTagger, ExternalTagger, etc.) are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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());
}
}

0 comments on commit d95e617

Please sign in to comment.