diff options
author | PJ Fanning <fanningpj@apache.org> | 2023-02-11 12:07:34 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2023-02-11 12:07:34 +0000 |
commit | 326126a3657146d6b811b6b58b142c998f1406ac (patch) | |
tree | 0b6e6ab534a47d7caebe9d104df018e9fc875b96 /poi | |
parent | 28a26d9cb23c8534b08987ee005a2df5fa61da9d (diff) | |
download | poi-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')
-rw-r--r-- | poi/src/main/java/org/apache/poi/extractor/ExtractorFactory.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/poi/src/main/java/org/apache/poi/extractor/ExtractorFactory.java b/poi/src/main/java/org/apache/poi/extractor/ExtractorFactory.java index 28b81e9cc4..3e8f046112 100644 --- a/poi/src/main/java/org/apache/poi/extractor/ExtractorFactory.java +++ b/poi/src/main/java/org/apache/poi/extractor/ExtractorFactory.java @@ -111,6 +111,12 @@ public final class ExtractorFactory { * 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()}. + * * @param preferEventExtractors If this threads should prefer event based extractors. */ public static void setThreadPrefersEventExtractors(boolean preferEventExtractors) { @@ -118,6 +124,16 @@ public final class ExtractorFactory { } /** + * Clears the setting for this thread made by {@link #setThreadPrefersEventExtractors(boolean) } + * + * @see #setThreadPrefersEventExtractors(boolean) + * @since POI 5.2.4 + */ + public static void removeThreadPrefersEventExtractorsSetting() { + threadPreferEventExtractors.remove(); + } + + /** * Should all threads prefer event based over usermodel based extractors? * If set, will take preference over the Thread level setting. * |