Return-Path: Delivered-To: apmail-incubator-abdera-commits-archive@locus.apache.org Received: (qmail 49126 invoked from network); 22 Aug 2006 00:14:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Aug 2006 00:14:27 -0000 Received: (qmail 6945 invoked by uid 500); 22 Aug 2006 00:14:27 -0000 Delivered-To: apmail-incubator-abdera-commits-archive@incubator.apache.org Received: (qmail 6929 invoked by uid 500); 22 Aug 2006 00:14:27 -0000 Mailing-List: contact abdera-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: abdera-dev@incubator.apache.org Delivered-To: mailing list abdera-commits@incubator.apache.org Received: (qmail 6919 invoked by uid 99); 22 Aug 2006 00:14:27 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Aug 2006 17:14:27 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Aug 2006 17:14:26 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 835AD1A981A; Mon, 21 Aug 2006 17:14:06 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r433438 - /incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/ServiceUtil.java Date: Tue, 22 Aug 2006 00:14:06 -0000 To: abdera-commits@incubator.apache.org From: rooneg@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060822001406.835AD1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: rooneg Date: Mon Aug 21 17:14:05 2006 New Revision: 433438 URL: http://svn.apache.org/viewvc?rev=433438&view=rev Log: Fix some obscure problems noticed by FindBugs and IDEA. * core/src/main/java/org/apache/abdera/util/ServiceUtil.java Import java.io.IOException. (locate, checkConfigProperties): Explicitly note that we're doing nothing in the catch blocks so IDEA will shut up. (checkMetaInfServices, _loadimpls): Close our input streams in the case of an exception, so we don't accidentally leak file handles. Also explicitly note that the empty catch blocks are desired. Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/ServiceUtil.java Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/ServiceUtil.java URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/ServiceUtil.java?rev=433438&r1=433437&r2=433438&view=diff ============================================================================== --- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/ServiceUtil.java (original) +++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/ServiceUtil.java Mon Aug 21 17:14:05 2006 @@ -20,6 +20,7 @@ import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.IOException; import java.net.URL; import java.util.ArrayList; import java.util.Enumeration; @@ -76,7 +77,9 @@ if (object == null && _default != null) { try { object = getClassLoader().loadClass(_default).newInstance(); - } catch (Exception e) {} + } catch (Exception e) { + // Nothing + } } return object; } @@ -92,7 +95,9 @@ if (s != null) { try { object = getClassLoader().loadClass(s).newInstance(); - } catch (Exception e) {} + } catch (Exception e) { + // Nothing + } } return object; } @@ -101,17 +106,28 @@ Object object = null; String sid = "META-INF/services/" + id; ClassLoader loader = getClassLoader(); + BufferedReader buf = null; try { InputStream is = loader.getResourceAsStream(sid); if (is != null) { - BufferedReader buf = new BufferedReader(new InputStreamReader(is)); + buf = new BufferedReader(new InputStreamReader(is)); String line = buf.readLine(); if (line != null) { String s = line.split("#",2)[0].trim(); object = loader.loadClass(s).newInstance(); } } - } catch (Exception e) {} + } catch (Exception e) { + // Nothing + } finally { + if (buf != null) { + try { + buf.close(); + } catch (IOException ioe) { + // Nothing + } + } + } return object; } @@ -127,20 +143,18 @@ @SuppressWarnings("unchecked") public static List _loadimpls(String sid) { - List impls = null; - impls = new ArrayList(); + List impls = new ArrayList(); ClassLoader loader = getClassLoader(); try { Enumeration e = loader.getResources(sid); for (;e.hasMoreElements();) { + BufferedReader buf = null; try { URL url = (URL) e.nextElement(); InputStream is = url.openStream(); if (is != null) { - BufferedReader buf = - new BufferedReader( - new InputStreamReader(is)); - String line = null; + buf = new BufferedReader(new InputStreamReader(is)); + String line; while ((line = buf.readLine()) != null) { String s = line.split("#",2)[0].trim(); if (!"".equals(s)) { @@ -149,9 +163,21 @@ } } } - } catch (Exception ex) {} + } catch (Exception ex) { + // Nothing + } finally { + if (buf != null) { + try { + buf.close(); + } catch (IOException ioe) { + // Nothing + } + } + } } - } catch (Exception e) {} + } catch (Exception e) { + // Nothing + } return impls; }