Hi Andrea,

Ah!  The context that some of the Objects need closing and others do not helps clarify things.

I just wrote a client side version of such a wrapper to see if it'd work (it does).  Sounds like an amendment to 'toWriter' to have a no-op-close wrapper around the 1) BufferedWriter, 2) Writer, and 3) OutputStream would fit the bill?

If so, I can try to put something together.

Cheers,

Jim

On 3/12/20 4:33 PM, Andrea Aime wrote:
Hi,
the API is problematic because it happens to create a Writer out of Object, using this method:
https://github.com/geotools/geotools/blob/master/modules/unsupported/geojson/src/main/java/org/geotools/geojson/GeoJSONUtil.java#L117

Some of the "things" passed in need closing (the FileWriter created out of file), others do not. Maybe someone can write a Writer wrapper that does not delegate the close() method down,
and use it for the sources that happen to already be writer or a stream?

Cheers
Andrea



On Thu, Mar 12, 2020 at 8:47 PM Jim Hughes <jhug...@ccri.com <mailto:jhug...@ccri.com>> wrote:

    From API point-of-view, that makes sense.  From a code
    point-of-view, there's a writer created on line 274:
    
https://github.com/geotools/geotools/blob/master/modules/unsupported/geojson/src/main/java/org/geotools/geojson/GeoJSONUtil.java#L274-L278...
    that writer isn't returned, so as-is, the code maybe doing
    something sensible.

    Thoughts?


    On 3/12/20 3:39 PM, Jody Garnett wrote:
    Good timing on testing, it seems rough closing the writer after
    one feature? I would update the javadoc to be clear about the API
    contract and leave the writer open.

    On Thu, Mar 12, 2020 at 11:50 AM Jim Hughes <jhug...@ccri.com
    <mailto:jhug...@ccri.com>> wrote:

        Hi all,

        As a happy coincidence, I was able to test the GeoTools RC
        with GeoMesa.  I did hit an issue or two.

        The first one is that GeoMesa uses GeoTools library code to
        write out GeoJson.  Calls to
        FeatureJSON.writeFeature(SimpleFeature feature, Object
        output) use GeoJSONUtil.encode(String, Writer).

        This encode method was changed[1] to use the
        try-with-resources pattern, and that means the writer we pass
        in gets closed.  This messes up that previous wrote out GeoJSON.

        I see two options:
        A.  This change is a 'bug' and we chat through a GeoTools
        update.
        B.  This change is an improvement, and I should update
        GeoMesa.  (Maybe to use "new
        FeatureEncoder(feature).toJSONString()" along with managing
        the writes to outputstreams, etc.)

        Thoughts?

        Jim

        1.
        
https://github.com/geotools/geotools/commit/8b5d6279474c9dc8962d279a884e508ab670ee3c#diff-208951a6b5feb5f96a890c79c9846389
        2. Example GeoMesa code:
        
https://github.com/locationtech/geomesa/blob/master/geomesa-tools/src/main/scala/org/locationtech/geomesa/tools/export/formats/GeoJsonExporter.scala

        On 3/12/20 12:53 AM, Jody Garnett wrote:
        23-RC is deployed and on SF, will work on blog post while
        waiting for future builds.
        --
        Jody Garnett


        On Wed, 11 Mar 2020 at 07:25, Jody Garnett
        <jody.garn...@gmail.com <mailto:jody.garn...@gmail.com>> wrote:

            Thanks for letting me know, speed seems good from this
            end. Thanks for building from the tag, that may have to
            do for timezone testing.
            I will start geowebcache release cycle at end-of-day.
            --
            Jody Garnett


            On Wed, 11 Mar 2020 at 02:17, Andrea Aime
            <andrea.a...@geo-solutions.it
            <mailto:andrea.a...@geo-solutions.it>> wrote:

                Hi Jody,
                I'm having trouble connecting to anything that's in
                the US, getting to the build server is very slow,
                downloading the package times out instead.
                I've tried building out of github checkouts (that
                one works) but it still gets stuck trying to download
                from the boundless repository...

                Will try again later, hopefully it's a short lived
                situation

                Cheers
                Andrea


                On Wed, Mar 11, 2020 at 4:30 AM Jody Garnett
                <jody.garn...@gmail.com
                <mailto:jody.garn...@gmail.com>> wrote:

                    Build is once again complete, please test
                    artifacts and report back:
                    -
                    
https://build.geoserver.org/view/release/job/geotools-release/230/artifact/build/release/distribution/23-RC/

                    Andrea if testing is successful please proceed
                    with geowebcache, or I will catch it tomorrow
                    after work.
                    --
                    Jody Garnett
                    _______________________________________________
                    GeoTools-Devel mailing list
                    GeoTools-Devel@lists.sourceforge.net
                    <mailto: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
                
<https://www.google.com/maps/search/Via+di+Montramito+3%2FA%0D%0A55054++Massarosa?entry=gmail&source=g>
                (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  
<mailto:GeoTools-Devel@lists.sourceforge.net>
        https://lists.sourceforge.net/lists/listinfo/geotools-devel


        _______________________________________________
        GeoTools-Devel mailing list
        GeoTools-Devel@lists.sourceforge.net
        <mailto:GeoTools-Devel@lists.sourceforge.net>
        https://lists.sourceforge.net/lists/listinfo/geotools-devel

-- --
    Jody Garnett


    _______________________________________________
    GeoTools-Devel mailing list
    GeoTools-Devel@lists.sourceforge.net
    <mailto: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

Reply via email to