geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johndam...@apache.org
Subject svn commit: r1811787 - in /geronimo/components/config/trunk/impl/src: main/java/org/apache/geronimo/config/configsource/PropertyFileConfigSource.java test/java/org/apache/geronimo/config/test/internal/PropertyFileConfigSourceTest.java
Date Wed, 11 Oct 2017 03:17:10 GMT
Author: johndament
Date: Wed Oct 11 03:17:09 2017
New Revision: 1811787

URL: http://svn.apache.org/viewvc?rev=1811787&view=rev
Log:
GERONIMO-6592 - Don't return null for the loaded properties, just empty map.  Also log the
issue, so the user is aware of the problem.

Added:
    geronimo/components/config/trunk/impl/src/test/java/org/apache/geronimo/config/test/internal/PropertyFileConfigSourceTest.java
Modified:
    geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/configsource/PropertyFileConfigSource.java

Modified: geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/configsource/PropertyFileConfigSource.java
URL: http://svn.apache.org/viewvc/geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/configsource/PropertyFileConfigSource.java?rev=1811787&r1=1811786&r2=1811787&view=diff
==============================================================================
--- geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/configsource/PropertyFileConfigSource.java
(original)
+++ geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/configsource/PropertyFileConfigSource.java
Wed Oct 11 03:17:09 2017
@@ -21,16 +21,14 @@ import java.io.InputStream;
 import java.net.URL;
 import java.util.Map;
 import java.util.Properties;
-
-import javax.enterprise.inject.Typed;
-import javax.enterprise.inject.Vetoed;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 /**
  * @author <a href="mailto:struberg@apache.org">Mark Struberg</a>
  */
-@Typed
-@Vetoed
 public class PropertyFileConfigSource extends BaseConfigSource {
+    private static final Logger LOG = Logger.getLogger(PropertyFileConfigSource.class.getName());
     private Map<String, String> properties;
     private String fileName;
 
@@ -74,7 +72,8 @@ public class PropertyFileConfigSource ex
             }
         }
         catch (IOException e) {
-            return null;
+            // don't return null on IOException
+            LOG.log(Level.WARNING, "Unable to read URL "+url, e);
         }
         finally {
             try {

Added: geronimo/components/config/trunk/impl/src/test/java/org/apache/geronimo/config/test/internal/PropertyFileConfigSourceTest.java
URL: http://svn.apache.org/viewvc/geronimo/components/config/trunk/impl/src/test/java/org/apache/geronimo/config/test/internal/PropertyFileConfigSourceTest.java?rev=1811787&view=auto
==============================================================================
--- geronimo/components/config/trunk/impl/src/test/java/org/apache/geronimo/config/test/internal/PropertyFileConfigSourceTest.java
(added)
+++ geronimo/components/config/trunk/impl/src/test/java/org/apache/geronimo/config/test/internal/PropertyFileConfigSourceTest.java
Wed Oct 11 03:17:09 2017
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.config.test.internal;
+
+import org.apache.geronimo.config.configsource.PropertyFileConfigSource;
+import org.testng.annotations.Test;
+
+import java.net.URL;
+import java.nio.file.Paths;
+
+import static org.testng.AssertJUnit.assertTrue;
+
+public class PropertyFileConfigSourceTest {
+    @Test
+    public void testLoadMissingFile() throws Exception{
+        URL url = Paths.get("some/missing/File.txt").toUri().toURL();
+        PropertyFileConfigSource propertyFileConfigSource = new PropertyFileConfigSource(url);
+        assertTrue(propertyFileConfigSource.getProperties().isEmpty());
+    }
+}



Mime
View raw message