Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #38741

Re: it's Closeable, but I don't want to close() it yet.

Path csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From Andreas Leitgeb <avl@logic.at>
Newsgroups comp.lang.java.programmer
Subject Re: it's Closeable, but I don't want to close() it yet.
Date Wed, 27 Feb 2019 19:03:26 -0000 (UTC)
Organization A noiseless patient Spider
Lines 34
Message-ID <slrnq7dnnu.cfl.avl@logic.at> (permalink)
References <slrnq7dcgo.cfl.avl@logic.at> <709a1f3b-fc99-4bd0-a8b8-866092bb7ae9@googlegroups.com>
Reply-To avl@logic.at
Injection-Date Wed, 27 Feb 2019 19:03:26 -0000 (UTC)
Injection-Info reader02.eternal-september.org; posting-host="bb077191349627e6d7efbb06e52b68a2"; logging-data="5316"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/idoWQdflfKBxjF1uBkIMr"
User-Agent slrn/1.0.3 (Linux)
Cancel-Lock sha1:qLOR2w7CgQTHDPPZRa572c6UNGU=
Xref csiph.com comp.lang.java.programmer:38741

Show key headers only | View raw


Eric Douglas <e.d.programmer@gmail.com> wrote:
> 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?
>
> You probably don't want to ignore the warning type entirely.  It sounds
> like if it's getting used in one method and you'll guarantee it gets
> closed elsewhere, you'll just want to add a SuppressWarnings to that
> method.

In the meantime, I could think of another solution:
- create an interface that only offers those methods of the entity
    that are really needed for its "use", e.g.   EntityUse
- let the entity retriever method return the entity with a
    static type EntityUse
- Then the "use"-part isn't aware of the entity's Closeability,
    and as an extra bonus, calling other methods is at least
    hidden behind the threshold of an explicit cast..

PS: I just added the @SuppressWarnings, but I feel better now
  knowing there would be also a clean "OO"-solution.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

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