From b3980acbf5621cf48b173ff4a5ca53a0d329d3d9 Mon Sep 17 00:00:00 2001 From: Jeremy Long Date: Sat, 7 Dec 2013 13:25:34 -0500 Subject: [PATCH] Changed order to prevent blocking, CallableDownloadTasks automatically submit the results to the process executor queue now Former-commit-id: 536fd58f195fd46de16d56064453409d0e39536b --- .../data/update/CallableDownloadTask.java | 19 ++++++++++++++----- .../data/update/StandardUpdate.java | 10 +--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/update/CallableDownloadTask.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/update/CallableDownloadTask.java index c766a3974..29d17c618 100644 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/update/CallableDownloadTask.java +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/update/CallableDownloadTask.java @@ -19,12 +19,14 @@ package org.owasp.dependencycheck.data.update; import java.io.File; +import java.io.IOException; import java.net.URL; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.logging.Level; import java.util.logging.Logger; +import org.owasp.dependencycheck.data.UpdateException; import org.owasp.dependencycheck.data.nvdcve.CveDB; import org.owasp.dependencycheck.utils.DownloadFailedException; import org.owasp.dependencycheck.utils.Downloader; @@ -40,15 +42,22 @@ public class CallableDownloadTask implements Callable> { * Simple constructor for the callable download task. * * @param nvdCveInfo the NVD CVE info - * @param first the first file - * @param second the second file * @param processor the processor service to submit the downloaded files to * @param cveDB the CVE DB to use to store the vulnerability data */ - public CallableDownloadTask(NvdCveInfo nvdCveInfo, File first, File second, ExecutorService processor, CveDB cveDB, DataStoreMetaInfo properties) { + public CallableDownloadTask(NvdCveInfo nvdCveInfo, ExecutorService processor, CveDB cveDB, DataStoreMetaInfo properties) throws UpdateException { + final File file1; + final File file2; + try { + file1 = File.createTempFile("cve" + nvdCveInfo.getId() + "_", ".xml"); + file2 = File.createTempFile("cve_1_2_" + nvdCveInfo.getId() + "_", ".xml"); + } catch (IOException ex) { + throw new UpdateException(ex); + } + this.nvdCveInfo = nvdCveInfo; - this.first = first; - this.second = second; + this.first = file1; + this.second = file2; this.processorService = processor; this.cveDB = cveDB; this.properties = properties; diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/update/StandardUpdate.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/update/StandardUpdate.java index f155b947e..1a8109372 100644 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/update/StandardUpdate.java +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/update/StandardUpdate.java @@ -148,15 +148,7 @@ public class StandardUpdate { final Set>> downloadFutures = new HashSet>>(maxUpdates); for (NvdCveInfo cve : updateable) { if (cve.getNeedsUpdate()) { - final File file1; - final File file2; - try { - file1 = File.createTempFile("cve" + cve.getId() + "_", ".xml"); - file2 = File.createTempFile("cve_1_2_" + cve.getId() + "_", ".xml"); - } catch (IOException ex) { - throw new UpdateException(ex); - } - final CallableDownloadTask call = new CallableDownloadTask(cve, file1, file2, processExecutor, cveDB, properties); + final CallableDownloadTask call = new CallableDownloadTask(cve, processExecutor, cveDB, properties); downloadFutures.add(downloadExecutors.submit(call)); } }