I'm looking at applying your faster schema resolver code, as I have put xml parser back in.
http://jira.jboss.com/jira/browse/JBRULES-235
So I added in your code as shown, non of the replacements throw exceptions this one:
        // Try current working directory
       {
           File file = new File(xsd);
           if(file.exists()) {
return new InputSource(new BufferedInputStream(new FileInputStream(file)));
           }
        }.

Shouldn't we try/catch this, as we don't wanto this exception bubbling up to the user? Or is the theory on this one that we already know the file exists, thus FileInputStream(...) won't fail - must admit I'm not entirely comfortable with that idea.

Mark
----------------------------------------------

### Eclipse Workspace Patch 1.0
#P drools
Index: drools-io/src/main/org/drools/io/RuleSetReader.java
===================================================================
RCS file: 
/home/projects/drools/scm/drools/drools-io/src/main/org/drools/io/RuleSetReader.java,v
retrieving revision 1.54
diff -u -r1.54 RuleSetReader.java
--- drools-io/src/main/org/drools/io/RuleSetReader.java 6 Jan 2006 13:35:23 
-0000       1.54
+++ drools-io/src/main/org/drools/io/RuleSetReader.java 15 Mar 2006 22:01:04 
-0000
@@ -39,6 +39,7 @@
 */

import java.io.BufferedInputStream;
+import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -982,56 +983,63 @@
        }
// Try looking in META-INF
-        try {
-            return new InputSource(cl.getResourceAsStream("META-INF/" + xsd));
-        } catch (Exception e) {
+        {
+               InputStream is = cl.getResourceAsStream("META-INF/" + xsd);
+               if(is != null) {
+                       return new InputSource(is);
+               }
        }
// Try looking in /META-INF
-        try {
-            return new InputSource(cl.getResourceAsStream("/META-INF/" + xsd));
-        } catch (Exception e) {
+        {
+               InputStream is = cl.getResourceAsStream("/META-INF/" + xsd);
+               if(is != null) {
+                       return new InputSource(is);
+               }
        }
// Try looking at root of classpath
-        try {
-            return new InputSource(cl.getResourceAsStream("/" + xsd));
-        } catch (Exception e) {
+        {
+               InputStream is = cl.getResourceAsStream("/" + xsd);
+               if(is != null) {
+                       return new InputSource(is);
+               }
        }
// Try current working directory
-        try {
-            return new InputSource(new BufferedInputStream(new FileInputStream(
-                    xsd)));
-        } catch (Exception e) {
+        {
+               File file = new File(xsd);
+               if(file.exists()) {
+                       return new InputSource(new BufferedInputStream(new 
FileInputStream(file)));
+               }
        }
cl = ClassLoader.getSystemClassLoader(); // Try looking in META-INF
-        try {
-            return new InputSource(cl.getResourceAsStream("META-INF/" + xsd));
-        } catch (Exception e) {
+        {
+               InputStream is = cl.getResourceAsStream("META-INF/" + xsd);
+               if(is != null) {
+                       return new InputSource(is);
+               }
        }
// Try looking in /META-INF
-        try {
-            return new InputSource(cl.getResourceAsStream("/META-INF/" + xsd));
-        } catch (Exception e) {
+        {
+               InputStream is = cl.getResourceAsStream("/META-INF/" + xsd);
+               if(is != null) {
+                       return new InputSource(is);
+               }
        }
// Try looking at root of classpath
-        try {
-            return new InputSource(cl.getResourceAsStream("/" + xsd));
-        } catch (Exception e) {
+        {
+               InputStream is = cl.getResourceAsStream("/" + xsd);
+               if(is != null) {
+                       return new InputSource(is);
+               }
        }
- // Try current working directory
-        try {
-            return new InputSource(new BufferedInputStream(new FileInputStream(
-                    xsd)));
-        } catch (Exception e) {
-        }
        return null;
}

Reply via email to