poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1846723 - in /poi/trunk: sonar/main/pom.xml sonar/ooxml/pom.xml sonar/pom.xml src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java
Date Fri, 16 Nov 2018 15:39:52 GMT
Author: kiwiwings
Date: Fri Nov 16 15:39:51 2018
New Revision: 1846723

URL: http://svn.apache.org/viewvc?rev=1846723&view=rev
Log:
Try to fix ImageIO cache error

Modified:
    poi/trunk/sonar/main/pom.xml
    poi/trunk/sonar/ooxml/pom.xml
    poi/trunk/sonar/pom.xml
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java

Modified: poi/trunk/sonar/main/pom.xml
URL: http://svn.apache.org/viewvc/poi/trunk/sonar/main/pom.xml?rev=1846723&r1=1846722&r2=1846723&view=diff
==============================================================================
--- poi/trunk/sonar/main/pom.xml (original)
+++ poi/trunk/sonar/main/pom.xml Fri Nov 16 15:39:51 2018
@@ -103,7 +103,7 @@
                 <artifactId>maven-surefire-plugin</artifactId>
                 <version>${maven.plugin.surefire.version}</version>
                 <configuration>
-                    <argLine>@{argLine} -Duser.language=en -Duser.country=US -Xmx1024m
-Djava.io.tmpdir=target/tmp -XX:-OmitStackTraceInFastThrow</argLine>
+                    <argLine>@{argLine} -Duser.language=en -Duser.country=US -Xmx1024m
-Djava.io.tmpdir=${basedir}/target/tmp -XX:-OmitStackTraceInFastThrow</argLine>
                 </configuration>
             </plugin>
 		</plugins>

Modified: poi/trunk/sonar/ooxml/pom.xml
URL: http://svn.apache.org/viewvc/poi/trunk/sonar/ooxml/pom.xml?rev=1846723&r1=1846722&r2=1846723&view=diff
==============================================================================
--- poi/trunk/sonar/ooxml/pom.xml (original)
+++ poi/trunk/sonar/ooxml/pom.xml Fri Nov 16 15:39:51 2018
@@ -93,7 +93,7 @@
                 <artifactId>maven-surefire-plugin</artifactId>
                 <version>${maven.plugin.surefire.version}</version>
                 <configuration>
-                    <argLine>@{argLine} -Duser.language=en -Duser.country=US -Xmx1024m
-Djava.io.tmpdir=target/tmp -XX:-OmitStackTraceInFastThrow</argLine>
+                    <argLine>@{argLine} -Duser.language=en -Duser.country=US -Xmx1024m
-Djava.io.tmpdir=${basedir}/target/tmp -XX:-OmitStackTraceInFastThrow</argLine>
                 </configuration>
             </plugin>
         </plugins>

Modified: poi/trunk/sonar/pom.xml
URL: http://svn.apache.org/viewvc/poi/trunk/sonar/pom.xml?rev=1846723&r1=1846722&r2=1846723&view=diff
==============================================================================
--- poi/trunk/sonar/pom.xml (original)
+++ poi/trunk/sonar/pom.xml Fri Nov 16 15:39:51 2018
@@ -117,7 +117,7 @@
                         <org.apache.poi.util.POILogger>org.apache.poi.util.NullLogger</org.apache.poi.util.POILogger>
                     </systemPropertyVariables>
                     <!-- use to following to analyze OOM issues:	-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/tmp -->
-                    <argLine>@{argLine} -Duser.language=en -Duser.country=US -Xmx1024m
-Djava.io.tmpdir=target/tmp
+                    <argLine>@{argLine} -Duser.language=en -Duser.country=US -Xmx1024m
-Djava.io.tmpdir=${basedir}/target/tmp
                     </argLine>
                     <excludes>
                         <exclude>**/All*Tests.java</exclude>

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java?rev=1846723&r1=1846722&r2=1846723&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java Fri Nov
16 15:39:51 2018
@@ -19,6 +19,7 @@ package org.apache.poi.hssf.usermodel;
 
 import java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
+import java.io.File;
 import java.io.IOException;
 import java.util.List;
 
@@ -27,7 +28,6 @@ import javax.imageio.ImageIO;
 import junit.framework.TestCase;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
 /**
@@ -37,19 +37,19 @@ import org.junit.BeforeClass;
  * @author Yegor Kozlov (yegor at apache dot org)
  * @author Trejkaz (trejkaz at trypticon dot org)
  */
-public final class TestHSSFPictureData extends TestCase {
-    private static boolean cacheBefore = ImageIO.getUseCache();
-
+public final class TestHSSFPictureData extends TestCase{
     @BeforeClass
     public static void setUpClass() {
-        // disable cache to avoid strange errors related to temporary directories in CI-builds
-        ImageIO.setUseCache(false);
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        // reset image cache to previous state
-        ImageIO.setUseCache(cacheBefore);
+        final String tmpDirProperty = System.getProperty("java.io.tmpdir");
+        if(tmpDirProperty == null || "".equals(tmpDirProperty)) {
+            return;
+        }
+        // ensure that temp-dir exists because ImageIO requires it
+        final File tmpDir = new File(tmpDirProperty);
+        if(!tmpDir.exists() && !tmpDir.mkdirs()) {
+            throw new IllegalStateException("Could not create temporary directory " + tmpDirProperty
+ ", full path " + tmpDir.getAbsolutePath());
+        }
+        ImageIO.setCacheDirectory(tmpDir);
     }
 
 	public void testPictures() throws IOException {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message