From 9c24d662337f0c2043fbd8e6dc7a91fb2b299dff Mon Sep 17 00:00:00 2001 From: Lianhao Lu Date: Fri, 12 Apr 2019 08:53:46 +0800 Subject: Fix sonnar issues Change-Id: Ic9ad2d733ace26fdd085a03af901783192d72a79 Issue-ID: POLICY-1638 Signed-off-by: Lianhao Lu --- .../handling/file/FileSystemReceptionHandler.java | 26 ++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'plugins/reception-plugins/src/main/java/org') diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java index 56bca900..72341ee5 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java @@ -115,8 +115,7 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler { */ @SuppressWarnings("unchecked") protected void startWatchService(final WatchService watcher, - final Path dir, - int maxThread) throws InterruptedException, NullPointerException, IllegalArgumentException { + final Path dir, int maxThread) throws InterruptedException { WatchKey key; ExecutorService pool = Executors.newFixedThreadPool(maxThread); @@ -128,18 +127,17 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler { for (final WatchEvent event : key.pollEvents()) { final WatchEvent ev = (WatchEvent) event; final Path fileName = ev.context(); - pool.execute(new Runnable() { - public void run() { - LOGGER.debug("new CSAR found: {}", fileName); - DistributionStatisticsManager.updateTotalDistributionCount(); - final String fullFilePath = dir.toString() + File.separator + fileName.toString(); - try { - waitForFileToBeReady(fullFilePath); - createPolicyInputAndCallHandler(fullFilePath); - LOGGER.debug("CSAR complete: {}", fileName); - } catch (InterruptedException e) { - LOGGER.error("waitForFileToBeReady interrupted", e); - } + pool.execute(() -> { + LOGGER.debug("new CSAR found: {}", fileName); + DistributionStatisticsManager.updateTotalDistributionCount(); + final String fullFilePath = dir.toString() + File.separator + fileName.toString(); + try { + waitForFileToBeReady(fullFilePath); + createPolicyInputAndCallHandler(fullFilePath); + LOGGER.debug("CSAR complete: {}", fileName); + } catch (InterruptedException e) { + LOGGER.error("waitForFileToBeReady interrupted", e); + Thread.currentThread().interrupt(); } }); } -- cgit 1.2.3-korg