openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r956757 - in /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql: DB2Dictionary.java DBDictionary.java
Date Tue, 22 Jun 2010 01:20:04 GMT
Author: dwoods
Date: Tue Jun 22 01:20:03 2010
New Revision: 956757

URL: http://svn.apache.org/viewvc?rev=956757&view=rev
Log:
OPENJPA-1700 FindBugs - Method may fail to clean up stream or resource

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=956757&r1=956756&r2=956757&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Tue Jun 22 01:20:03 2010
@@ -273,20 +273,25 @@ public class DB2Dictionary
         super.connectedConfiguration(conn);
 
         DatabaseMetaData metaData = conn.getMetaData();
+        Statement stmnt = null;	
+        ResultSet rs =null;
         try {
             String str = "SELECT CURRENT SCHEMA FROM SYSIBM.SYSDUMMY1";
-            Statement stmnt = conn.createStatement();
-            ResultSet rs = stmnt.executeQuery(str);
+            stmnt = conn.createStatement();
+            rs = stmnt.executeQuery(str);
             if (rs.next()) {
                 String currSchema = rs.getString(1);
                 if (currSchema != null)
                     setDefaultSchemaName(currSchema.trim());
             }
-            rs.close();
-            stmnt.close();
         } catch (SQLException e) {
             if (log.isTraceEnabled())
                 log.trace(_loc.get("can_not_get_current_schema", e.getMessage()));
+        } finally {
+            if (rs != null)
+                rs.close();
+            if (stmnt != null)
+                stmnt.close();
         }
 
         String driverName = metaData.getDriverName();

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=956757&r1=956756&r2=956757&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Tue Jun 22 01:20:03 2010
@@ -4581,7 +4581,6 @@ public class DBDictionary
         try {
             String keywords = new BufferedReader(new InputStreamReader(in)).
                 readLine();
-            in.close();
             reservedWordSet.addAll(Arrays.asList(Strings.split
                 (keywords, ",", 0)));
         } catch (IOException ioe) {



Mime
View raw message