You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Cédrik LIME (JIRA)" <ji...@apache.org> on 2007/02/22 16:19:05 UTC
[jira] Created: (FILEUPLOAD-125) new FileCleanerCleanup may lead to
problems [PATCH]
new FileCleanerCleanup may lead to problems [PATCH]
---------------------------------------------------
Key: FILEUPLOAD-125
URL: https://issues.apache.org/jira/browse/FILEUPLOAD-125
Project: Commons FileUpload
Issue Type: Bug
Affects Versions: 1.2
Reporter: Cédrik LIME
This is a follow-up on FILEUPLOAD-120.
As described in using.html#resourceCleanup, stopping the IO's reaper thread when commons-io is in the container's classpath will impact other running applications. The solution to this is to test if the FileCleaner class was loaded by the application's ClassLoader (i.e. commons-io.jar is in WEB-INF/lib/):
public void contextDestroyed(ServletContextEvent sce) {
if (FileCleaner.class.getClassLoader() == Thread.currentThread().getContextClassLoader()) {
FileCleaner.exitWhenFinished();
}
}
This is, if users don't forget to put FileCleanerCleanup as a servlet listener, of course...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (FILEUPLOAD-125) new FileCleanerCleanup may lead
to problems [PATCH]
Posted by "Jochen Wiedmann (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FILEUPLOAD-125?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12478015 ]
Jochen Wiedmann commented on FILEUPLOAD-125:
--------------------------------------------
Cédrik, I understand your concerns. In order to get things done, I have opened IO-116 and added a patch that improves the situation with commons-io. Nevertheless, I'll leave this bug as "WONTFIX".
> new FileCleanerCleanup may lead to problems [PATCH]
> ---------------------------------------------------
>
> Key: FILEUPLOAD-125
> URL: https://issues.apache.org/jira/browse/FILEUPLOAD-125
> Project: Commons FileUpload
> Issue Type: Bug
> Affects Versions: 1.2
> Reporter: Cédrik LIME
>
> This is a follow-up on FILEUPLOAD-120.
> As described in using.html#resourceCleanup, stopping the IO's reaper thread when commons-io is in the container's classpath will impact other running applications. The solution to this is to test if the FileCleaner class was loaded by the application's ClassLoader (i.e. commons-io.jar is in WEB-INF/lib/):
> public void contextDestroyed(ServletContextEvent sce) {
> if (FileCleaner.class.getClassLoader() == Thread.currentThread().getContextClassLoader()) {
> FileCleaner.exitWhenFinished();
> }
> }
> This is, if users don't forget to put FileCleanerCleanup as a servlet listener, of course...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Resolved: (FILEUPLOAD-125) new FileCleanerCleanup may lead
to problems [PATCH]
Posted by "Jochen Wiedmann (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FILEUPLOAD-125?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jochen Wiedmann resolved FILEUPLOAD-125.
----------------------------------------
Resolution: Won't Fix
Understanding your suggestion, I nevertheless decided against picking it up as a recommendation:
While the idea to compare classloaders works in your case, I wouldn't assume that it will work always. For example, I see no reason, why Thread.currentThread().getContextClassLoader() must differ among threads: For example, I could imagine that a J2EE server uses the very same ClassLoader for all threads, which holds a ThreadLocal instance internally. A recommendation should work in all cases.
IMO, the ball is still in the field of commons-io, which should allow to create and destroy the thread as a local object, which can be bound, for example, to the ServletContextListener.
> new FileCleanerCleanup may lead to problems [PATCH]
> ---------------------------------------------------
>
> Key: FILEUPLOAD-125
> URL: https://issues.apache.org/jira/browse/FILEUPLOAD-125
> Project: Commons FileUpload
> Issue Type: Bug
> Affects Versions: 1.2
> Reporter: Cédrik LIME
>
> This is a follow-up on FILEUPLOAD-120.
> As described in using.html#resourceCleanup, stopping the IO's reaper thread when commons-io is in the container's classpath will impact other running applications. The solution to this is to test if the FileCleaner class was loaded by the application's ClassLoader (i.e. commons-io.jar is in WEB-INF/lib/):
> public void contextDestroyed(ServletContextEvent sce) {
> if (FileCleaner.class.getClassLoader() == Thread.currentThread().getContextClassLoader()) {
> FileCleaner.exitWhenFinished();
> }
> }
> This is, if users don't forget to put FileCleanerCleanup as a servlet listener, of course...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (FILEUPLOAD-125) new FileCleanerCleanup may lead
to problems [PATCH]
Posted by "Cédrik LIME (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FILEUPLOAD-125?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12476979 ]
Cédrik LIME commented on FILEUPLOAD-125:
----------------------------------------
Jochen,
Thanks for your answer. I agree that ultimately commons-io should enable us to manage this thread more finely... Until that time, we'll have to cope with it.
Thread.currentThread().getContextClassLoader() represents the current web application's ClassLoader, not the current Thread ClassLoader (which we could get with Thread.currentThread().getClass().getClassLoader()). A Thread's ContextClassLoader /will/ change at runtime by the J2EE container to the served webapp's ClassLoader (that is: the same Thread will serve many different webapps during its lifetime).
I have mixed feelings about some piece of code in a web application affecting other non-related web applications. While the fault is on the shoulders of commons-io, I think we shouldn't allow the possibility to impact the other running webapps. Hence the aforementioned patch which I honestly believe works in all cases and for every application servers.
Anyway, this problem only arises when commons-io is in the container classpath, which hopefully will not be the case in a typical J2EE configuration.
> new FileCleanerCleanup may lead to problems [PATCH]
> ---------------------------------------------------
>
> Key: FILEUPLOAD-125
> URL: https://issues.apache.org/jira/browse/FILEUPLOAD-125
> Project: Commons FileUpload
> Issue Type: Bug
> Affects Versions: 1.2
> Reporter: Cédrik LIME
>
> This is a follow-up on FILEUPLOAD-120.
> As described in using.html#resourceCleanup, stopping the IO's reaper thread when commons-io is in the container's classpath will impact other running applications. The solution to this is to test if the FileCleaner class was loaded by the application's ClassLoader (i.e. commons-io.jar is in WEB-INF/lib/):
> public void contextDestroyed(ServletContextEvent sce) {
> if (FileCleaner.class.getClassLoader() == Thread.currentThread().getContextClassLoader()) {
> FileCleaner.exitWhenFinished();
> }
> }
> This is, if users don't forget to put FileCleanerCleanup as a servlet listener, of course...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org