FileOutputStream.available() and pipe EOF
Hi list. My question relates to streams returned by java.lang.Process.getInputStream() On Linux calling available() after the other side of the pipe was closed will throw: java.io.IOException: Stream Closed This is very handy, because you can distinguish EOF and a pause in transmission. On Windows same Oracle JDK version 1.8.0_161 behaves in a traditional manner and available() returns 0 in both cases. Will this ever change?
Re: FileOutputStream.available() and pipe EOF
Hi Basin, or instead of relying on an undocumented behaviour, you can use any overloads of read(), if it returns -1, it's the ends of the stream. cheers, Rémi - Mail original - > De: "Basin Ilya" > À: "core-libs-dev" > Envoyé: Samedi 10 Février 2018 22:15:18 > Objet: FileOutputStream.available() and pipe EOF > Hi list. > > My question relates to streams returned by > java.lang.Process.getInputStream() > > On Linux calling available() after the other side of the pipe was closed > will throw: > > java.io.IOException: Stream Closed > > This is very handy, because you can distinguish EOF and a pause in > transmission. > > On Windows same Oracle JDK version 1.8.0_161 behaves in a traditional > manner and available() returns 0 in both cases. Will this ever change?
Re: FileOutputStream.available() and pipe EOF
Unfortunately, read() is 1) uninterruptilbe 2) Unlike sockets, close() or even Thread.stop() won't cancel a read pipe operation on Windows 11.02.2018 0:27, Remi Forax пишет: > Hi Basin, > or instead of relying on an undocumented behaviour, you can use any overloads > of read(), if it returns -1, it's the ends of the stream. > > cheers, > Rémi > > - Mail original - >> De: "Basin Ilya" >> À: "core-libs-dev" >> Envoyé: Samedi 10 Février 2018 22:15:18 >> Objet: FileOutputStream.available() and pipe EOF > >> Hi list. >> >> My question relates to streams returned by >> java.lang.Process.getInputStream() >> >> On Linux calling available() after the other side of the pipe was closed >> will throw: >> >> java.io.IOException: Stream Closed >> >> This is very handy, because you can distinguish EOF and a pause in >> transmission. >> >> On Windows same Oracle JDK version 1.8.0_161 behaves in a traditional >> manner and available() returns 0 in both cases. Will this ever change?
Re: RFR: jsr166 jdk integration 2018-02
Hans, thanks for another great lesson! On Fri, Feb 9, 2018 at 11:19 AM, Hans Boehm wrote: > > The downside of treating "this" specially is that it makes it even harder > to explain the other cases, e.g. when the object being finalized > prematurely was an explicit parameter, or perhaps even the result of a > factory method. > Java programmer intuition says the "this" object receiver is special. E.g. there's no way to explicitly null out "this" in a method body to be nice to the GC, as you can with a method argument. Think how crazy "this = null;" looks! But that's what the VM is doing on your behalf. Anyways, back in the real world this change got submitted with reachabilityFence.