Description of problem: From JIRA: https://issues.jboss.org/browse/RESTEASY-1080 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! How reproducible: Easy. Steps to Reproduce: There's a reproducer attached to the JIRA for upstream resteasy. For the product, I'm attaching a reproducer that runs on EAP 6.2 1. Download the reproducer and unzip it 2. Start EAP 6.2 standalone mode, build and deploy the project: mvn clean package jboss-as:deploy -Dmaven.test.skip=true 3. Run the test mvn test Actual results: After the method execution, the tmp file will still be there; Expected results: It should clean the tmp file; Additional info: An interceptor would be a possible solution to clean the tmp file right after the JAX-RS method execution. We could also add a method on the Datasource provider to remove the tmp file, that could be called after the method execution. If you think the interceptor is a good solution, let me know, I have the PR for it. We could at least add a method on the SequenceDatasource class to remove the temp file: public void removeTempFile(){ tempFile.delete(); }
Created attachment 912312 [details] A test for the product A maven project to reproduce the issue on EAP.
Kyle Lape <kyle.lape> updated the status of jira RESTEASY-1080 to Coding In Progress
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.
Set the requires_doc_text to '-' because this bug targets 6.4 and duplicates the release note text in Bug 1122779, which targets 6.3.1.
Upstream Branch_2_3 fixed: master:resteasy-upstream weinanli$ git log 982512d9 commit 982512d99371735d6bce35764962993b0b4a2f98 Author: Kyle Lape <kyle.lape> Date: Thu Jul 24 08:41:20 2014 -0700 [RESTEASY-1080] DataSourceProvider does not delete the temporary files it creates code reference: https://github.com/resteasy/Resteasy/blob/Branch_2_3/resteasy-jaxrs/src/main/java/org/jboss/resteasy/plugins/providers/DataSourceProvider.java#L133
Kyle Lape <kyle.lape> updated the status of jira RESTEASY-1080 to Resolved
The fix is not present because resteasy is still in version 2.3.8.Final-redhat-3 not 2.3.9.
Verified on EAP 6.4.0.DR9
Alessio Soldano <asoldano> updated the status of jira RESTEASY-1080 to Closed