Re: Backporting try-with-resources to Java < 7 (was: Re: [imaging] Closing stream)

2013-11-04 Thread Matt Benson
On Nov 4, 2013 1:12 AM, "Damjan Jovanovic" wrote: > > For the record, I would only use this for imaging >= 2.0. > > Weaver looked undocumented and undecipherable to me, but let me look at it > again slowly. Tell me how you really feel! :-) More seriously, tell me how to fix these problems. There

Re: Backporting try-with-resources to Java < 7 (was: Re: [imaging] Closing stream)

2013-11-04 Thread Damjan Jovanovic
e > From: Damjan Jovanovic > Date:11/04/2013 02:11 (GMT-05:00) > To: Commons Developers List > Subject: Re: Backporting try-with-resources to Java < 7 (was: Re: > [imaging] Closing stream) > > For the record, I would only use this for imaging >= 2.0. > > Weave

Re: Backporting try-with-resources to Java < 7 (was: Re: [imaging] Closing stream)

2013-11-04 Thread Gary Gregory
I thought we were going to Java 7 for 2.0? Gary Original message From: Damjan Jovanovic Date:11/04/2013 02:11 (GMT-05:00) To: Commons Developers List Subject: Re: Backporting try-with-resources to Java < 7 (was: Re: [imaging] Closing stream) For the record, I wo

Re: Backporting try-with-resources to Java < 7 (was: Re: [imaging] Closing stream)

2013-11-03 Thread Damjan Jovanovic
For the record, I would only use this for imaging >= 2.0. Weaver looked undocumented and undecipherable to me, but let me look at it again slowly. Damjan On Sun, Nov 3, 2013 at 9:14 PM, Matt Benson wrote: > I wasn't under the impression this was blocking imaging 1.0. In any case, > framing Da

Re: Backporting try-with-resources to Java < 7 (was: Re: [imaging] Closing stream)

2013-11-03 Thread Matt Benson
I wasn't under the impression this was blocking imaging 1.0. In any case, framing Damjan's work as a Weaver module would still use the same work he's done with ASM and would really only utilize a standard mechanism for triggering the process. It would also avoid proliferation of multiple maven plug

Re: Backporting try-with-resources to Java < 7 (was: Re: [imaging] Closing stream)

2013-11-03 Thread Gary Gregory
On Sun, Nov 3, 2013 at 10:56 AM, Matt Benson wrote: > Sounds like it would be trivial to frame what you've done here into the > context of a Weaver module, for which there exist both a maven plugin and > an Antlib, as well as a need for a near-term release. :-) > and eating our own dog food :)

Re: Backporting try-with-resources to Java < 7 (was: Re: [imaging] Closing stream)

2013-11-03 Thread Matt Benson
Sounds like it would be trivial to frame what you've done here into the context of a Weaver module, for which there exist both a maven plugin and an Antlib, as well as a need for a near-term release. :-) Matt On Nov 3, 2013 2:30 AM, "Damjan Jovanovic" wrote: > On Fri, Oct 25, 2013 at 1:52 PM, Ma

RE: Backporting try-with-resources to Java < 7 (was: Re: [imaging] Closing stream)

2013-11-03 Thread Gary Gregory
Original message From: Damjan Jovanovic Date:11/03/2013 03:30 (GMT-05:00) To: Commons Developers List Subject: Backporting try-with-resources to Java < 7 (was: Re: [imaging] Closing stream) On Fri, Oct 25, 2013 at 1:52 PM, Matt Benson wrote: > On Oct 25, 2013 6

Backporting try-with-resources to Java < 7 (was: Re: [imaging] Closing stream)

2013-11-03 Thread Damjan Jovanovic
On Fri, Oct 25, 2013 at 1:52 PM, Matt Benson wrote: > On Oct 25, 2013 6:30 AM, "Damjan Jovanovic" wrote: > > > > On Fri, Oct 25, 2013 at 12:36 PM, Jörg Schaible > > wrote: > > > Hi Damjan, > > > > > > Damjan Jovanovic wrote: > > > > > > [snip] > > > > > > Thanks for explanation. > > > > > >> We

Re: [imaging] Closing stream

2013-10-30 Thread Jörg Schaible
Hi Damjan, Damjan Jovanovic wrote: > For the sake of similarity of 1.0 with 0.x versions, I've stayed with Java > 1.5 and in commit 1537238 I've gone with the set flag on every successful > return path + closeQuietly() idea. Looks good now. Thanks for your effort. > It was a mission and broke t

Re: [imaging] Closing stream

