Re: getResourceAsStream() for a folder

2016-10-14 Thread Svetlin Zarev
Oops, I was looking at the code before the fix. Sorry.

2016-10-14 9:07 GMT+03:00 Svetlin Zarev :

> Hi Mark!
>
> > Fixed.
>
> > Mark
>
>
> What about the inconsistency between getContent() and doGetInputStream() ?
> In case of doGetInputStream() when a FileNotFoundException is thrown, the
> caller will get a "null" stream. But in case of getContent() the caller
> will get a byte[] full of zeroes, which will result in ByteArrayInputStream
> that returns incorrect content. Also if an IOEx is thrown during read, the
> caller may get corrupted content -> one part filled with zeroes.
>
>
> Best regards,
>
> Svetlin
>


Re: getResourceAsStream() for a folder

2016-10-14 Thread Svetlin Zarev
Hi Mark!

> Fixed.

> Mark


What about the inconsistency between getContent() and doGetInputStream() ?
In case of doGetInputStream() when a FileNotFoundException is thrown, the
caller will get a "null" stream. But in case of getContent() the caller
will get a byte[] full of zeroes, which will result in ByteArrayInputStream
that returns incorrect content. Also if an IOEx is thrown during read, the
caller may get corrupted content -> one part filled with zeroes.


Best regards,

Svetlin


Re: getResourceAsStream() for a folder

2016-10-13 Thread Romain Manni-Bucau
Thanks Mark!


Romain Manni-Bucau
@rmannibucau  |  Blog
 | Old Wordpress Blog
 | Github  |
LinkedIn  | Tomitriber
 | JavaEE Factory


2016-10-13 16:05 GMT+02:00 Mark Thomas :

> On 13/10/2016 14:27, Mark Thomas wrote:
> > On 13/10/2016 13:13, Romain Manni-Bucau wrote:
> >> @Svetlin: thanks to catch it, was intended for dev@tomcat (thanks
> gmail to
> >> have completion ;))
> >>
> >> dev@tomcat: can you check please the original question (in short:
> >> getResourceAsStream("/some/folder")
> >> returns a stream)
> >
> > Thanks for the heads up. I'll take a look.
>
> Fixed.
>
> Mark
>
> >> Romain Manni-Bucau
> >> @rmannibucau  |  Blog
> >>  | Old Wordpress Blog
> >>  | Github  rmannibucau> |
> >> LinkedIn  | Tomitriber
> >>  | JavaEE Factory
> >> 
> >>
> >> 2016-10-13 13:59 GMT+02:00 Svetlin Zarev  com>:
> >>
> >>> Hi,
> >>>
> >>> IMO this is a bug introduced with [1][2]. Although the root cause is
> in the
> >>> bad impl. of FileResource [3] that ignores the IOException and despite
> the
> >>> error, still returns a byte[] as if nothing bad happened.
> >>>
> >>>
> >>> [1] https://bz.apache.org/bugzilla/show_bug.cgi?id=60146
> >>> [2]
> >>> https://github.com/apache/tomcat85/blob/5768426dd27422747f2b9b4da5a092
> >>> 7ee3328ffb/java/org/apache/catalina/webresources/
> CachedResource.java#L267
> >>> [3]
> >>> https://github.com/apache/tomcat85/blob/5768426dd27422747f2b9b4da5a092
> >>> 7ee3328ffb/java/org/apache/catalina/webresources/
> FileResource.java#L203
> >>>
> >>> PS: Maybe this should be forwarded to the tomcat dev list ?
> >>>
> >>> Kind regards,
> >>> Svetlin
> >>>
> >>> 2016-10-13 12:06 GMT+03:00 Romain Manni-Bucau :
> >>>
>  Hi guys,
> 
>  upgrading tomee to tomcat 8.5.6 I noticed request.getServletContext().
>  getResourceAsStream(path) now returns an empty stream for / (or an
> >>> existing
>  folder probably). Not sure it is expected or unintended.
> 
>  Reading the spec it is not that clear to me since the folder is an
> >>> existing
>  resource but not really a webresource so not it should be considered
> as a
>  resource and therefore having a stream (which doesn't mean much for a
>  folder).
> 
>  Romain Manni-Bucau
>  @rmannibucau  |  Blog
>   | Old Wordpress Blog
>   | Github   rmannibucau> |
>  LinkedIn  | Tomitriber
>   | JavaEE Factory
>  
> 
> >>>
> >>
> >
> >
> > -
> > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> > For additional commands, e-mail: dev-h...@tomcat.apache.org
> >
>
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>
>


