Author: antonio Date: Sun May 1 10:14:26 2005 New Revision: 165526 URL: http://svn.apache.org/viewcvs?rev=165526&view=rev Log: Don't check for 4502892. It is fixed in java 1.4
Modified: cocoon/trunk/src/java/org/apache/cocoon/reading/ImageReader.java Modified: cocoon/trunk/src/java/org/apache/cocoon/reading/ImageReader.java URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/reading/ImageReader.java?rev=165526&r1=165525&r2=165526&view=diff ============================================================================== --- cocoon/trunk/src/java/org/apache/cocoon/reading/ImageReader.java (original) +++ cocoon/trunk/src/java/org/apache/cocoon/reading/ImageReader.java Sun May 1 10:14:26 2005 @@ -31,7 +31,6 @@ import org.apache.avalon.framework.parameters.Parameters; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.environment.SourceResolver; -import org.apache.commons.lang.SystemUtils; import org.xml.sax.SAXException; import com.sun.image.codec.jpeg.ImageFormatException; @@ -94,9 +93,6 @@ private static final boolean ENLARGE_DEFAULT = true; private static final boolean FIT_DEFAULT = false; - /* See http://developer.java.sun.com/developer/bugParade/bugs/4502892.html */ - private static final boolean JVMBugFixed = SystemUtils.isJavaVersionAtLeast(1.4f); - private int width; private int height; private float[] scaleColor = new float[3]; @@ -226,28 +222,6 @@ + " expires: " + expires); } - /* - * NOTE (SM): - * Due to Bug Id 4502892 (which is found in *all* JVM implementations from - * 1.2.x and 1.3.x on all OS!), we must buffer the JPEG generation to avoid - * that connection resetting by the peer (user pressing the stop button, - * for example) crashes the entire JVM (yes, dude, the bug is *that* nasty - * since it happens in JPEG routines which are native!) - * I'm perfectly aware of the huge memory problems that this causes (almost - * doubling memory consuption for each image and making the GC work twice - * as hard) but it's *far* better than restarting the JVM every 2 minutes - * (since this is the average experience for image-intensive web application - * such as an image gallery). - * Please, go to the <a href="http://developer.java.sun.com/developer/bugParade/bugs/4502892.html">Sun Developers Connection</a> - * and vote this BUG as the one you would like fixed sooner rather than - * later and all this hack will automagically go away. - * Many deep thanks to Michael Hartle <[EMAIL PROTECTED]> for tracking - * this down and suggesting the workaround. - * - * UPDATE (SM): - * This appears to be fixed on JDK 1.4 - */ - try { JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(inputStream); BufferedImage original = decoder.decodeAsBufferedImage(); @@ -273,18 +247,8 @@ if (null != colorFilter) { colorFilter.filter(currentImage, currentImage); } - - // JVM Bug handling - if (JVMBugFixed) { - JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out); - encoder.encode(currentImage); - } else { - ByteArrayOutputStream bstream = new ByteArrayOutputStream(); - JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bstream); - encoder.encode(currentImage); - out.write(bstream.toByteArray()); - } - + JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out); + encoder.encode(currentImage); out.flush(); } catch (ImageFormatException e) { throw new ProcessingException("Error reading the image. " +