Deal with case of no block list

This commit is contained in:
Sean Owen 2014-01-22 21:11:36 +00:00
parent 5a6982f301
commit 62cf0ade90

View file

@ -57,10 +57,10 @@ import java.net.MalformedURLException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.Map; import java.util.Map;
@ -115,14 +115,18 @@ public final class DecodeServlet extends HttpServlet {
diskFileItemFactory = new DiskFileItemFactory(1 << 16, repository); diskFileItemFactory = new DiskFileItemFactory(1 << 16, repository);
diskFileItemFactory.setFileCleaningTracker(fileCleaningTracker); diskFileItemFactory.setFileCleaningTracker(fileCleaningTracker);
URL blockURL = context.getClassLoader().getResource("/private/uri-block-substrings.txt");
if (blockURL == null) {
blockedURLSubstrings = Collections.emptyList();
} else {
try { try {
blockedURLSubstrings = blockedURLSubstrings = Resources.readLines(blockURL, StandardCharsets.UTF_8);
Resources.readLines(Resources.getResource("/private/uri-block-substrings.txt"), StandardCharsets.UTF_8);
} catch (IOException ioe) { } catch (IOException ioe) {
throw new ServletException(ioe); throw new ServletException(ioe);
} }
log.info("Blocking URIs containing: " + blockedURLSubstrings); log.info("Blocking URIs containing: " + blockedURLSubstrings);
} }
}
@Override @Override
protected void doGet(HttpServletRequest request, protected void doGet(HttpServletRequest request,