harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r520379 - in /harmony/enhanced/classlib/trunk/modules/imageio: ./ src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/ src/main/java/org/apache/harmony/x/imageio/plugins/png/ src/test/java/javax/ src/test/java/javax/imageio/ src/test/re...
Date Tue, 20 Mar 2007 13:07:46 GMT
Author: ayza
Date: Tue Mar 20 06:07:44 2007
New Revision: 520379

URL: http://svn.apache.org/viewvc?view=rev&rev=520379
Log:
Fixing threading issue in ImageIO. See HARMONY-3135 ([classlib][imageio] unexpected InterruptedException
after loading png-image)

Added:
    harmony/enhanced/classlib/trunk/modules/imageio/src/test/java/javax/
    harmony/enhanced/classlib/trunk/modules/imageio/src/test/java/javax/imageio/
    harmony/enhanced/classlib/trunk/modules/imageio/src/test/java/javax/imageio/ImageIOTest.java
  (with props)
    harmony/enhanced/classlib/trunk/modules/imageio/src/test/resources/
    harmony/enhanced/classlib/trunk/modules/imageio/src/test/resources/images/
    harmony/enhanced/classlib/trunk/modules/imageio/src/test/resources/images/utest.jpg  
(with props)
    harmony/enhanced/classlib/trunk/modules/imageio/src/test/resources/images/utest.png  
(with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/imageio/build.xml
    harmony/enhanced/classlib/trunk/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReader.java
    harmony/enhanced/classlib/trunk/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/png/PNGImageReader.java

Modified: harmony/enhanced/classlib/trunk/modules/imageio/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/imageio/build.xml?view=diff&rev=520379&r1=520378&r2=520379
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/imageio/build.xml (original)
+++ harmony/enhanced/classlib/trunk/modules/imageio/build.xml Tue Mar 20 06:07:44 2007
@@ -147,7 +147,7 @@
         </jar>
     </target>
 
-    <target name="compile-tests">
+    <target name="compile-tests" depends="copy-test-resources">
         <echo message="Compiling ImageIO tests" />
 
         <mkdir dir="${hy.imageio.bin.test}" />
@@ -223,4 +223,12 @@
             append="true">imageio${line.separator}</echo>
     </target>
 
+    <target name="copy-test-resources">
+        <mkdir dir="${hy.imageio.bin.test}/resources" />
+        <copy todir="${hy.imageio.bin.test}/resources" includeemptydirs="false">
+            <fileset dir="${hy.imageio.src.test.resources}">
+                <exclude name="**/*.java" />
+            </fileset>
+        </copy>
+    </target>
 </project>

Modified: harmony/enhanced/classlib/trunk/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReader.java?view=diff&rev=520379&r1=520378&r2=520379
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReader.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReader.java
Tue Mar 20 06:07:44 2007
@@ -99,6 +99,12 @@
         OffscreenImage image = new OffscreenImage(source);
         source.addConsumer(image);
         source.load();
+        // The interrupted flag should be cleared because ImageDecoder interrupts
+        // current thread while decoding. The same technique is used in
+        // ImageLoader#run(). Another solution can be to create
+        // a separate decoding thread. However, decoder keeps its own pool
+        // of threads so creating a new thread will be just a waste of resources.
+        Thread.interrupted();
         return image.getBufferedImage();
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/png/PNGImageReader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/png/PNGImageReader.java?view=diff&rev=520379&r1=520378&r2=520379
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/png/PNGImageReader.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/png/PNGImageReader.java
Tue Mar 20 06:07:44 2007
@@ -82,6 +82,9 @@
         OffscreenImage image = new OffscreenImage(source);
         source.addConsumer(image);
         source.load();
+        // The interrupted flag should be cleared because ImageDecoder interrupts
+        // current thread while decoding (due its architecture).
+        Thread.interrupted();
         return image.getBufferedImage();
     }
 

Added: harmony/enhanced/classlib/trunk/modules/imageio/src/test/java/javax/imageio/ImageIOTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/imageio/src/test/java/javax/imageio/ImageIOTest.java?view=auto&rev=520379
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/imageio/src/test/java/javax/imageio/ImageIOTest.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/imageio/src/test/java/javax/imageio/ImageIOTest.java
Tue Mar 20 06:07:44 2007
@@ -0,0 +1,47 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.imageio;
+
+import java.net.URL;
+import java.util.LinkedList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+public class ImageIOTest extends TestCase {
+
+    public void testReadURL() throws Exception {
+        // Regression for HARMONY-3135
+        for (URL url : listImages()) {
+            assertNotNull(ImageIO.read(url));
+            assertFalse("The current thread has been interrupted! URL: " + url, //$NON-NLS-1$
+                    Thread.currentThread().isInterrupted());
+        }
+    }
+
+    protected List<URL> listImages() {
+        final String imgPath = "/resources/images/utest."; //$NON-NLS-1$
+        final Class<? extends ImageIOTest> c = getClass();
+        final List<URL> img = new LinkedList<URL>();
+
+        img.add(c.getResource(imgPath + "jpg")); //$NON-NLS-1$
+        img.add(c.getResource(imgPath + "png")); //$NON-NLS-1$
+
+        return img;
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/imageio/src/test/java/javax/imageio/ImageIOTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/imageio/src/test/resources/images/utest.jpg
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/imageio/src/test/resources/images/utest.jpg?view=auto&rev=520379
==============================================================================
Binary file - no diff available.

Propchange: harmony/enhanced/classlib/trunk/modules/imageio/src/test/resources/images/utest.jpg
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: harmony/enhanced/classlib/trunk/modules/imageio/src/test/resources/images/utest.png
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/imageio/src/test/resources/images/utest.png?view=auto&rev=520379
==============================================================================
Binary file - no diff available.

Propchange: harmony/enhanced/classlib/trunk/modules/imageio/src/test/resources/images/utest.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message