Open 99sono opened 9 years ago
I can't see how this method can be called more then once with the same uniqueId parameter value.
Since this value is made unique by the call to the method org.primefaces.component.graphicimage.GraphicImageRenderer#createUniqueContentId which generates this uniqueId.
As mentioned in issue #4, there is an issue with ViewScoped beans and refreshing the page with AJAX.
When uniqueId generation is only based on clientId and expressionString, the registerImage can be called with the same uniqueId multiple times.
In that case, the check must be performed.
The GraphicImageManager leaks files upon refresh of a page with.
Essentially the problem seems to be that on the first page rendering, where the functionality works properly, the StreamContent of the view access scoped bean gets closed and its contets saved on a temp file.
On a susequent request to the page (e.g. refresh of the labrador page) the the uniqueId of the page stay the same and the code would just ask for the operating system to go ahead and create a new temp file. The new temp file would be a leakage since it corresponded to an already existing unique id and in addition it would be empty because the original StreamedContent input stream had already been closed on the first rendereing.
I refactored the register method to be as follows:
/* * During the rendering phase of p:graphic image for which the avanced graphic image feature is enabled the * StreamedContent gets writtent to a temporary file in the OS tmp file folder. Finally, the uniqueId will be used * to do a lookup of path to the temporary file to render the iamge requested. * @param content * the primefaces streamed content for an image which should be written out to an OS temporary file. * @param uniqueId * a unique id for the current user session and image access, used to create a new unique temp file / public void registerImage(StreamedContent content, String uniqueId) {
Thanks