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
This commit is contained in:
PJ Fanning 2023-02-11 12:07:34 +00:00
parent 28a26d9cb2
commit 326126a365
2 changed files with 34 additions and 0 deletions

View File

@ -102,11 +102,29 @@ 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.

View File

@ -111,12 +111,28 @@ 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) {
threadPreferEventExtractors.set(preferEventExtractors);
}
/**
* 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.