2013-10-30 Thread Benedikt Ritter
Sounds good to me. 2013/10/30 Damjan Jovanovic > For the sake of similarity of 1.0 with 0.x versions, I've stayed with Java > 1.5 and in commit 1537238 I've gone with the set flag on every successful > return path + closeQuietly() idea. > > It was a mission and broke things (DeflaterOutputStrea

Re: [imaging] Closing stream

2013-10-30 Thread Damjan Jovanovic
For the sake of similarity of 1.0 with 0.x versions, I've stayed with Java 1.5 and in commit 1537238 I've gone with the set flag on every successful return path + closeQuietly() idea. It was a mission and broke things (DeflaterOutputStream apparently doesn't honor flush()). I am moving Imaging to

Re: [imaging] Closing stream

2013-10-27 Thread Gary Gregory
On Sun, Oct 27, 2013 at 1:51 AM, Damjan Jovanovic wrote: > an > > On Fri, Oct 25, 2013 at 5:24 PM, Jörg Schaible > wrote: > > Hi Damjan, > > > > Damjan Jovanovic wrote: > > > >> On Fri, Oct 25, 2013 at 12:36 PM, Jörg Schaible > >> wrote: > >>> Hi Damjan, > >>> > >>> Damjan Jovanovic wrote: > >>

Re: [imaging] Closing stream

2013-10-27 Thread sebb
On 27 October 2013 05:51, Damjan Jovanovic wrote: > an > > On Fri, Oct 25, 2013 at 5:24 PM, Jörg Schaible wrote: >> Hi Damjan, >> >> Damjan Jovanovic wrote: >> >>> On Fri, Oct 25, 2013 at 12:36 PM, Jörg Schaible >>> wrote: Hi Damjan, Damjan Jovanovic wrote: [snip]

Re: [imaging] Closing stream

2013-10-26 Thread Damjan Jovanovic
an On Fri, Oct 25, 2013 at 5:24 PM, Jörg Schaible wrote: > Hi Damjan, > > Damjan Jovanovic wrote: > >> On Fri, Oct 25, 2013 at 12:36 PM, Jörg Schaible >> wrote: >>> Hi Damjan, >>> >>> Damjan Jovanovic wrote: >>> >>> [snip] >>> >>> Thanks for explanation. >>> We would be able to adapt that

Re: [imaging] Closing stream

2013-10-25 Thread Jörg Schaible
Hi Sebb, sebb wrote: > There was some related discussion here: > > https://issues.apache.org/jira/browse/IO-249 Yeah, this CloseableHandler is another interesting approach. It does just not cover the problem of the "original exception" (yet). Cheers, Jörg --

Re: [imaging] Closing stream

2013-10-25 Thread Jörg Schaible
Hi Damjan, Damjan Jovanovic wrote: > On Fri, Oct 25, 2013 at 12:36 PM, Jörg Schaible > wrote: >> Hi Damjan, >> >> Damjan Jovanovic wrote: >> >> [snip] >> >> Thanks for explanation. >> >>> We would be able to adapt that for Java < 1.7 by swallowing the close >>> exception instead of calling addSu

Re: [imaging] Closing stream

2013-10-25 Thread sebb
It relates to the general discussion On 25 October 2013 15:21, Matt Benson wrote: > Thanks, Sebastian, but I don't see how the discussion there relates to the > "custom Java compiler" alternative postulated by Damjan, which is what I was > responding to. Which is not to say it doesn't relate; I

Re: [imaging] Closing stream

2013-10-25 Thread Matt Benson
Thanks, Sebastian, but I don't see how the discussion there relates to the "custom Java compiler" alternative postulated by Damjan, which is what I was responding to. Which is not to say it doesn't relate; I may be being thick. Matt On Fri, Oct 25, 2013 at 8:50 AM, sebb wrote: > There was som

Re: [imaging] Closing stream

2013-10-25 Thread sebb
There was some related discussion here: https://issues.apache.org/jira/browse/IO-249 On 25 October 2013 12:52, Matt Benson wrote: > On Oct 25, 2013 6:30 AM, "Damjan Jovanovic" wrote: >> >> On Fri, Oct 25, 2013 at 12:36 PM, Jörg Schaible >> wrote: >> > Hi Damjan, >> > >> > Damjan Jovanovic wrot

Re: [imaging] Closing stream

2013-10-25 Thread Matt Benson
On Oct 25, 2013 6:30 AM, "Damjan Jovanovic" wrote: > > On Fri, Oct 25, 2013 at 12:36 PM, Jörg Schaible > wrote: > > Hi Damjan, > > > > Damjan Jovanovic wrote: > > > > [snip] > > > > Thanks for explanation. > > > >> We would be able to adapt that for Java < 1.7 by swallowing the close > >> excepti

Re: [imaging] Closing stream

2013-10-25 Thread Damjan Jovanovic
On Fri, Oct 25, 2013 at 12:36 PM, Jörg Schaible wrote: > Hi Damjan, > > Damjan Jovanovic wrote: > > [snip] > > Thanks for explanation. > >> We would be able to adapt that for Java < 1.7 by swallowing the close >> exception instead of calling addSuppressed() on the primary exception, >> but the sho

Re: [imaging] Closing stream

2013-10-25 Thread Jörg Schaible
Hi Damjan, Damjan Jovanovic wrote: [snip] Thanks for explanation. > We would be able to adapt that for Java < 1.7 by swallowing the close > exception instead of calling addSuppressed() on the primary exception, > but the show stopper is catching and rethrowing the primary exception > (Throwable

Re: [imaging] Closing stream

2013-10-25 Thread Damjan Jovanovic
On Fri, Oct 25, 2013 at 9:01 AM, Jörg Schaible wrote: > Hi Damjan, > > Damjan Jovanovic wrote: > >> On Thu, Oct 24, 2013 at 11:29 PM, Gary Gregory >> wrote: >>> On Thu, Oct 24, 2013 at 4:31 PM, Jörg Schaible >>> wrote: >>> Hi Damjan, Damjan Jovanovic wrote: > As one of th

Re: [imaging] Closing stream

2013-10-25 Thread Julien Aymé
Hi, Concerning Java 7, I think that the try-with-ressources throws the first exception encountered, and add other exceptions in the "suppressed" exceptions. See http://docs.oracle.com/javase/7/docs/api/java/lang/Throwable.html#addSuppressed(java.lang.Throwable) My 2 cents, Regards, Julien 2013/

Re: [imaging] Closing stream

2013-10-25 Thread Jörg Schaible
Hi Damjan, Damjan Jovanovic wrote: > On Thu, Oct 24, 2013 at 11:29 PM, Gary Gregory > wrote: >> On Thu, Oct 24, 2013 at 4:31 PM, Jörg Schaible >> wrote: >> >>> Hi Damjan, >>> >>> Damjan Jovanovic wrote: >>> >>> > As one of the perpetrators of the problem, I have now fixed it. The >>> > reasons I

Re: [imaging] Closing stream

2013-10-24 Thread Damjan Jovanovic
On Thu, Oct 24, 2013 at 11:29 PM, Gary Gregory wrote: > On Thu, Oct 24, 2013 at 4:31 PM, Jörg Schaible wrote: > >> Hi Damjan, >> >> Damjan Jovanovic wrote: >> >> > As one of the perpetrators of the problem, I have now fixed it. The >> > reasons I swallowed exceptions were simple: >> >> [snip] >> >

Re: [imaging] Closing stream

2013-10-24 Thread Gary Gregory
On Thu, Oct 24, 2013 at 4:31 PM, Jörg Schaible wrote: > Hi Damjan, > > Damjan Jovanovic wrote: > > > As one of the perpetrators of the problem, I have now fixed it. The > > reasons I swallowed exceptions were simple: > > [snip] > > > * when an exception is thrown and close() then throws another >

Re: [imaging] Closing stream

2013-10-24 Thread Jörg Schaible
Hi Damjan, Damjan Jovanovic wrote: > As one of the perpetrators of the problem, I have now fixed it. The > reasons I swallowed exceptions were simple: [snip] > * when an exception is thrown and close() then throws another > exception, the close() exception is propagated and the original > excep

Re: [imaging] Closing stream

2013-10-24 Thread Damjan Jovanovic
As one of the perpetrators of the problem, I have now fixed it. The reasons I swallowed exceptions were simple: * when multiple resources need to be closed, earlier exceptions in finally cause later close() methods to get skipped and those resources to leak * when an exception is thrown and close()

Re: [imaging] Closing stream

2013-10-23 Thread Damjan Jovanovic
On Thu, Oct 24, 2013 at 4:34 AM, Bernd Eckenfels wrote: > Am 24.10.2013, 02:16 Uhr, schrieb Gary Gregory : > >> try { >> if (outputStream != null) { >> outputStream.close(); >> } >> } catch (final Exception e) { >>

Re: [imaging] Closing stream

2013-10-23 Thread Bernd Eckenfels
Am 24.10.2013, 02:16 Uhr, schrieb Gary Gregory : try { if (outputStream != null) { outputStream.close(); } } catch (final Exception e) { Debug.debug(e); } this calls for a helper or a private

Re: [imaging] Closing stream

2013-10-23 Thread sebb
On 24 October 2013 02:49, Gary Gregory wrote: > On Wed, Oct 23, 2013 at 9:38 PM, sebb wrote: > >> On 24 October 2013 01:16, Gary Gregory wrote: >> > Hi All: >> > >> > I see a log of this pattern: >> > >> > try { >> > if (outputStream != null) { >> >

Re: [imaging] Closing stream

2013-10-23 Thread Gary Gregory
On Wed, Oct 23, 2013 at 9:38 PM, sebb wrote: > On 24 October 2013 01:16, Gary Gregory wrote: > > Hi All: > > > > I see a log of this pattern: > > > > try { > > if (outputStream != null) { > > outputStream.close(); > > } > >

Re: [imaging] Closing stream

2013-10-23 Thread sebb
On 24 October 2013 01:16, Gary Gregory wrote: > Hi All: > > I see a log of this pattern: > > try { > if (outputStream != null) { > outputStream.close(); > } > } catch (final Exception e) { > Debug.debug(e);

[imaging] Closing stream

2013-10-23 Thread Gary Gregory
Hi All: I see a log of this pattern: try { if (outputStream != null) { outputStream.close(); } } catch (final Exception e) { Debug.debug(e); } for example in org.apache.commons.imaging.Imaging