Author: antonio Date: Sun May 1 09:39:11 2005 New Revision: 165522 URL: http://svn.apache.org/viewcvs?rev=165522&view=rev Log: Use SystemUtils to detect java 1.4 or higher
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/reading/ImageReader.java Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/reading/ImageReader.java URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/reading/ImageReader.java?rev=165522&r1=165521&r2=165522&view=diff ============================================================================== --- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/reading/ImageReader.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/reading/ImageReader.java Sun May 1 09:39:11 2005 @@ -31,7 +31,7 @@ import org.apache.avalon.framework.parameters.Parameters; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.environment.SourceResolver; -import org.apache.commons.lang.BooleanUtils; +import org.apache.commons.lang.SystemUtils; import org.xml.sax.SAXException; import com.sun.image.codec.jpeg.ImageFormatException; @@ -94,6 +94,9 @@ 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]; @@ -271,10 +274,11 @@ colorFilter.filter(currentImage, currentImage); } - if (!handleJVMBug()) { + // JVM Bug handling + if (JVMBugFixed) { JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out); encoder.encode(currentImage); - } else { + } else { ByteArrayOutputStream bstream = new ByteArrayOutputStream(); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bstream); encoder.encode(currentImage); @@ -319,39 +323,5 @@ + ":" + this.offsetColor[2] + ":" + ((null == this.grayscaleFilter) ? "color" : "grayscale") + ":" + super.getKey(); - } - - /** - * Determine if workaround for Bug Id 4502892 is neccessary. - * This method assumes that Bug is present if - * java.version is undeterminable, and for java.version - * 1.1, 1.2, 1.3, all other java.version do not need the Bug handling - * - * @return true if we should handle the JVM bug, else false - */ - protected boolean handleJVMBug() { - // java.version=1.4.0 - String java_version = System.getProperty( "java.version", "0.0.0" ); - boolean handleJVMBug = true; - - char major = java_version.charAt(0); - char minor = java_version.charAt(2); - - // make 0.0, 1.1, 1.2, 1.3 handleJVMBug = true - if (major == '0' || major == '1') { - if (minor == '0' || minor == '1' || minor == '2' || minor == '3') { - handleJVMBug = true; - } else { - handleJVMBug = false; - } - } else { - handleJVMBug = true; - } - if (getLogger().isDebugEnabled()) { - getLogger().debug("Running java " + String.valueOf(java_version) + - " need to handle JVM bug " + String.valueOf(handleJVMBug)); - } - - return handleJVMBug; } }