cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/acting ImageUploadAction.java
Date Mon, 26 Feb 2001 17:43:00 GMT
bloritsch    01/02/26 09:43:00

  Modified:    src/org/apache/cocoon/acting Tag: xml-cocoon2
                        ImageUploadAction.java
  Log:
  Make sure that the FileInputStream is closed before I try to delete the File.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.5   +5 -2      xml-cocoon/src/org/apache/cocoon/acting/Attic/ImageUploadAction.java
  
  Index: ImageUploadAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/acting/Attic/ImageUploadAction.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- ImageUploadAction.java	2001/02/23 22:34:45	1.1.2.4
  +++ ImageUploadAction.java	2001/02/26 17:42:57	1.1.2.5
  @@ -48,7 +48,7 @@
    * at this time.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2001/02/23 22:34:45 $
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2001/02/26 17:42:57 $
    */
   public class ImageUploadAction extends ComposerAction implements Contextualizable {
       private final static int SIZE = 0;
  @@ -162,6 +162,7 @@
           }
   
           File image = null;
  +        FileInputStream imageStream = null;
   
           try {
               PreparedStatement statement = conn.prepareStatement(query);
  @@ -172,8 +173,9 @@
               int [] dimensions = ImageDirectoryGenerator.getSize(image);
               paramValues[ImageUploadAction.WIDTH] = dimensions[0];
               paramValues[ImageUploadAction.HEIGHT] = dimensions[1];
  +            imageStream = new FileInputStream(image);
   
  -            statement.setBinaryStream(1, new FileInputStream(image), paramValues[ImageUploadAction.SIZE]);
  +            statement.setBinaryStream(1, imageStream, paramValues[ImageUploadAction.SIZE]);
   
               int maxIndex = 1;
               for (int i = 0; i < ImageUploadAction.NUM_PARAMS; i++) {
  @@ -196,6 +198,7 @@
           } catch (Exception e) {
               getLogger().warn("Could not commit file: " + query, e);
           } finally {
  +            if (imageStream != null) imageStream.close();
               if (image != null) image.delete();
   
               try {
  
  
  

Mime
View raw message