Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Andreas Leitgeb Newsgroups: comp.lang.java.programmer Subject: Re: it's Closeable, but I don't want to close() it yet. Date: Fri, 1 Mar 2019 09:43:22 -0000 (UTC) Organization: A noiseless patient Spider Lines: 24 Message-ID: References: Reply-To: avl@logic.at Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 1 Mar 2019 09:43:22 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="c144b748bf03aa5835b53744c000c08a"; logging-data="12445"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19JzDIbuJ2BbZqf65wlbMqZ" User-Agent: slrn/1.0.3 (Linux) Cancel-Lock: sha1:eqVWL00OUC6aRbVTYvjltqnEtJc= Xref: csiph.com comp.lang.java.programmer:38774 Daniele Futtorovic wrote: > On 2019-02-28 22:24, Marcel Mueller wrote: >> Am 28.02.19 um 20:10 schrieb Andreas Leitgeb: >>> My case can be better characterized in that the Closeable entity is >>> an attribute of a Context class, and a getter is called by "users" for >>> the ref of the entity.   Lifetime management of the entity is handled >>> by the Context.   "Users" (specific methods doing their parts of >>> the Context's whole task) really shouldn't close() it or they would >>> spoil it for later users. >> In this case do not expose close(). Expose an interface that only >> provides the methods relevant for the users. Indeed, that's what I thought of - only after posting ;-) > Or don't implement Closeable in the first place. Well, if that were an option, it would be pretty obvious :) (The real Entity implementation extends a given Closeable- implementing class) > Or just ignore the bloody warning and don't let your tools get in your way. That's an option I already mentioned in first post of thread.