Re: getResourceAsStream() for a folder

2016-10-13 Thread Mark Thomas
On 13/10/2016 14:27, Mark Thomas wrote:
> On 13/10/2016 13:13, Romain Manni-Bucau wrote:
>> @Svetlin: thanks to catch it, was intended for dev@tomcat (thanks gmail to
>> have completion ;))
>>
>> dev@tomcat: can you check please the original question (in short:
>> getResourceAsStream("/some/folder")
>> returns a stream)
> 
> Thanks for the heads up. I'll take a look.

Fixed.

Mark

>> Romain Manni-Bucau
>> @rmannibucau  |  Blog
>>  | Old Wordpress Blog
>>  | Github  
>> |
>> LinkedIn  | Tomitriber
>>  | JavaEE Factory
>> 
>>
>> 2016-10-13 13:59 GMT+02:00 Svetlin Zarev :
>>
>>> Hi,
>>>
>>> IMO this is a bug introduced with [1][2]. Although the root cause is in the
>>> bad impl. of FileResource [3] that ignores the IOException and despite the
>>> error, still returns a byte[] as if nothing bad happened.
>>>
>>>
>>> [1] https://bz.apache.org/bugzilla/show_bug.cgi?id=60146
>>> [2]
>>> https://github.com/apache/tomcat85/blob/5768426dd27422747f2b9b4da5a092
>>> 7ee3328ffb/java/org/apache/catalina/webresources/CachedResource.java#L267
>>> [3]
>>> https://github.com/apache/tomcat85/blob/5768426dd27422747f2b9b4da5a092
>>> 7ee3328ffb/java/org/apache/catalina/webresources/FileResource.java#L203
>>>
>>> PS: Maybe this should be forwarded to the tomcat dev list ?
>>>
>>> Kind regards,
>>> Svetlin
>>>
>>> 2016-10-13 12:06 GMT+03:00 Romain Manni-Bucau :
>>>
 Hi guys,

 upgrading tomee to tomcat 8.5.6 I noticed request.getServletContext().
 getResourceAsStream(path) now returns an empty stream for / (or an
>>> existing
 folder probably). Not sure it is expected or unintended.

 Reading the spec it is not that clear to me since the folder is an
>>> existing
 resource but not really a webresource so not it should be considered as a
 resource and therefore having a stream (which doesn't mean much for a
 folder).

 Romain Manni-Bucau
 @rmannibucau  |  Blog
  | Old Wordpress Blog
  | Github  |
 LinkedIn  | Tomitriber
  | JavaEE Factory
 

>>>
>>
> 
> 
> -
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
> 


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: getResourceAsStream() for a folder

2016-10-13 Thread Mark Thomas
On 13/10/2016 13:13, Romain Manni-Bucau wrote:
> @Svetlin: thanks to catch it, was intended for dev@tomcat (thanks gmail to
> have completion ;))
> 
> dev@tomcat: can you check please the original question (in short:
> getResourceAsStream("/some/folder")
> returns a stream)

Thanks for the heads up. I'll take a look.

Mark

