Thanks for the input guys. Your suggestions make sense. I'll try removing
the seek and see how that works with all of the geotools/geoserver unit
tests and also do some smoke testing. I'll file a bug in jira with all of
the details as well.

On Thu, Oct 31, 2019 at 3:55 AM Daniele Romagnoli <
daniele.romagn...@geo-solutions.it> wrote:

> Hi Justin,
> I tracked a bit the git history and it looks like that this seek(0) is
> there since 2012 (that is where the git history ends more or less).
> Not sure if that seek(0) has been put there for a real reason (since JAI
> uses deferred execution and reader can start the actual read only once
> need) or as a some kind of precaution.
> I think that you could try removing that line and do some GeoServer tests
> using ImageMosaic with configured "use JAI imageread" and see what happens
> under load.
>
> Please, let us know.
> Regards,
> Daniele
>
>
>
>
>
>
> On Thu, Oct 31, 2019 at 10:05 AM Andrea Aime <andrea.a...@geo-solutions.it>
> wrote:
>
>> Hi Justin,
>> before we add a flag to work around it, I was wondering if the issue
>> could be fixed in a different way, like, at the source.
>>
>> Looking at the FileImageInputStreamImpl, I've noticed one oddball thing,
>> but it's probably not related: the lines do not seem matching up.
>>
>> https://github.com/geosolutions-it/imageio-ext/blob/master/library/streams/src/main/java/it/geosolutions/imageio/stream/input/FileImageInputStreamExtImpl.java#L285
>>
>> Anyways, the error in question is a few lines above... seems someone is
>> reading the header (to get the color model as you say), the PNGImageReader
>> calls flushBefore updating the flushedPos, and then the seek(0) in
>> ReadType.JAI_IMAGEREAD fails. Hum... I'm wondering if the seek(0) really
>> necessary, given that the reader has been provided as parameter? (e.g., is
>> it the same read on which we called to get the color model?). Another
>> option could be to temporarily pass a wrapping input stream killing the
>> flushbefore, just for the sake of reading the header...
>>
>> Daniele's input much appreciated too :-D
>>
>> Cheers
>> Andrea
>>
>>
>> On Wed, Oct 30, 2019 at 9:43 PM Justin Deoliveira <jdeol...@gmail.com>
>> wrote:
>>
>>> Hi folks,
>>>
>>> I am working on upgrading an application from a much older version of
>>> geotools (15.1) to the latest stable. I've hit a roadblock regarding image
>>> mosaics consisting of indexed PNG files that I think I have narrowed down
>>> to this change:
>>>
>>>
>>> https://github.com/geotools/geotools/commit/585b021d15df7d132bd6963d7fb78338e814b625
>>>
>>>
>>> What appears to be happening is that the call to getRawColorModel is
>>> advancing the underlying image stream. Later on in the process that same
>>> stream stream is "seeked" back to the zero position in preparation for the
>>> actual read operation, and that throws an exception:
>>>
>>> java.lang.IllegalArgumentException: pos < flushedPos!
>>> at
>>> it.geosolutions.imageio.stream.input.FileImageInputStreamExtImpl.seek(FileImageInputStreamExtImpl.java:285)
>>> at
>>> org.geotools.coverage.grid.io.imageio.ReadType$2.read(ReadType.java:131)
>>> at
>>> org.geotools.gce.imagemosaic.GranuleDescriptor.loadRaster(GranuleDescriptor.java:928)
>>>
>>>
>>> I am guessing it's perhaps some limitation with the PNG format (which I
>>> know is about the worst possible format to be rendering imagery from 🤔 ).
>>>
>>> So I guess my first question is would this be considered a bug? Or more
>>> or a limitation with this particular file format? I am guessing a bug since
>>> prior to this change this scenario works.
>>>
>>> Assuming that bug is the consensus I'd be happy to attempt a patch but
>>> probably need some guidance on how to proceed. My initial thought for a
>>> "quick fix" was that perhaps we could add a flag to the mosaic
>>> configuration or a read parameter that specified explicitly that the images
>>> in the mosaic have an IndexColorModel so that we can forgo the check and
>>> hence not pre-advance the image stream?
>>>
>>> Thoughts appreciated.
>>>
>>> Thanks!
>>>
>>> -Justin
>>>
>>>
>>> _______________________________________________
>>> GeoTools-Devel mailing list
>>> GeoTools-Devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>>>
>>
>>
>> --
>>
>> Regards, Andrea Aime == GeoServer Professional Services from the experts!
>> Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime
>> @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054
>> Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339
>> 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it
>> ------------------------------------------------------- *Con riferimento
>> alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 -
>> Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni
>> circostanza inerente alla presente email (il suo contenuto, gli eventuali
>> allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i
>> destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per
>> errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le
>> sarei comunque grato se potesse darmene notizia. This email is intended
>> only for the person or entity to which it is addressed and may contain
>> information that is privileged, confidential or otherwise protected from
>> disclosure. We remind that - as provided by European Regulation 2016/679
>> “GDPR” - copying, dissemination or use of this e-mail or the information
>> herein by anyone other than the intended recipient is prohibited. If you
>> have received this email by mistake, please notify us immediately by
>> telephone or e-mail.*
>> _______________________________________________
>> GeoTools-Devel mailing list
>> GeoTools-Devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>>
>
>
> --
> Regards,
> Daniele Romagnoli
> ==
> GeoServer Professional Services from the experts! Visit
> http://goo.gl/it488V for more information.
> ==
>
> Ing. Daniele Romagnoli
> Senior Software Engineer
>
> GeoSolutions S.A.S.
> Via di Montramito 3/A
> 55054  Massarosa (LU)
> Italy
> phone: +39 0584 962313
> fax:      +39 0584 1660272
>
> http://www.geo-solutions.it
> http://twitter.com/geosolutions_it
>
> -------------------------------------------------------
>
> Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE
> 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si
> precisa che ogni circostanza inerente alla presente email (il suo
> contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è
> riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il
> messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra
> operazione è illecita. Le sarei comunque grato se potesse darmene notizia.
>
> This email is intended only for the person or entity to which it is
> addressed and may contain information that is privileged, confidential or
> otherwise protected from disclosure. We remind that - as provided by
> European Regulation 2016/679 “GDPR” - copying, dissemination or use of this
> e-mail or the information herein by anyone other than the intended
> recipient is prohibited. If you have received this email by mistake, please
> notify us immediately by telephone or e-mail.
>
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to