You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2020/02/02 19:17:51 UTC

[maven-indexer] 01/01: Fix race condition in FileResource

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch pull/42
in repository https://gitbox.apache.org/repos/asf/maven-indexer.git

commit 771199533fa07beab318bf31d9dd3825ffadaa9c
Author: sixcorners <si...@gmail.com>
AuthorDate: Sun Feb 2 09:06:42 2020 -0600

    Fix race condition in FileResource
    
    Closes #42
---
 .../org/apache/maven/index/reader/DirectoryResourceHandler.java     | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/indexer-reader/src/test/java/org/apache/maven/index/reader/DirectoryResourceHandler.java b/indexer-reader/src/test/java/org/apache/maven/index/reader/DirectoryResourceHandler.java
index aea0ee1..c799034 100644
--- a/indexer-reader/src/test/java/org/apache/maven/index/reader/DirectoryResourceHandler.java
+++ b/indexer-reader/src/test/java/org/apache/maven/index/reader/DirectoryResourceHandler.java
@@ -23,6 +23,7 @@ import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -69,10 +70,11 @@ public class DirectoryResourceHandler
     }
 
     public InputStream read() throws IOException {
-      if (file.isFile()) {
+      try {
         return new BufferedInputStream(new FileInputStream(file));
+      } catch (FileNotFoundException e) {
+        return null;
       }
-      return null;
     }
 
     public OutputStream write() throws IOException {