You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by jcgarciam <jc...@gmail.com> on 2010/11/23 20:05:17 UTC
Simple Download from StringResourceStream cause NPE wicket 1.5M3
(possible bug??)
Hi Folks,
Probably im doing it wrong, but please bear with me, currently i'm trying to
do a very simple download operation in wicket 1.5M3, but it fails with a NPE
in (ResourceStreamResource.java line 72), because it seems is always
expecting that any IResourceStream implementation set the lastModifiedTime
in the underlying stream before calling dataNeedsToBeWritten which
StringResourceStream doesn't do it ( i need to explicitly set it to make it
work ) .
@Override
protected ResourceResponse newResourceResponse(Attributes attributes)
{
ResourceResponse data = new ResourceResponse();
(72)-> data.setLastModified(stream.lastModifiedTime().toDate());
My code using [StringResourceStream]
<code>
final StringBuilder content = new StringBuilder("Hello,world");
add(new Link<Void>("downloadDoc") {
@Override
public void onClick() {
StringResourceStream stream = new
StringResourceStream(content.toString(),"html/csv");
getRequestCycle().scheduleRequestHandlerAfterCurrent(new
ResourceStreamRequestHandler(stream)
.setFileName("demo.csv")
.setContentDisposition(ContentDisposition.ATTACHMENT));
}
});
</code>
Calling [stream.setLastModified(Time.now());] right before scheduling the
request handler make the download to works, but it seems that probably im
doing something wrong (not supposed to a download on this way) or does it
sounds like a bug in [ResourceStreamResource.java]?
Thanks,
Attached is a quickstart
http://apache-wicket.1842946.n4.nabble.com/file/n3056036/DownloadStreamBug.7z
DownloadStreamBug.7z
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056036.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Simple Download from StringResourceStream cause NPE wicket
1.5M3 (possible bug??)
Posted by jcgarciam <jc...@gmail.com>.
Great, exactly what i had in mind :)
Thanks.
On Tue, Nov 23, 2010 at 4:42 PM, Martin Grigorov-4 [via Apache Wicket] <
ml-node+3056108-1056044911-65838@n4.nabble.com<ml...@n4.nabble.com>
> wrote:
> Covered by the fix ;-)
> All classes
> extending org.apache.wicket.util.resource.AbstractStringResourceStream will
>
> have it initialized for free.
>
> On Tue, Nov 23, 2010 at 8:37 PM, jcgarciam <[hidden email]<http://user/SendEmail.jtp?type=node&node=3056108&i=0>>
> wrote:
>
> >
> > Hi Martin,
> >
> > I explored the object hierarchy, and it seems *StringBufferResourceStream
>
> > *may
> > suffer from the same problem, if its constructed and no append or prepend
>
> > method is called on it (which is a weird scenario of course).
> >
> > Thanks!
> >
> > On Tue, Nov 23, 2010 at 4:27 PM, Martin Grigorov-4 [via Apache Wicket] <
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=3056108&i=1><[hidden
> email] <http://user/SendEmail.jtp?type=node&node=3056108&i=2>>
> > <[hidden email] <http://user/SendEmail.jtp?type=node&node=3056108&i=3><[hidden
> email] <http://user/SendEmail.jtp?type=node&node=3056108&i=4>>
> > >
> > > wrote:
> >
> > > Done.
> > > r1038292
> > >
> > > On Tue, Nov 23, 2010 at 8:20 PM, Martin Grigorov <[hidden email]<
> > http://user/SendEmail.jtp?type=node&node=3056080&i=0>>wrote:
> > >
> > >
> > > > Looks like a bug.
> > > > I think StringResourceStream has to initialize its lastModifiedTime
> in
> > > the
> > > > constructor to Time.now().
> > > >
> > > > I'll create a ticket and fix it.
> > > >
> > > >
> > > > On Tue, Nov 23, 2010 at 8:05 PM, jcgarciam <[hidden email]<
> > http://user/SendEmail.jtp?type=node&node=3056080&i=1>>
> > > wrote:
> > > >
> > > >>
> > > >> Hi Folks,
> > > >>
> > > >> Probably im doing it wrong, but please bear with me, currently i'm
> > > trying
> > > >> to
> > > >> do a very simple download operation in wicket 1.5M3, but it fails
> with
> > a
> > >
> > > >> NPE
> > > >> in (ResourceStreamResource.java line 72), because it seems is always
>
> > > >> expecting that any IResourceStream implementation set the
> > > lastModifiedTime
> > > >> in the underlying stream before calling dataNeedsToBeWritten which
> > > >> StringResourceStream doesn't do it ( i need to explicitly set it to
> > make
> > >
> > > >> it
> > > >> work ) .
> > > >>
> > > >> @Override
> > > >> protected ResourceResponse newResourceResponse(Attributes
> > > >> attributes)
> > > >> {
> > > >> ResourceResponse data = new ResourceResponse();
> > > >> (72)-> data.setLastModified(stream.lastModifiedTime().toDate());
> > > >>
> > > >>
> > > >> My code using [StringResourceStream]
> > > >> <code>
> > > >> final StringBuilder content = new
> StringBuilder("Hello,world");
> > > >> add(new Link<Void>("downloadDoc") {
> > > >> @Override
> > > >> public void onClick() {
> > > >> StringResourceStream stream = new
> > > >> StringResourceStream(content.toString(),"html/csv");
> > > >>
> > > >> getRequestCycle().scheduleRequestHandlerAfterCurrent(new
> > > >> ResourceStreamRequestHandler(stream)
> > > >> .setFileName("demo.csv")
> > > >>
> > > >> .setContentDisposition(ContentDisposition.ATTACHMENT));
> > > >> }
> > > >> });
> > > >> </code>
> > > >>
> > > >> Calling [stream.setLastModified(Time.now());] right before
> scheduling
> > > the
> > > >> request handler make the download to works, but it seems that
> probably
> > > im
> > > >> doing something wrong (not supposed to a download on this way) or
> does
> > > it
> > > >> sounds like a bug in [ResourceStreamResource.java]?
> > > >>
> > > >> Thanks,
> > > >>
> > > >> Attached is a quickstart
> > > >>
> > > >>
> > >
> >
> http://apache-wicket.1842946.n4.nabble.com/file/n3056036/DownloadStreamBug.7z<http://apache-wicket.1842946.n4.nabble.com/file/n3056036/DownloadStreamBug.7z?by-user=t>
> > <
> >
> http://apache-wicket.1842946.n4.nabble.com/file/n3056036/DownloadStreamBug.7z?by-user=t<http://apache-wicket.1842946.n4.nabble.com/file/n3056036/DownloadStreamBug.7z?by-user=t&by-user=t>
>
> > >
> > > >> DownloadStreamBug.7z
> > > >>
> > > >>
> > > >> --
> > > >> View this message in context:
> > > >>
> > >
> >
> http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056036.html<http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056036.html?by-user=t>
> > <
> >
> http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056036.html?by-user=t<http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056036.html?by-user=t&by-user=t>
>
> > >
> > > >> Sent from the Users forum mailing list archive at Nabble.com.
> > > >>
> > > >>
> ---------------------------------------------------------------------
> > > >> To unsubscribe, e-mail: [hidden email]<
> > http://user/SendEmail.jtp?type=node&node=3056080&i=2>
> > > >> For additional commands, e-mail: [hidden email]<
> > http://user/SendEmail.jtp?type=node&node=3056080&i=3>
> > > >>
> > > >>
> > > >
> > >
> > >
> > > ------------------------------
> > > View message @
> > >
> >
> http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056080.html<http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056080.html?by-user=t>
> > >
> > > To unsubscribe from Simple Download from StringResourceStream cause NPE
>
> > > wicket 1.5M3 (possible bug??), click here<
> >
> http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3056036&code=amNnYXJjaWFtQGdtYWlsLmNvbXwzMDU2MDM2fDEyNTYxMzc3ODY=<http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3056036&code=amNnYXJjaWFtQGdtYWlsLmNvbXwzMDU2MDM2fDEyNTYxMzc3ODY=&by-user=t>
> > >.
> > >
> > >
> >
> >
> >
> > --
> > Sincerely,
> > JC (http://www.linkedin.com/in/jcgarciam)
> > Work smarter, not harder!.
> >
> > --
> > View this message in context:
> >
> http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056096.html<http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056096.html?by-user=t>
>
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=3056108&i=5>
> > For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=3056108&i=6>
> >
> >
>
>
> ------------------------------
> View message @
> http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056108.html
>
> To unsubscribe from Simple Download from StringResourceStream cause NPE
> wicket 1.5M3 (possible bug??), click here<http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3056036&code=amNnYXJjaWFtQGdtYWlsLmNvbXwzMDU2MDM2fDEyNTYxMzc3ODY=>.
>
>
--
Sincerely,
JC (http://www.linkedin.com/in/jcgarciam)
Work smarter, not harder!.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056116.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Simple Download from StringResourceStream cause NPE wicket 1.5M3
(possible bug??)
Posted by Martin Grigorov <mg...@apache.org>.
Covered by the fix ;-)
All classes
extending org.apache.wicket.util.resource.AbstractStringResourceStream will
have it initialized for free.
On Tue, Nov 23, 2010 at 8:37 PM, jcgarciam <jc...@gmail.com> wrote:
>
> Hi Martin,
>
> I explored the object hierarchy, and it seems *StringBufferResourceStream
> *may
> suffer from the same problem, if its constructed and no append or prepend
> method is called on it (which is a weird scenario of course).
>
> Thanks!
>
> On Tue, Nov 23, 2010 at 4:27 PM, Martin Grigorov-4 [via Apache Wicket] <
> ml-node+3056080-692802461-65838@n4.nabble.com<ml...@n4.nabble.com>
> <ml...@n4.nabble.com>
> >
> > wrote:
>
> > Done.
> > r1038292
> >
> > On Tue, Nov 23, 2010 at 8:20 PM, Martin Grigorov <[hidden email]<
> http://user/SendEmail.jtp?type=node&node=3056080&i=0>>wrote:
> >
> >
> > > Looks like a bug.
> > > I think StringResourceStream has to initialize its lastModifiedTime in
> > the
> > > constructor to Time.now().
> > >
> > > I'll create a ticket and fix it.
> > >
> > >
> > > On Tue, Nov 23, 2010 at 8:05 PM, jcgarciam <[hidden email]<
> http://user/SendEmail.jtp?type=node&node=3056080&i=1>>
> > wrote:
> > >
> > >>
> > >> Hi Folks,
> > >>
> > >> Probably im doing it wrong, but please bear with me, currently i'm
> > trying
> > >> to
> > >> do a very simple download operation in wicket 1.5M3, but it fails with
> a
> >
> > >> NPE
> > >> in (ResourceStreamResource.java line 72), because it seems is always
> > >> expecting that any IResourceStream implementation set the
> > lastModifiedTime
> > >> in the underlying stream before calling dataNeedsToBeWritten which
> > >> StringResourceStream doesn't do it ( i need to explicitly set it to
> make
> >
> > >> it
> > >> work ) .
> > >>
> > >> @Override
> > >> protected ResourceResponse newResourceResponse(Attributes
> > >> attributes)
> > >> {
> > >> ResourceResponse data = new ResourceResponse();
> > >> (72)-> data.setLastModified(stream.lastModifiedTime().toDate());
> > >>
> > >>
> > >> My code using [StringResourceStream]
> > >> <code>
> > >> final StringBuilder content = new StringBuilder("Hello,world");
> > >> add(new Link<Void>("downloadDoc") {
> > >> @Override
> > >> public void onClick() {
> > >> StringResourceStream stream = new
> > >> StringResourceStream(content.toString(),"html/csv");
> > >>
> > >> getRequestCycle().scheduleRequestHandlerAfterCurrent(new
> > >> ResourceStreamRequestHandler(stream)
> > >> .setFileName("demo.csv")
> > >>
> > >> .setContentDisposition(ContentDisposition.ATTACHMENT));
> > >> }
> > >> });
> > >> </code>
> > >>
> > >> Calling [stream.setLastModified(Time.now());] right before scheduling
> > the
> > >> request handler make the download to works, but it seems that probably
> > im
> > >> doing something wrong (not supposed to a download on this way) or does
> > it
> > >> sounds like a bug in [ResourceStreamResource.java]?
> > >>
> > >> Thanks,
> > >>
> > >> Attached is a quickstart
> > >>
> > >>
> >
> http://apache-wicket.1842946.n4.nabble.com/file/n3056036/DownloadStreamBug.7z
> <
> http://apache-wicket.1842946.n4.nabble.com/file/n3056036/DownloadStreamBug.7z?by-user=t
> >
> > >> DownloadStreamBug.7z
> > >>
> > >>
> > >> --
> > >> View this message in context:
> > >>
> >
> http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056036.html
> <
> http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056036.html?by-user=t
> >
> > >> Sent from the Users forum mailing list archive at Nabble.com.
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: [hidden email]<
> http://user/SendEmail.jtp?type=node&node=3056080&i=2>
> > >> For additional commands, e-mail: [hidden email]<
> http://user/SendEmail.jtp?type=node&node=3056080&i=3>
> > >>
> > >>
> > >
> >
> >
> > ------------------------------
> > View message @
> >
> http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056080.html
> >
> > To unsubscribe from Simple Download from StringResourceStream cause NPE
> > wicket 1.5M3 (possible bug??), click here<
> http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3056036&code=amNnYXJjaWFtQGdtYWlsLmNvbXwzMDU2MDM2fDEyNTYxMzc3ODY=
> >.
> >
> >
>
>
>
> --
> Sincerely,
> JC (http://www.linkedin.com/in/jcgarciam)
> Work smarter, not harder!.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056096.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Simple Download from StringResourceStream cause NPE wicket
1.5M3 (possible bug??)
Posted by jcgarciam <jc...@gmail.com>.
Hi Martin,
I explored the object hierarchy, and it seems *StringBufferResourceStream *may
suffer from the same problem, if its constructed and no append or prepend
method is called on it (which is a weird scenario of course).
Thanks!
On Tue, Nov 23, 2010 at 4:27 PM, Martin Grigorov-4 [via Apache Wicket] <
ml-node+3056080-692802461-65838@n4.nabble.com<ml...@n4.nabble.com>
> wrote:
> Done.
> r1038292
>
> On Tue, Nov 23, 2010 at 8:20 PM, Martin Grigorov <[hidden email]<http://user/SendEmail.jtp?type=node&node=3056080&i=0>>wrote:
>
>
> > Looks like a bug.
> > I think StringResourceStream has to initialize its lastModifiedTime in
> the
> > constructor to Time.now().
> >
> > I'll create a ticket and fix it.
> >
> >
> > On Tue, Nov 23, 2010 at 8:05 PM, jcgarciam <[hidden email]<http://user/SendEmail.jtp?type=node&node=3056080&i=1>>
> wrote:
> >
> >>
> >> Hi Folks,
> >>
> >> Probably im doing it wrong, but please bear with me, currently i'm
> trying
> >> to
> >> do a very simple download operation in wicket 1.5M3, but it fails with a
>
> >> NPE
> >> in (ResourceStreamResource.java line 72), because it seems is always
> >> expecting that any IResourceStream implementation set the
> lastModifiedTime
> >> in the underlying stream before calling dataNeedsToBeWritten which
> >> StringResourceStream doesn't do it ( i need to explicitly set it to make
>
> >> it
> >> work ) .
> >>
> >> @Override
> >> protected ResourceResponse newResourceResponse(Attributes
> >> attributes)
> >> {
> >> ResourceResponse data = new ResourceResponse();
> >> (72)-> data.setLastModified(stream.lastModifiedTime().toDate());
> >>
> >>
> >> My code using [StringResourceStream]
> >> <code>
> >> final StringBuilder content = new StringBuilder("Hello,world");
> >> add(new Link<Void>("downloadDoc") {
> >> @Override
> >> public void onClick() {
> >> StringResourceStream stream = new
> >> StringResourceStream(content.toString(),"html/csv");
> >>
> >> getRequestCycle().scheduleRequestHandlerAfterCurrent(new
> >> ResourceStreamRequestHandler(stream)
> >> .setFileName("demo.csv")
> >>
> >> .setContentDisposition(ContentDisposition.ATTACHMENT));
> >> }
> >> });
> >> </code>
> >>
> >> Calling [stream.setLastModified(Time.now());] right before scheduling
> the
> >> request handler make the download to works, but it seems that probably
> im
> >> doing something wrong (not supposed to a download on this way) or does
> it
> >> sounds like a bug in [ResourceStreamResource.java]?
> >>
> >> Thanks,
> >>
> >> Attached is a quickstart
> >>
> >>
> http://apache-wicket.1842946.n4.nabble.com/file/n3056036/DownloadStreamBug.7z<http://apache-wicket.1842946.n4.nabble.com/file/n3056036/DownloadStreamBug.7z?by-user=t>
> >> DownloadStreamBug.7z
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056036.html<http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056036.html?by-user=t>
> >> Sent from the Users forum mailing list archive at Nabble.com.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=3056080&i=2>
> >> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=3056080&i=3>
> >>
> >>
> >
>
>
> ------------------------------
> View message @
> http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056080.html
>
> To unsubscribe from Simple Download from StringResourceStream cause NPE
> wicket 1.5M3 (possible bug??), click here<http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3056036&code=amNnYXJjaWFtQGdtYWlsLmNvbXwzMDU2MDM2fDEyNTYxMzc3ODY=>.
>
>
--
Sincerely,
JC (http://www.linkedin.com/in/jcgarciam)
Work smarter, not harder!.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056096.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Simple Download from StringResourceStream cause NPE wicket 1.5M3
(possible bug??)
Posted by Martin Grigorov <mg...@apache.org>.
Done.
r1038292
On Tue, Nov 23, 2010 at 8:20 PM, Martin Grigorov <mg...@apache.org>wrote:
> Looks like a bug.
> I think StringResourceStream has to initialize its lastModifiedTime in the
> constructor to Time.now().
>
> I'll create a ticket and fix it.
>
>
> On Tue, Nov 23, 2010 at 8:05 PM, jcgarciam <jc...@gmail.com> wrote:
>
>>
>> Hi Folks,
>>
>> Probably im doing it wrong, but please bear with me, currently i'm trying
>> to
>> do a very simple download operation in wicket 1.5M3, but it fails with a
>> NPE
>> in (ResourceStreamResource.java line 72), because it seems is always
>> expecting that any IResourceStream implementation set the lastModifiedTime
>> in the underlying stream before calling dataNeedsToBeWritten which
>> StringResourceStream doesn't do it ( i need to explicitly set it to make
>> it
>> work ) .
>>
>> @Override
>> protected ResourceResponse newResourceResponse(Attributes
>> attributes)
>> {
>> ResourceResponse data = new ResourceResponse();
>> (72)-> data.setLastModified(stream.lastModifiedTime().toDate());
>>
>>
>> My code using [StringResourceStream]
>> <code>
>> final StringBuilder content = new StringBuilder("Hello,world");
>> add(new Link<Void>("downloadDoc") {
>> @Override
>> public void onClick() {
>> StringResourceStream stream = new
>> StringResourceStream(content.toString(),"html/csv");
>>
>> getRequestCycle().scheduleRequestHandlerAfterCurrent(new
>> ResourceStreamRequestHandler(stream)
>> .setFileName("demo.csv")
>>
>> .setContentDisposition(ContentDisposition.ATTACHMENT));
>> }
>> });
>> </code>
>>
>> Calling [stream.setLastModified(Time.now());] right before scheduling the
>> request handler make the download to works, but it seems that probably im
>> doing something wrong (not supposed to a download on this way) or does it
>> sounds like a bug in [ResourceStreamResource.java]?
>>
>> Thanks,
>>
>> Attached is a quickstart
>>
>> http://apache-wicket.1842946.n4.nabble.com/file/n3056036/DownloadStreamBug.7z
>> DownloadStreamBug.7z
>>
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056036.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
Re: Simple Download from StringResourceStream cause NPE wicket 1.5M3
(possible bug??)
Posted by Martin Grigorov <mg...@apache.org>.
Looks like a bug.
I think StringResourceStream has to initialize its lastModifiedTime in the
constructor to Time.now().
I'll create a ticket and fix it.
On Tue, Nov 23, 2010 at 8:05 PM, jcgarciam <jc...@gmail.com> wrote:
>
> Hi Folks,
>
> Probably im doing it wrong, but please bear with me, currently i'm trying
> to
> do a very simple download operation in wicket 1.5M3, but it fails with a
> NPE
> in (ResourceStreamResource.java line 72), because it seems is always
> expecting that any IResourceStream implementation set the lastModifiedTime
> in the underlying stream before calling dataNeedsToBeWritten which
> StringResourceStream doesn't do it ( i need to explicitly set it to make it
> work ) .
>
> @Override
> protected ResourceResponse newResourceResponse(Attributes
> attributes)
> {
> ResourceResponse data = new ResourceResponse();
> (72)-> data.setLastModified(stream.lastModifiedTime().toDate());
>
>
> My code using [StringResourceStream]
> <code>
> final StringBuilder content = new StringBuilder("Hello,world");
> add(new Link<Void>("downloadDoc") {
> @Override
> public void onClick() {
> StringResourceStream stream = new
> StringResourceStream(content.toString(),"html/csv");
>
> getRequestCycle().scheduleRequestHandlerAfterCurrent(new
> ResourceStreamRequestHandler(stream)
> .setFileName("demo.csv")
>
> .setContentDisposition(ContentDisposition.ATTACHMENT));
> }
> });
> </code>
>
> Calling [stream.setLastModified(Time.now());] right before scheduling the
> request handler make the download to works, but it seems that probably im
> doing something wrong (not supposed to a download on this way) or does it
> sounds like a bug in [ResourceStreamResource.java]?
>
> Thanks,
>
> Attached is a quickstart
>
> http://apache-wicket.1842946.n4.nabble.com/file/n3056036/DownloadStreamBug.7z
> DownloadStreamBug.7z
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056036.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>