Bug 1122779

Summary: [GSS] (6.3.1) DataSourceProvider does not delete the temporary files it creates
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Kyle Lape <klape>
Component: RESTEasyAssignee: Weinan Li <weli>
Status: CLOSED CURRENTRELEASE QA Contact: Katerina Odabasi <kanovotn>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 6.3.0CC: bbaranow, bmaxwell, kanovotn, klape, rdickens, weli, wsiqueir
Target Milestone: CR1Keywords: Triaged
Target Release: EAP 6.3.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Known Issue
Doc Text:
The `DataSourceProvider` (org.jboss.resteasy.plugins.providers.DataSourceProvider.readDataSource(InputStream, MediaType)) creates a temporary file named `resteasy-provider-datasource ... .tmp` when reading more then 4096 bytes. However, it does not delete the created temporary file itself nor does it provide a facility to do so, resulting in a resource leak. This issue is under investigation and is expected to be resolved in the next release.
Story Points: ---
Clone Of: 1113338 Environment:
Last Closed: 2014-10-13 18:37:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1113338    
Bug Blocks: 1102082, 1105695    

Description Kyle Lape 2014-07-24 04:31:26 UTC
The DataSourceProvider (org.jboss.resteasy.plugins.providers.DataSourceProvider.readDataSource(InputStream, MediaType)) creates a temporary file named "resteasy-provider-datasource ... .tmp" when reading more then 4096 bytes. However, it does not delete the created temporary file itself nor does it provide a facility to do so. This results in a resource leak.

Comment 3 Kyle Lape 2014-07-24 21:16:44 UTC
The file is now marked for deletion at the shut down of the JVM.  In addition, the file is deleted immediately once the input stream has reached the end.  

While this commit improvies the behavior of RESTEasy, it does not completely eliminate the potential of a build-up of temporary files.  If a endpoint does not fully consume attachments, then they won't be deleted until the JVM is restarted, which could be a long time.

A potential workaround is to create an EJB timer to delete these files periodically.  I wrote such an EJB here:

https://github.com/kylape/resteasy-datasource-cleaner

Currently waiting for the upstream PRs to be merged.

Comment 5 Weinan Li 2014-08-06 11:49:55 UTC
Upstream trunk merged: https://github.com/resteasy/Resteasy/pull/532

@Kyle, could you please create a PR for Branch_2_3 upstream also?

I'll merge this to 2.3.8.SP2-redhat for EAP 6.3.1.

Comment 6 Weinan Li 2014-08-12 04:55:13 UTC
Upgrading RESTEasy to 2.3.8.SP2 solves the problem: https://github.com/jbossas/jboss-eap/pull/1557/files

Comment 7 Kyle Lape 2014-08-12 05:38:29 UTC
Hi Weinan,  I didn't see this commit in the 2.3.8.SP2 branch.  Can you please double check it made the build?  My apologies if I was supposed to push the commit myself.  Thanks.

Comment 8 Weinan Li 2014-08-14 08:02:04 UTC
(In reply to Kyle Lape from comment #7)
> Hi Weinan,  I didn't see this commit in the 2.3.8.SP2 branch.  Can you
> please double check it made the build?  My apologies if I was supposed to
> push the commit myself.  Thanks.

Seems like I forgot to push my changes. I'll ask Dustin to rebuild a -redhat-2 to include it.

Comment 9 baranowb 2014-08-14 08:02:19 UTC
Assigned since commit did not make it. Needs respin of redhat-2. Thanks Kyle.

Comment 12 Katerina Odabasi 2014-08-29 08:22:33 UTC
Verified in EAP 6.3.1.CP.CR1.

Comment 13 JBoss JIRA Server 2014-09-16 21:10:05 UTC
Kyle Lape <kyle.lape> updated the status of jira RESTEASY-1080 to Resolved

Comment 15 JBoss JIRA Server 2016-08-02 16:15:28 UTC
Alessio Soldano <asoldano> updated the status of jira RESTEASY-1080 to Closed