[ 
https://issues.apache.org/jira/browse/WICKET-4718?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437769#comment-13437769
 ] 

Carsten Dräger edited comment on WICKET-4718 at 8/20/12 9:08 PM:
-----------------------------------------------------------------

Ok, here's the stack trace when I try to cache the IResourceStream returned by 
getResourceStream() in my extended ResourceStreamResource. I get that multiple 
times as well: http://pastebin.com/5tgWDZYc

Also, I tried to debug it. Without caching, if I click on a ResourceLink e.g. 
to display an image from the database in a JQuery FancyBox, the stream get 
instantiated in the CouchDbAttachmentResource#getResourceStream(). It then 
appears to get instantiated again in the 
ResourceStreamResource#internalGetResourceStream()! I can't see why this should 
be happening. 
Also, by the time the resource should be displayed, the stream is already 
closed for some reason, so this is happening all over again, which is probably 
why I get 2x2=4 queries for one click on a ResourceLink.

If I try your workaround, it's sometimes working, sometimes not depending on 
the way I use the resource. I still get multiple queries, but for the image 
explained above, it's only happening two times.
However, when I let the browser e.g. play a .wav file directly from the 
database, it's not working anymore and I get the following exceptions: 
http://pastebin.com/JZF1kF9i

So not really an option either :/
                
      was (Author: blacklight):
    Ok, here's the stack trace when I try to cache the IResourceStream returned 
by getResourceStream() in my extended ResourceStreamResource. I get that 
multiple times as well: http://pastebin.com/tNQ5hfAC

Also, I tried to debug it. Without caching, if I click on a ResourceLink e.g. 
to display an image from the database in a JQuery FancyBox, the stream get 
instantiated in the CouchDbAttachmentResource#getResourceStream(). It then 
appears to get instantiated again in the 
ResourceStreamResource#internalGetResourceStream()! I can't see why this should 
be happening. 
Also, by the time the resource should be displayed, the stream is already 
closed for some reason, so this is happening all over again, which is probably 
why I get 2x2=4 queries for one click on a ResourceLink.

If I try your workaround, it's sometimes working, sometimes not depending on 
the way I use the resource. I still get multiple queries, but for the image 
explained above, it's only happening two times.
However, when I let the browser e.g. play a .wav file directly from the 
database, it's not working anymore and I get the following exceptions: 
http://pastebin.com/TDRg9KzD

So not really an option either :/
                  
> ResourceStreamResource#getResourceStream() is called multiple times
> -------------------------------------------------------------------
>
>                 Key: WICKET-4718
>                 URL: https://issues.apache.org/jira/browse/WICKET-4718
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 6.0.0-beta3
>         Environment: Mac OS X 10.7.4 Lion, Java 6, IntelliJ Idea 11.1, Tomcat 
> 7 & Jetty 7.5.0
>            Reporter: Carsten Dräger
>
> When a ResourceStreamResource is implemented to return a IResourceStream 
> dynamically, by returning a new instance of an extended 
> AbstractResourceStream, that ResourceStream is instantiated multiple times 
> when a ResourceLink is clicked.
> In my case, that ResourceStream returns an AttachmentInputStream from the 
> Ektorp library (for CouchDB interaction). This behavior results in multiple 
> queries (currently up to four) when I click once on a ResourceLink to that 
> resource.
> Code Examples
> Extended ResourceStreamResource: http://pastebin.com/9BB7LEiV
> Extended IResouceStream: http://pastebin.com/Z7GvzGja

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply via email to