poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1704710 - in /poi/trunk/src: java/org/apache/poi/hssf/record/ ooxml/java/org/apache/poi/ss/usermodel/ scratchpad/testcases/org/apache/poi/hslf/record/ testcases/org/apache/poi/hssf/eventusermodel/ testcases/org/apache/poi/hssf/extractor/ t...
Date Tue, 22 Sep 2015 19:50:41 GMT
Author: centic
Date: Tue Sep 22 19:50:37 2015
New Revision: 1704710

URL: http://svn.apache.org/viewvc?rev=1704710&view=rev
Log:
Ensure that the ThreadLocal-Biff-Password is reset correctly after each usage, we had some
unit tests failing sporadically due to this

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/record/RecordFactoryInputStream.java
    poi/trunk/src/ooxml/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java
    poi/trunk/src/testcases/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java
    poi/trunk/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestRecordFactoryInputStream.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/crypto/TestXorEncryption.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/RecordFactoryInputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/RecordFactoryInputStream.java?rev=1704710&r1=1704709&r2=1704710&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/RecordFactoryInputStream.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/RecordFactoryInputStream.java Tue Sep 22
19:50:37 2015
@@ -55,8 +55,6 @@ public final class RecordFactoryInputStr
 		private final Record _lastRecord;
 		private final boolean _hasBOFRecord;
 
-		private static POILogger log = POILogFactory.getLogger(StreamEncryptionInfo.class);
-		
 		public StreamEncryptionInfo(RecordInputStream rs, List<Record> outputRecs) {
 			Record rec;
 			rs.nextRecord();

Modified: poi/trunk/src/ooxml/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/ss/usermodel/WorkbookFactory.java?rev=1704710&r1=1704709&r2=1704710&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/ss/usermodel/WorkbookFactory.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/ss/usermodel/WorkbookFactory.java Tue Sep 22 19:50:37
2015
@@ -121,9 +121,11 @@ public class WorkbookFactory {
         if (password != null) {
             Biff8EncryptionKey.setCurrentUserPassword(password);
         }
-        Workbook wb = new HSSFWorkbook(root, true);
-        Biff8EncryptionKey.setCurrentUserPassword(null);
-        return wb;
+        try {
+            return new HSSFWorkbook(root, true);
+        } finally {
+            Biff8EncryptionKey.setCurrentUserPassword(null);
+        }
     }
 
     /**

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java?rev=1704710&r1=1704709&r2=1704710&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java
(original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java
Tue Sep 22 19:50:37 2015
@@ -47,6 +47,7 @@ import org.apache.poi.poifs.crypt.HashAl
 import org.apache.poi.poifs.crypt.cryptoapi.CryptoAPIEncryptionHeader;
 import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -57,6 +58,7 @@ public class TestDocumentEncryption {
     POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
 
     @Before
+    @After  // also afterwards to not affect other tests running in the same JVM
     public void resetPassword() {
         Biff8EncryptionKey.setCurrentUserPassword(null);
     }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java?rev=1704710&r1=1704709&r2=1704710&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java Tue
Sep 22 19:50:37 2015
@@ -36,6 +36,7 @@ import org.apache.poi.hssf.record.Select
 import org.apache.poi.hssf.record.WindowTwoRecord;
 import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.junit.After;
 
 /**
  * Testing for {@link HSSFEventFactory}
@@ -45,6 +46,12 @@ public final class TestHSSFEventFactory
         return HSSFTestDataSamples.openSampleFileStream(sampleFileName);
     }
 
+    // to not affect other tests running in the same JVM
+    @After
+    public void resetPassword() {
+        Biff8EncryptionKey.setCurrentUserPassword(null);
+    }
+
     public void testWithMissingRecords() throws Exception {
 
         HSSFRequest req = new HSSFRequest();

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java?rev=1704710&r1=1704709&r2=1704710&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java Tue Sep
22 19:50:37 2015
@@ -32,12 +32,18 @@ import org.apache.poi.hssf.usermodel.HSS
 import org.apache.poi.poifs.filesystem.DirectoryNode;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.LocaleUtil;
+import org.junit.After;
 import org.junit.Test;
 
 /**
  *
  */
 public final class TestExcelExtractor {
+    // to not affect other tests running in the same JVM
+    @After
+    public void resetPassword() {
+        Biff8EncryptionKey.setCurrentUserPassword(null);
+    }
 
 	@SuppressWarnings("resource")
     private static ExcelExtractor createExtractor(String sampleFileName) throws IOException
{

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestRecordFactoryInputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestRecordFactoryInputStream.java?rev=1704710&r1=1704709&r2=1704710&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestRecordFactoryInputStream.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestRecordFactoryInputStream.java Tue
Sep 22 19:50:37 2015
@@ -25,6 +25,7 @@ import java.io.ByteArrayInputStream;
 import org.apache.poi.EncryptedDocumentException;
 import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
 import org.apache.poi.util.HexRead;
+import org.junit.After;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -35,6 +36,11 @@ import org.junit.rules.ExpectedException
  * @author Josh Micich
  */
 public final class TestRecordFactoryInputStream {
+    // to not affect other tests running in the same JVM
+    @After
+    public void resetPassword() {
+        Biff8EncryptionKey.setCurrentUserPassword(null);
+    }
 
 	/**
 	 * Hex dump of a BOF record and most of a FILEPASS record.

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/crypto/TestXorEncryption.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/crypto/TestXorEncryption.java?rev=1704710&r1=1704709&r2=1704710&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/crypto/TestXorEncryption.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/crypto/TestXorEncryption.java Tue Sep
22 19:50:37 2015
@@ -27,12 +27,19 @@ import org.apache.poi.hssf.usermodel.HSS
 import org.apache.poi.poifs.crypt.CryptoFunctions;
 import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
 import org.apache.poi.util.HexRead;
+import org.junit.After;
 import org.junit.Test;
 
 public class TestXorEncryption {
     
     private static HSSFTestDataSamples samples = new HSSFTestDataSamples();
     
+    // to not affect other tests running in the same JVM
+    @After
+    public void resetPassword() {
+        Biff8EncryptionKey.setCurrentUserPassword(null);
+    }
+
     @Test
     public void testXorEncryption() throws Exception {
         // Xor-Password: abc

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=1704710&r1=1704709&r2=1704710&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Tue Sep 22 19:50:37
2015
@@ -74,6 +74,7 @@ import org.apache.poi.ss.usermodel.Sheet
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.util.LocaleUtil;
+import org.junit.After;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -85,6 +86,11 @@ import org.junit.Test;
  *  define the test in the base class {@link BaseTestBugzillaIssues}</b>
  */
 public final class TestBugs extends BaseTestBugzillaIssues {
+    // to not affect other tests running in the same JVM
+    @After
+    public void resetPassword() {
+        Biff8EncryptionKey.setCurrentUserPassword(null);
+    }
 
     public TestBugs() {
         super(HSSFITestDataProvider.instance);



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


Mime
View raw message