JAMES-2004 Fail when file not found in PropertiesProvider

Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/9f7a4dc0
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/9f7a4dc0
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/9f7a4dc0

Branch: refs/heads/master
Commit: 9f7a4dc0c848042459f259192b8f50c813543830
Parents: fec6a27
Author: benwa <btell...@linagora.com>
Authored: Tue Apr 18 12:37:55 2017 +0700
Committer: benwa <btell...@linagora.com>
Committed: Fri Apr 21 08:27:41 2017 +0700

----------------------------------------------------------------------
 .../main/java/org/apache/james/utils/PropertiesProvider.java  | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/9f7a4dc0/server/container/guice/configuration/src/main/java/org/apache/james/utils/PropertiesProvider.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/configuration/src/main/java/org/apache/james/utils/PropertiesProvider.java
 
b/server/container/guice/configuration/src/main/java/org/apache/james/utils/PropertiesProvider.java
index 780b5ee..d9a090a 100644
--- 
a/server/container/guice/configuration/src/main/java/org/apache/james/utils/PropertiesProvider.java
+++ 
b/server/container/guice/configuration/src/main/java/org/apache/james/utils/PropertiesProvider.java
@@ -19,6 +19,7 @@
 
 package org.apache.james.utils;
 
+import java.io.File;
 import java.io.FileNotFoundException;
 
 import javax.inject.Inject;
@@ -41,6 +42,10 @@ public class PropertiesProvider {
 
     public PropertiesConfiguration getConfiguration(String fileName) throws 
FileNotFoundException, ConfigurationException {
         Preconditions.checkArgument(!Strings.isNullOrEmpty(fileName));
-        return new 
PropertiesConfiguration(fileSystem.getFile(FileSystem.FILE_PROTOCOL_AND_CONF + 
fileName + ".properties"));
+        File file = fileSystem.getFile(FileSystem.FILE_PROTOCOL_AND_CONF + 
fileName + ".properties");
+        if (!file.exists()) {
+            throw new FileNotFoundException();
+        }
+        return new PropertiesConfiguration(file);
     }
 }
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to