Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Daniele Futtorovic Newsgroups: comp.lang.java.programmer Subject: Re: it's Closeable, but I don't want to close() it yet. Date: Thu, 28 Feb 2019 23:25:49 +0100 Organization: A noiseless patient Spider Lines: 19 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 28 Feb 2019 22:25:56 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="1b056db60caa3cc160f6cdeeaadeccd4"; logging-data="23296"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX183qLBxLBjK00NYKjaIIrCJ" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 Cancel-Lock: sha1:hg9Ek+Ng1xpkeYCN2YZ1hi65QnI= In-Reply-To: X-Antivirus-Status: Clean Content-Language: en-US X-Antivirus: AVG (VPS 190228-6, 02/28/2019), Outbound message Xref: csiph.com comp.lang.java.programmer:38769 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. Or don't implement Closeable in the first place. Or just ignore the bloody warning and don't let your tools get in your way. -- DF.