> 
> 
> Romain Manni-Bucau
> @rmannibucau  |  Blog
>  | Old Wordpress Blog
>  | Github  |
> LinkedIn  | Tomitriber
>  | JavaEE Factory
> 
> 
> 2016-10-13 13:59 GMT+02:00 Svetlin Zarev :
> 
>> Hi,
>>
>> IMO this is a bug introduced with [1][2]. Although the root cause is in the
>> bad impl. of FileResource [3] that ignores the IOException and despite the
>> error, still returns a byte[] as if nothing bad happened.
>>
>>
>> [1] https://bz.apache.org/bugzilla/show_bug.cgi?id=60146
>> [2]
>> https://github.com/apache/tomcat85/blob/5768426dd27422747f2b9b4da5a092
>> 7ee3328ffb/java/org/apache/catalina/webresources/CachedResource.java#L267
>> [3]
>> https://github.com/apache/tomcat85/blob/5768426dd27422747f2b9b4da5a092
>> 7ee3328ffb/java/org/apache/catalina/webresources/FileResource.java#L203
>>
>> PS: Maybe this should be forwarded to the tomcat dev list ?
>>
>> Kind regards,
>> Svetlin
>>
>> 2016-10-13 12:06 GMT+03:00 Romain Manni-Bucau :
>>
>>> Hi guys,
>>>
>>> upgrading tomee to tomcat 8.5.6 I noticed request.getServletContext().
>>> getResourceAsStream(path) now returns an empty stream for / (or an
>> existing
>>> folder probably). Not sure it is expected or unintended.
>>>
>>> Reading the spec it is not that clear to me since the folder is an
>> existing
>>> resource but not really a webresource so not it should be considered as a
>>> resource and therefore having a stream (which doesn't mean much for a
>>> folder).
>>>
>>> Romain Manni-Bucau
>>> @rmannibucau  |  Blog
>>>  | Old Wordpress Blog
>>>  | Github >> rmannibucau> |
>>> LinkedIn  | Tomitriber
>>>  | JavaEE Factory
>>> 
>>>
>>
> 


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: getResourceAsStream() for a folder

2016-10-13 Thread Romain Manni-Bucau
@Svetlin: thanks to catch it, was intended for dev@tomcat (thanks gmail to
have completion ;))

dev@tomcat: can you check please the original question (in short:
getResourceAsStream("/some/folder")
returns a stream)


Romain Manni-Bucau
@rmannibucau  |  Blog
 | Old Wordpress Blog
 | Github  |
LinkedIn  | Tomitriber
 | JavaEE Factory


2016-10-13 13:59 GMT+02:00 Svetlin Zarev :

> Hi,
>
> IMO this is a bug introduced with [1][2]. Although the root cause is in the
> bad impl. of FileResource [3] that ignores the IOException and despite the
> error, still returns a byte[] as if nothing bad happened.
>
>
> [1] https://bz.apache.org/bugzilla/show_bug.cgi?id=60146
> [2]
> https://github.com/apache/tomcat85/blob/5768426dd27422747f2b9b4da5a092
> 7ee3328ffb/java/org/apache/catalina/webresources/CachedResource.java#L267
> [3]
> https://github.com/apache/tomcat85/blob/5768426dd27422747f2b9b4da5a092
> 7ee3328ffb/java/org/apache/catalina/webresources/FileResource.java#L203
>
> PS: Maybe this should be forwarded to the tomcat dev list ?
>
> Kind regards,
> Svetlin
>
> 2016-10-13 12:06 GMT+03:00 Romain Manni-Bucau :
>
> > Hi guys,
> >
> > upgrading tomee to tomcat 8.5.6 I noticed request.getServletContext().
> > getResourceAsStream(path) now returns an empty stream for / (or an
> existing
> > folder probably). Not sure it is expected or unintended.
> >
> > Reading the spec it is not that clear to me since the folder is an
> existing
> > resource but not really a webresource so not it should be considered as a
> > resource and therefore having a stream (which doesn't mean much for a
> > folder).
> >
> > Romain Manni-Bucau
> > @rmannibucau  |  Blog
> >  | Old Wordpress Blog
> >  | Github  > rmannibucau> |
> > LinkedIn  | Tomitriber
> >  | JavaEE Factory
> > 
> >
>