Revision: 9116
Author: [email protected]
Date: Tue Oct 19 09:23:31 2010
Log: check the return value of ImageIO.write

Review at http://gwt-code-reviews.appspot.com/1030801

Review by: [email protected]
http://code.google.com/p/google-web-toolkit/source/detail?r=9116

Modified:
 /trunk/user/src/com/google/gwt/resources/rg/ImageBundleBuilder.java
 /trunk/user/src/com/google/gwt/user/rebind/ui/ImageBundleBuilder.java

=======================================
--- /trunk/user/src/com/google/gwt/resources/rg/ImageBundleBuilder.java Tue Aug 31 14:51:43 2010 +++ /trunk/user/src/com/google/gwt/resources/rg/ImageBundleBuilder.java Tue Oct 19 09:23:31 2010
@@ -555,11 +555,17 @@

     try {
       ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
-      ImageIO.write(bundledImage, BUNDLE_FILE_TYPE, byteOutputStream);
+ boolean writerAvailable = ImageIO.write(bundledImage, BUNDLE_FILE_TYPE,
+          byteOutputStream);
+      if (!writerAvailable) {
+        logger.log(TreeLogger.ERROR, "No " + BUNDLE_FILE_TYPE
+            + " writer available");
+        throw new UnableToCompleteException();
+      }
       imageBytes = byteOutputStream.toByteArray();
     } catch (IOException e) {
       logger.log(TreeLogger.ERROR,
-          "Unable to generate file name for image bundle file", null);
+          "An error occurred while trying to write the image bundle.", e);
       throw new UnableToCompleteException();
     }
     return imageBytes;
=======================================
--- /trunk/user/src/com/google/gwt/user/rebind/ui/ImageBundleBuilder.java Tue Aug 31 14:51:43 2010 +++ /trunk/user/src/com/google/gwt/user/rebind/ui/ImageBundleBuilder.java Tue Oct 19 09:23:31 2010
@@ -326,11 +326,17 @@

     try {
       ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
-      ImageIO.write(bundledImage, BUNDLE_FILE_TYPE, byteOutputStream);
+ boolean writerAvailable = ImageIO.write(bundledImage, BUNDLE_FILE_TYPE,
+          byteOutputStream);
+      if (!writerAvailable) {
+        logger.log(TreeLogger.ERROR, "No " + BUNDLE_FILE_TYPE
+            + " writer available");
+        throw new UnableToCompleteException();
+      }
       imageBytes = byteOutputStream.toByteArray();
     } catch (IOException e) {
       logger.log(TreeLogger.ERROR,
-          "Unable to generate file name for image bundle file", null);
+          "An error occurred while trying to write the image bundle.", e);
       throw new UnableToCompleteException();
     }

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to