Author: antonio
Date: Fri Jan 21 12:50:08 2005
New Revision: 125961

URL: http://svn.apache.org/viewcvs?view=rev&rev=125961
Log:
Close the Readers in finally{}
Modified:
   
cocoon/branches/BRANCH_2_1_X/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/EsqlHelper.java

Modified: 
cocoon/branches/BRANCH_2_1_X/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/EsqlHelper.java
Url: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/EsqlHelper.java?view=diff&rev=125961&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/EsqlHelper.java&r1=125960&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/EsqlHelper.java&r2=125961
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/EsqlHelper.java
     (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/EsqlHelper.java
     Fri Jan 21 12:50:08 2005
@@ -38,19 +38,15 @@
 
 public class EsqlHelper {
 
-    //private static Boolean TRUE = Boolean.TRUE;
-
     /** returns byte array from BLOB
      */
     public final static byte[] getBlob(ResultSet set, String column) throws 
RuntimeException {
 
-        byte[] result = null;
         try {
-            result = EsqlHelper.getBlob(set, set.findColumn(column));
+            return EsqlHelper.getBlob(set, set.findColumn(column));
         } catch (Exception e) {
             throw new CascadingRuntimeException("Error getting blob data for 
column " + column, e);
         }
-        return result;
     }
 
     /** returns byte array from BLOB
@@ -138,13 +134,11 @@
     public final static String getStringOrClob(ResultSet set, String column, 
String defaultString)
         throws RuntimeException {
 
-        String result = null;
         try {
-            result = EsqlHelper.getStringOrClob(set, set.findColumn(column), 
defaultString);
+            return EsqlHelper.getStringOrClob(set, set.findColumn(column), 
defaultString);
         } catch (Exception e) {
             throw new CascadingRuntimeException("Error getting text from 
column " + column, e);
         }
-        return result;
     }
 
     /** returns Unicode encoded string from CLOB or String column 
@@ -164,10 +158,6 @@
                 reader = new BufferedReader(dbClob.getCharacterStream());
                 buffer = new char[length];
                 reader.read(buffer);
-                reader.close();
-                if (reader != null) {
-                    reader.close();
-                }
                 if (buffer != null) {
                     result = new String(buffer);
                 } else if (defaultString != null && 
!defaultString.equals("_null_")) {
@@ -183,6 +173,9 @@
         } catch (Exception e) {
             throw new CascadingRuntimeException("Error getting text from 
column " + column, e);
         } finally {
+            if (reader != null) {
+                reader.close();
+            }
             // ORACLE 'temporary lob' problem patch start
             if (dbClob != null && 
dbClob.getClass().getName().equals("oracle.sql.CLOB")) {
                 try {
@@ -222,10 +215,6 @@
             reader = new BufferedReader(dbClob.getCharacterStream());
             buffer = new char[length];
             reader.read(buffer);
-            reader.close();
-            if (reader != null) {
-                reader.close();
-            }
             if (buffer != null) {
                 result = new String(buffer);
             } else if (defaultString != null && 
!defaultString.equals("_null_")) {
@@ -236,6 +225,9 @@
         } catch (Exception e) {
             throw new CascadingRuntimeException("Error getting text from 
column " + column, e);
         } finally {
+            if (reader != null) {
+                reader.close();
+            }
             // ORACLE 'temporary lob' problem patch start
             if (dbClob != null && 
dbClob.getClass().getName().equals("oracle.sql.CLOB")) {
                 try {
@@ -260,13 +252,12 @@
     public final static String getAscii(ResultSet set, String column, String 
defaultString)
         throws RuntimeException {
 
-        String result = null;
         try {
-            result = EsqlHelper.getAscii(set, set.findColumn(column), 
defaultString);
+            int colIndex = set.findColumn(column);
+            return EsqlHelper.getAscii(set, colIndex, defaultString);
         } catch (Exception e) {
             throw new CascadingRuntimeException("Error getting ascii data for 
column " + column, e);
         }
-        return result;
     }
 
     /** returns ascii string from CLOB or String column 
@@ -325,7 +316,6 @@
                     // swallow
                 }
             }
-
         }
         return result;
     }
@@ -400,5 +390,4 @@
             }
         }
     }
-
 }

Reply via email to