aboutsummaryrefslogtreecommitdiffstats
path: root/poi-ooxml/src/main/java
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2023-02-11 12:07:34 +0000
committerPJ Fanning <fanningpj@apache.org>2023-02-11 12:07:34 +0000
commit326126a3657146d6b811b6b58b142c998f1406ac (patch)
tree0b6e6ab534a47d7caebe9d104df018e9fc875b96 /poi-ooxml/src/main/java
parent28a26d9cb23c8534b08987ee005a2df5fa61da9d (diff)
downloadpoi-326126a3657146d6b811b6b58b142c998f1406ac.tar.gz
poi-326126a3657146d6b811b6b58b142c998f1406ac.zip
provide way to clear the state on the ThreadLocal used byby ExtractorFactory
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1907581 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml/src/main/java')
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/ooxml/extractor/POIXMLExtractorFactory.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/ooxml/extractor/POIXMLExtractorFactory.java b/poi-ooxml/src/main/java/org/apache/poi/ooxml/extractor/POIXMLExtractorFactory.java
index 8bd8b535bc..2de39e3669 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/ooxml/extractor/POIXMLExtractorFactory.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/ooxml/extractor/POIXMLExtractorFactory.java
@@ -102,12 +102,30 @@ public final class POIXMLExtractorFactory implements ExtractorProvider {
/**
* Should this thread prefer event based over usermodel based extractors?
* Will only be used if the All Threads setting is null.
+ *
+ * <p>
+ * This uses ThreadLocals and these can leak resources when you have a lot of threads.
+ * </p>
+ *
+ * You should always try to call {@link #removeThreadPrefersEventExtractorsSetting()}.
+ *
+ * @see #setAllThreadsPreferEventExtractors
*/
public static void setThreadPrefersEventExtractors(boolean preferEventExtractors) {
ExtractorFactory.setThreadPrefersEventExtractors(preferEventExtractors);
}
/**
+ * Clears the setting for this thread made by {@link #setThreadPrefersEventExtractors(boolean) }
+ *
+ * @see #setThreadPrefersEventExtractors(boolean)
+ * @since POI 5.2.4
+ */
+ public static void removeThreadPrefersEventExtractorsSetting() {
+ ExtractorFactory.removeThreadPrefersEventExtractorsSetting();
+ }
+
+ /**
* Should all threads prefer event based over usermodel based extractors?
* If set, will take preference over the Thread level setting.
*/