You are viewing a plain text version of this content. The canonical link for it is here.
Posted to svn@forrest.apache.org by th...@apache.org on 2006/08/04 13:41:39 UTC
svn commit: r428699 -
/forrest/trunk/main/java/org/apache/forrest/conf/ForrestConfModule.java
Author: thorsten
Date: Fri Aug 4 04:41:38 2006
New Revision: 428699
URL: http://svn.apache.org/viewvc?rev=428699&view=rev
Log:
FOR-914 [Java Coding] Do not raise exception when you can prevent them
Enhancing the code of the forrestConfModule.
Modified:
forrest/trunk/main/java/org/apache/forrest/conf/ForrestConfModule.java
Modified: forrest/trunk/main/java/org/apache/forrest/conf/ForrestConfModule.java
URL: http://svn.apache.org/viewvc/forrest/trunk/main/java/org/apache/forrest/conf/ForrestConfModule.java?rev=428699&r1=428698&r2=428699&view=diff
==============================================================================
--- forrest/trunk/main/java/org/apache/forrest/conf/ForrestConfModule.java (original)
+++ forrest/trunk/main/java/org/apache/forrest/conf/ForrestConfModule.java Fri Aug 4 04:41:38 2006
@@ -136,45 +136,26 @@
filteringProperties = loadXMLPropertiesFromURI(filteringProperties,
forrestPropertiesStringURI);
- } catch (FileNotFoundException e) {
- if (debugging())
- debug("Unable to find local.forrest.properties.xml, ignoring.");
- }
// get the values from forrest.properties.xml
- try {
forrestPropertiesStringURI = projectHome + SystemUtils.FILE_SEPARATOR
+ "forrest.properties.xml";
filteringProperties = loadXMLPropertiesFromURI(filteringProperties,
forrestPropertiesStringURI);
- } catch (FileNotFoundException e) {
- if (debugging())
- debug("Unable to find forrest.properties.xml, ignoring.");
- }
// get the values from default.forrest.properties.xml
- try {
forrestPropertiesStringURI = contextHome + SystemUtils.FILE_SEPARATOR
+ "default.forrest.properties.xml";
filteringProperties = loadXMLPropertiesFromURI(filteringProperties,
forrestPropertiesStringURI);
- } catch (FileNotFoundException e) {
- if (debugging())
- debug("Unable to find default.forrest.properties.xml, ignoring.");
- }
// get forrest.properties and load the values
- try {
forrestPropertiesStringURI = projectHome + SystemUtils.FILE_SEPARATOR
+ "forrest.properties";
filteringProperties = loadAntPropertiesFromURI(filteringProperties,
forrestPropertiesStringURI);
- } catch (FileNotFoundException e) {
- if (debugging())
- debug("Unable to find forrest.properties, using defaults.");
- }
// get default-forrest.properties and load the values
String defaultForrestPropertiesStringURI = contextHome + SystemUtils.FILE_SEPARATOR
@@ -188,18 +169,15 @@
StringTokenizer st = new StringTokenizer(strPluginList, ",");
while (st.hasMoreTokens()) {
forrestPropertiesStringURI = ForrestConfUtils.getPluginDir(st.nextToken().trim());
- try {
forrestPropertiesStringURI = forrestPropertiesStringURI
+ SystemUtils.FILE_SEPARATOR + "default.plugin.properties.xml";
filteringProperties = loadXMLPropertiesFromURI(filteringProperties,
forrestPropertiesStringURI);
- } catch (FileNotFoundException e) {
- if (debugging())
- debug("Unable to load " + forrestPropertiesStringURI + ", ignoring. "
- + e.getMessage());
- }
}
}
+ } catch (Exception e) {
+ getLogger().error("Opps, something went wrong.",e);
+ }
loadSystemProperties(filteringProperties);
ForrestConfUtils.aliasSkinProperties(filteringProperties);
@@ -259,9 +237,9 @@
InputStream in = null;
try {
source = m_resolver.resolveURI(propertiesStringURI);
+ if (debugging())
+ debug("Searching for forrest.properties.xml in " + source.getURI());
if (source.exists()){
- if (debugging())
- debug("Searching for forrest.properties.xml in " + source.getURI());
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
@@ -278,7 +256,8 @@
if (debugging())
debug("Loaded:" + propertiesStringURI + filteringProperties.toString());
- }
+ }else if (debugging())
+ debug("Unable to find "+source.getURI()+", ignoring.");
} finally {
if (source != null) {
@@ -308,17 +287,17 @@
Source source = null;
InputStream in = null;
try {
-
source = m_resolver.resolveURI(antPropertiesStringURI);
-
if (debugging())
debug("Searching for forrest.properties in" + source.getURI());
- in = source.getInputStream();
- filteringProperties = new AntProperties(precedingProperties);
- filteringProperties.load(in);
+ if (source.exists()){
+ in = source.getInputStream();
+ filteringProperties = new AntProperties(precedingProperties);
+ filteringProperties.load(in);
- if (debugging())
- debug("Loaded:" + antPropertiesStringURI + filteringProperties.toString());
+ if (debugging())
+ debug("Loaded:" + antPropertiesStringURI + filteringProperties.toString());
+ }
} finally {
if (source != null) {
Re: svn commit: r428699 -
/forrest/trunk/main/java/org/apache/forrest/conf/ForrestConfModule.java
Posted by Thorsten Scherler <th...@wyona.com>.
El vie, 04-08-2006 a las 13:44 +0100, Ross Gardler escribió:
> thorsten@apache.org wrote:
> > Author: thorsten
> > Date: Fri Aug 4 04:41:38 2006
> > New Revision: 428699
>
> ...
>
> > + } catch (Exception e) {
> > + getLogger().error("Opps, something went wrong.",e);
> > + }
>
> -1 (to this addition only, other changes in this commit are OK - see
> discussion thread)
>
> This chage is swallowing exceptions and preventing Cocoon reporting them
> to the user.
>
Forgot to throw them, thx for pointing out.
salu2
--
Thorsten Scherler
COO Spain
Wyona Inc. - Open Source Content Management - Apache Lenya
http://www.wyona.com http://lenya.apache.org
thorsten.scherler@wyona.com thorsten@apache.org
Re: svn commit: r428699 - /forrest/trunk/main/java/org/apache/forrest/conf/ForrestConfModule.java
Posted by Ross Gardler <rg...@apache.org>.
thorsten@apache.org wrote:
> Author: thorsten
> Date: Fri Aug 4 04:41:38 2006
> New Revision: 428699
...
> + } catch (Exception e) {
> + getLogger().error("Opps, something went wrong.",e);
> + }
-1 (to this addition only, other changes in this commit are OK - see
discussion thread)
This chage is swallowing exceptions and preventing Cocoon reporting them
to the user.
Ross