Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #38764
| X-Received | by 2002:a05:620a:13a7:: with SMTP id m7mr1076146qki.0.1551390274442; Thu, 28 Feb 2019 13:44:34 -0800 (PST) |
|---|---|
| X-Received | by 2002:a5b:10c:: with SMTP id 12mr1517147ybx.323.1551390274264; Thu, 28 Feb 2019 13:44:34 -0800 (PST) |
| Path | csiph.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!m21no188835qta.0!news-out.google.com!o7ni57qta.1!nntp.google.com!m21no188832qta.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.java.programmer |
| Date | Thu, 28 Feb 2019 13:44:33 -0800 (PST) |
| In-Reply-To | <slrnq7dcgo.cfl.avl@logic.at> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=50.78.95.177; posting-account=2czF5goAAAD4GBMPIGV4KcD2K4PhoB_H |
| NNTP-Posting-Host | 50.78.95.177 |
| References | <slrnq7dcgo.cfl.avl@logic.at> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <bdc2e9fe-e8f3-4485-92d6-a34eee265556@googlegroups.com> (permalink) |
| Subject | Re: it's Closeable, but I don't want to close() it yet. |
| From | Eric Douglas <e.d.programmer@gmail.com> |
| Injection-Date | Thu, 28 Feb 2019 21:44:34 +0000 |
| Content-Type | text/plain; charset="UTF-8" |
| Lines | 33 |
| Xref | csiph.com comp.lang.java.programmer:38764 |
Show key headers only | View raw
On Wednesday, February 27, 2019 at 10:52:01 AM UTC-5, Andreas Leitgeb wrote:
> In my application there exists an entity that is Closeable.
> It is kept in some class, and other parts of my application
> request a ref to the entity and do actions on it, then drop
> their ref, leaving the entity intact.
>
> Everything runs fine, except eclipse warns me about spots
> where the entity is requested, used, and then dropped.
> Eclipse thinks it might need to be close()d.
>
> Apart from ignoring the warning per eclipse settings or
> adding @SuppressWarnings, is there maybe a way to tell
> the compiler that a certain ref is not meant to be close()d?
> Letting it know that - despite the entity's ultimate fate of
> being eventually closed - this is not yet the time&place for it?
One last fun scenario. ImageIO.read actually reads an InputStream and closes it. So I do this and it works fine, but Eclipse throws a potential resource leak warning on mciis:
try {
final MemoryCacheImageInputStream mciis = new MemoryCacheImageInputStream(is);
myBufferedImage = ImageIO.read(mciis);
} catch (final IOException e) {
return null;
}
Passing in ByteArrayInputStream is containing the bytes of a proper image file, the above code does not hit the exception, and works fine despite the warning. Now if you attempt to close it to avoid that warning:
try (final MemoryCacheImageInputStream mciis = new MemoryCacheImageInputStream(is)) {
myBufferedImage = ImageIO.read(mciis);
} catch (final IOException e) {
return null;
}
This does hit the exception.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
it's Closeable, but I don't want to close() it yet. Andreas Leitgeb <avl@logic.at> - 2019-02-27 15:51 +0000
Re: it's Closeable, but I don't want to close() it yet. Eric Douglas <e.d.programmer@gmail.com> - 2019-02-27 08:48 -0800
Re: it's Closeable, but I don't want to close() it yet. Andreas Leitgeb <avl@logic.at> - 2019-02-27 19:03 +0000
Re: it's Closeable, but I don't want to close() it yet. Eric Douglas <e.d.programmer@gmail.com> - 2019-02-27 11:09 -0800
Re: it's Closeable, but I don't want to close() it yet. Andreas Leitgeb <avl@logic.at> - 2019-02-28 12:20 +0000
Re: it's Closeable, but I don't want to close() it yet. Eric Douglas <e.d.programmer@gmail.com> - 2019-02-28 06:19 -0800
Re: it's Closeable, but I don't want to close() it yet. Eric Douglas <e.d.programmer@gmail.com> - 2019-02-28 06:52 -0800
Re: it's Closeable, but I don't want to close() it yet. bursejan@gmail.com - 2019-02-28 08:24 -0800
Re: it's Closeable, but I don't want to close() it yet. bursejan@gmail.com - 2019-02-28 08:34 -0800
Re: it's Closeable, but I don't want to close() it yet. Eric Douglas <e.d.programmer@gmail.com> - 2019-02-28 09:00 -0800
Re: it's Closeable, but I don't want to close() it yet. bursejan@gmail.com - 2019-02-28 11:12 -0800
Re: it's Closeable, but I don't want to close() it yet. Eric Douglas <e.d.programmer@gmail.com> - 2019-02-28 11:26 -0800
Re: it's Closeable, but I don't want to close() it yet. bursejan@gmail.com - 2019-02-28 11:33 -0800
Re: it's Closeable, but I don't want to close() it yet. Eric Douglas <e.d.programmer@gmail.com> - 2019-02-28 11:37 -0800
Re: it's Closeable, but I don't want to close() it yet. bursejan@gmail.com - 2019-02-28 11:41 -0800
Re: it's Closeable, but I don't want to close() it yet. Eric Douglas <e.d.programmer@gmail.com> - 2019-02-28 11:48 -0800
Re: it's Closeable, but I don't want to close() it yet. Eric Douglas <e.d.programmer@gmail.com> - 2019-02-28 12:51 -0800
Re: it's Closeable, but I don't want to close() it yet. Andreas Leitgeb <avl@logic.at> - 2019-03-01 08:47 +0000
Re: it's Closeable, but I don't want to close() it yet. Andreas Leitgeb <avl@logic.at> - 2019-03-01 09:31 +0000
Re: it's Closeable, but I don't want to close() it yet. Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2019-03-03 02:01 +0100
Re: it's Closeable, but I don't want to close() it yet. Andreas Leitgeb <avl@logic.at> - 2019-03-04 09:38 +0000
Re: it's Closeable, but I don't want to close() it yet. Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2019-03-04 12:26 +0100
Re: it's Closeable, but I don't want to close() it yet. Andreas Leitgeb <avl@logic.at> - 2019-03-05 14:34 +0000
Re: it's Closeable, but I don't want to close() it yet. Eric Douglas <e.d.programmer@gmail.com> - 2019-03-05 07:34 -0800
Re: it's Closeable, but I don't want to close() it yet. Arne Vajhøj <arne@vajhoej.dk> - 2019-03-04 13:59 -0500
Re: it's Closeable, but I don't want to close() it yet. Marcel Mueller <news.5.maazl@spamgourmet.org> - 2019-02-28 08:30 +0100
Re: it's Closeable, but I don't want to close() it yet. Andreas Leitgeb <avl@logic.at> - 2019-02-28 19:10 +0000
Re: it's Closeable, but I don't want to close() it yet. Eric Douglas <e.d.programmer@gmail.com> - 2019-02-28 11:34 -0800
Re: it's Closeable, but I don't want to close() it yet. Marcel Mueller <news.5.maazl@spamgourmet.org> - 2019-02-28 22:24 +0100
Re: it's Closeable, but I don't want to close() it yet. Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2019-02-28 23:25 +0100
Re: it's Closeable, but I don't want to close() it yet. Andreas Leitgeb <avl@logic.at> - 2019-03-01 09:43 +0000
Re: it's Closeable, but I don't want to close() it yet. Eric Douglas <e.d.programmer@gmail.com> - 2019-02-28 12:11 -0800
Re: it's Closeable, but I don't want to close() it yet. bursejan@gmail.com - 2019-02-28 13:49 -0800
Re: it's Closeable, but I don't want to close() it yet. bursejan@gmail.com - 2019-02-28 13:52 -0800
Re: it's Closeable, but I don't want to close() it yet. Eric Douglas <e.d.programmer@gmail.com> - 2019-02-28 13:59 -0800
Re: it's Closeable, but I don't want to close() it yet. bursejan@gmail.com - 2019-02-28 16:17 -0800
Re: it's Closeable, but I don't want to close() it yet. Eric Douglas <e.d.programmer@gmail.com> - 2019-02-28 12:26 -0800
Re: it's Closeable, but I don't want to close() it yet. Eric Douglas <e.d.programmer@gmail.com> - 2019-02-28 13:44 -0800
Re: it's Closeable, but I don't want to close() it yet. bursejan@gmail.com - 2019-03-01 07:40 -0800
Re: it's Closeable, but I don't want to close() it yet. bursejan@gmail.com - 2019-03-01 08:34 -0800
Re: it's Closeable, but I don't want to close() it yet. Eric Douglas <e.d.programmer@gmail.com> - 2019-03-11 06:27 -0700
Re: it's Closeable, but I don't want to close() it yet. Eric Douglas <e.d.programmer@gmail.com> - 2019-03-11 07:24 -0700
csiph-web