Simple Download from StringResourceStream cause NPE wicket 1.5M3 (possible bug??)

2010-11-23 Thread jcgarciam

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 LinkVoid(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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Simple Download from StringResourceStream cause NPE wicket 1.5M3 (possible bug??)

2010-11-23 Thread Martin Grigorov
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 jcgarc...@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 LinkVoid(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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: Simple Download from StringResourceStream cause NPE wicket 1.5M3 (possible bug??)

2010-11-23 Thread Martin Grigorov
Done.
r1038292

On Tue, Nov 23, 2010 at 8:20 PM, Martin Grigorov mgrigo...@apache.orgwrote:

 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 jcgarc...@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 LinkVoid(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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org





Re: Simple Download from StringResourceStream cause NPE wicket 1.5M3 (possible bug??)

2010-11-23 Thread jcgarciam

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-65...@n4.nabble.comml-node%2b3056080-692802461-65...@n4.nabble.com
 wrote:

 Done.
 r1038292

 On Tue, Nov 23, 2010 at 8:20 PM, Martin Grigorov [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=3056080i=0wrote:


  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=nodenode=3056080i=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 LinkVoid(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.7zhttp://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.htmlhttp://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=nodenode=3056080i=2
  For additional commands, e-mail: [hidden 
  email]http://user/SendEmail.jtp?type=nodenode=3056080i=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 
 herehttp://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=3056036code=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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Simple Download from StringResourceStream cause NPE wicket 1.5M3 (possible bug??)

2010-11-23 Thread Martin Grigorov
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 jcgarc...@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-65...@n4.nabble.comml-node%2b3056080-692802461-65...@n4.nabble.com
 ml-node%2b3056080-692802461-65...@n4.nabble.comml-node%252b3056080-692802461-65...@n4.nabble.com
 
  wrote:

  Done.
  r1038292
 
  On Tue, Nov 23, 2010 at 8:20 PM, Martin Grigorov [hidden email]
 http://user/SendEmail.jtp?type=nodenode=3056080i=0wrote:
 
 
   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=nodenode=3056080i=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 LinkVoid(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=nodenode=3056080i=2
   For additional commands, e-mail: [hidden email]
 http://user/SendEmail.jtp?type=nodenode=3056080i=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_codenode=3056036code=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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: Simple Download from StringResourceStream cause NPE wicket 1.5M3 (possible bug??)

2010-11-23 Thread jcgarciam
://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_codenode=3056036code=amNnYXJjaWFtQGdtYWlsLmNvbXwzMDU2MDM2fDEyNTYxMzc3ODY=http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=3056036code=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.htmlhttp://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=nodenode=3056108i=5
  For additional commands, e-mail: [hidden 
  email]http://user/SendEmail.jtp?type=nodenode=3056108i=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 
 herehttp://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=3056036code=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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org