You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2019/03/06 18:36:12 UTC
svn commit: r1854935 - in /poi/trunk/src/ooxml:
java/org/apache/poi/ooxml/util/DocumentHelper.java
testcases/org/apache/poi/ooxml/util/TestDocumentHelper.java
Author: fanningpj
Date: Wed Mar 6 18:36:12 2019
New Revision: 1854935
URL: http://svn.apache.org/viewvc?rev=1854935&view=rev
Log:
[bug-63240] make DocumentHelper.newDocumentBuilder non-synchronized]
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/ooxml/util/DocumentHelper.java
poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/TestDocumentHelper.java
Modified: poi/trunk/src/ooxml/java/org/apache/poi/ooxml/util/DocumentHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/ooxml/util/DocumentHelper.java?rev=1854935&r1=1854934&r2=1854935&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/ooxml/util/DocumentHelper.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/ooxml/util/DocumentHelper.java Wed Mar 6 18:36:12 2019
@@ -86,7 +86,7 @@ public final class DocumentHelper {
* @throws IllegalStateException If creating the DocumentBuilder fails, e.g.
* due to {@link ParserConfigurationException}.
*/
- public static synchronized DocumentBuilder newDocumentBuilder() {
+ public static DocumentBuilder newDocumentBuilder() {
try {
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
documentBuilder.setEntityResolver(SAXHelper.IGNORING_ENTITY_RESOLVER);
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/TestDocumentHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/TestDocumentHelper.java?rev=1854935&r1=1854934&r2=1854935&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/TestDocumentHelper.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/TestDocumentHelper.java Wed Mar 6 18:36:12 2019
@@ -22,6 +22,9 @@ import org.xml.sax.InputSource;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
import static org.junit.Assert.*;
@@ -36,6 +39,21 @@ public class TestDocumentHelper {
}
@Test
+ public void testCreatingManyDocumentBuilders() throws Exception {
+ int limit = 1000;
+ ArrayList<CompletableFuture<DocumentBuilder>> futures = new ArrayList<>();
+ for(int i = 0; i < limit; i++) {
+ futures.add(CompletableFuture.supplyAsync(() -> {
+ return DocumentHelper.newDocumentBuilder();
+ }));
+ }
+ for(CompletableFuture<DocumentBuilder> future : futures) {
+ DocumentBuilder documentBuilder = future.get(10, TimeUnit.SECONDS);
+ assertTrue(documentBuilder.isNamespaceAware());
+ }
+ }
+
+ @Test
public void testDocumentBuilderFactory() throws Exception {
try {
assertTrue(DocumentHelper.documentBuilderFactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING));
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org