From 92f15137e304f2955fbea9950d0c12247754cec3 Mon Sep 17 00:00:00 2001 From: mdb Date: Wed, 16 Oct 2002 01:52:37 +0000 Subject: [PATCH] Work around a bug in Tomcat 3.3's class loader. git-svn-id: https://samskivert.googlecode.com/svn/trunk@866 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../java/com/samskivert/util/ConfigUtil.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/ConfigUtil.java b/projects/samskivert/src/java/com/samskivert/util/ConfigUtil.java index fda02f23..7966e8cb 100644 --- a/projects/samskivert/src/java/com/samskivert/util/ConfigUtil.java +++ b/projects/samskivert/src/java/com/samskivert/util/ConfigUtil.java @@ -1,5 +1,5 @@ // -// $Id: ConfigUtil.java,v 1.6 2002/01/29 23:19:41 mdb Exp $ +// $Id: ConfigUtil.java,v 1.7 2002/10/16 01:52:37 mdb Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -151,6 +151,24 @@ public class ConfigUtil rsrcs.add(enum.nextElement()); } + // if we found no resources in our enumerations, try loading the + // properties using getResource() rather than getResources(); this + // works around a bug in Tomcat 3.3's classloader wherein it + // simply returns nothing to all calls to getResources() + if (rsrcs.size() == 0) { + // if getResourceAsStream() returns something, but + // getResources() returned nothing, then we know there's a bug + // and we do our best to work around it + if (getResourceAsStream(path, loader) != null) { + Log.warning("Buggy classloader: getResources() returned " + + "no resources, but getResourceAsStream() " + + "returned a resource [path=" + path + + ", loader=" + loader.getClass().getName() + + "]. Returning the one we could get our hands on."); + return loadProperties(path, loader); + } + } + // now load each file in turn into our properties object Properties props = new Properties(); for (int i = rsrcs.size()-1; i >= 0; i--) {