Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 51469 invoked from network); 2 Mar 2006 10:02:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 Mar 2006 10:02:53 -0000 Received: (qmail 74409 invoked by uid 500); 2 Mar 2006 10:03:38 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 74085 invoked by uid 500); 2 Mar 2006 10:03:36 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 74074 invoked by uid 500); 2 Mar 2006 10:03:36 -0000 Received: (qmail 74071 invoked by uid 99); 2 Mar 2006 10:03:36 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Mar 2006 02:03:36 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 02 Mar 2006 02:03:35 -0800 Received: (qmail 51337 invoked by uid 65534); 2 Mar 2006 10:02:28 -0000 Message-ID: <20060302100228.51336.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r382339 - /jakarta/commons/proper/logging/contrib/simon/jcl2/src/core/java/org/apache/commons/logging/Utils.java Date: Thu, 02 Mar 2006 10:02:28 -0000 To: commons-cvs@jakarta.apache.org From: skitching@apache.org X-Mailer: svnmailer-1.0.7 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: skitching Date: Thu Mar 2 02:02:26 2006 New Revision: 382339 URL: http://svn.apache.org/viewcvs?rev=382339&view=rev Log: Fix bug when using explicit classloader to find java services file. Modified: jakarta/commons/proper/logging/contrib/simon/jcl2/src/core/java/org/apache/commons/logging/Utils.java Modified: jakarta/commons/proper/logging/contrib/simon/jcl2/src/core/java/org/apache/commons/logging/Utils.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/contrib/simon/jcl2/src/core/java/org/apache/commons/logging/Utils.java?rev=382339&r1=382338&r2=382339&view=diff ============================================================================== --- jakarta/commons/proper/logging/contrib/simon/jcl2/src/core/java/org/apache/commons/logging/Utils.java (original) +++ jakarta/commons/proper/logging/contrib/simon/jcl2/src/core/java/org/apache/commons/logging/Utils.java Thu Mar 2 02:02:26 2006 @@ -45,9 +45,10 @@ * META-INF/services/service.name where service.name * matches the fully qualified name of the provided base class. *

- * The file contains a single non-comment line containing the name of - * the concrete class. An instance of that type will be created, and - * returned. + * The file contains one or more non-comment lines containing the + * names of concrete classes that provide an implementation of the + * base class. An instance of the first-occurring class will be + * created and returned. *

* The classloader that is used as the base of the search for the * service file is the one that loaded the specified base class. The @@ -77,14 +78,19 @@ throws LogConfigurationException { String serviceName = baseClass.getName(); - String serviceFileName = "/META-INF/services/" + serviceName; + String serviceFileName = "META-INF/services/" + serviceName; InputStream is; if (baseLoader == null) { // Don't call baseClass.getClassLoader here, as that may cause // a SecurityException in some environments. Just use the method // on the Class object which should have the same effect. - is = baseClass.getResourceAsStream(serviceFileName); + // + // Note that when using Class.getResourceAsStream, we need a slash + // on the front of the path to prevent the class packagename being + // prefixed to the resource. However we must NOT put a slash on the + // front when using ClassLoader.getResourceAsStream! + is = baseClass.getResourceAsStream("/" + serviceFileName); } else { is = baseLoader.getResourceAsStream(serviceFileName); } --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org