Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #35281
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Cecil Westerhof <Cecil@decebal.nl> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Not closing connections and statements |
| Date | Sat, 13 Aug 2016 01:19:25 +0200 |
| Organization | Decebal Computing |
| Lines | 37 |
| Message-ID | <87bn0xlgn6.fsf@Equus.decebal.nl> (permalink) |
| References | <87shuakxjq.fsf@Equus.decebal.nl> <nol6er$gf5$1@dont-email.me> <87k2fllkjf.fsf@Equus.decebal.nl> <nolhsq$b0s$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | mx02.eternal-september.org; posting-host="12baf5125b19322b899c79c2e3878015"; logging-data="24887"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+pP1c+rljzi/Re95TSsvD6+DkaogD/5iM=" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
| X-Homepage | http://www.decebal.nl/ |
| Cancel-Lock | sha1:ye4KbVLqiAdgMWhjvG7t7uiY8MU= sha1:gdlbsVOSnECH6H7cQ6ejNBI9xj0= |
| Xref | csiph.com comp.lang.java.programmer:35281 |
Show key headers only | View raw
On Saturday 13 Aug 2016 00:16 CEST, Eric Sosman wrote:
> On 8/12/2016 5:55 PM, Cecil Westerhof wrote:
>> On Friday 12 Aug 2016 21:01 CEST, Martin Gregorie wrote:
>>
>>> [...] the connection should always be closed as one of the last
>>> actions in the process - putting the close() inside a finally{}
>>> block is a good idea.
>> [...]
>> As I understood it the execution of finally is not guaranteed.
>
> Code in a `finally' block is guaranteed to execute, no matter how
> the matching `try' block completes: return, break, continue, throw,
> or run to the closing brace. (Well, the "guarantee" is only as solid
> as the JVM itself: If somebody shuts down the JVM with System.exit()
> or similar, the no-longer-running JVM cannot execute `finally'
> blocks. And if the JVM goes completely haywire and can no longer
> execute Java, all bets are off. But in the absence of such
> catastrophes, execution of a `finally' block is guaranteed at the
> same level of confidence as constructor chaining.)
>
> Perhaps you've confused `finally' with `finalize()'?
Yes, my bad: I did not read correctly. :'-(
But the finally block is no use. As long as the program is running the
connection is used. Only when the program terminates the connection
could/should be closed. But I do not really know when it is closed.
(Certainly not when others use the code.) With the information I have
now it looks like it is not really a problem when the connection is
not closed when it is used during the complete run time of the
program.
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-12 13:59 +0200
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 09:15 -0400
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 09:39 -0400
Re: Not closing connections and statements Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-08-12 22:31 +0200
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 22:04 -0400
Re: Not closing connections and statements Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-08-13 07:55 +0200
Re: Not closing connections and statements Martin Gregorie <martin@address-in-sig.invalid> - 2016-08-12 19:01 +0000
Re: Not closing connections and statements Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-08-12 22:35 +0200
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 21:52 -0400
Re: Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-12 23:55 +0200
Re: Not closing connections and statements Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-12 18:16 -0400
Re: Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-13 01:19 +0200
Re: Not closing connections and statements Martin Gregorie <martin@address-in-sig.invalid> - 2016-08-13 00:21 +0000
Re: Not closing connections and statements Gunter Herrmann <gunter.herrmann@earthlink.net> - 2016-08-17 16:38 -0400
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 21:58 -0400
Re: Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-13 12:50 +0200
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 21:59 -0400
Re: Not closing connections and statements Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-08-13 08:47 +0200
Re: Not closing connections and statements Andreas Leitgeb <avl@logic.at> - 2016-08-13 08:05 +0000
Re: Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-13 12:21 +0200
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-13 09:54 -0400
Re: Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-13 12:19 +0200
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-13 10:04 -0400
log4j RollingFileAppender (was: Not closing connections and statements) Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-08-14 22:24 +0200
Re: log4j RollingFileAppender Arne Vajhøj <arne@vajhoej.dk> - 2016-08-14 21:01 -0400
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-13 11:58 -0400
logging (was: Not closing connections and statements) Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-08-14 23:46 +0200
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 21:44 -0400
Re: Not closing connections and statements Florian Weimer <fw@deneb.enyo.de> - 2016-08-13 16:33 +0200
Re: Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-13 17:34 +0200
csiph-web