public Stream getMainStreamSafe() throws BadDescriptorException { Stream stream = mainStream; if (stream == null) throw new BadDescriptorException(); return stream; }
public Stream getPipeStreamSafe() throws BadDescriptorException { Stream stream = pipeStream; if (stream == null) throw new BadDescriptorException(); return stream; }
public Stream getPipeStreamSafe() throws BadDescriptorException { Stream stream = pipeStream; if (stream == null) throw new BadDescriptorException(); return stream; }
public Stream getWriteStreamSafe() throws BadDescriptorException { Stream stream = pipeStream == null ? mainStream : pipeStream; if (stream == null) throw new BadDescriptorException(); return stream; }
public Stream getMainStreamSafe() throws BadDescriptorException { Stream stream = mainStream; if (stream == null) throw new BadDescriptorException(); return stream; }
public Stream getWriteStreamSafe() throws BadDescriptorException { Stream stream = pipeStream == null ? mainStream : pipeStream; if (stream == null) throw new BadDescriptorException(); return stream; }
/** * Check whether the isOpen returns true, raising a BadDescriptorException if * it returns false. * * @throws org.jruby.util.io.BadDescriptorException if isOpen returns false */ public void checkOpen() throws BadDescriptorException { if (!isOpen()) { throw new BadDescriptorException(); } }
/** * Check whether the isOpen returns true, raising a BadDescriptorException if * it returns false. * * @throws org.jruby.util.io.BadDescriptorException if isOpen returns false */ public void checkOpen() throws BadDescriptorException { if (!isOpen()) { throw new BadDescriptorException(); } }
/** * Check whether the isOpen returns true, raising a BadDescriptorException if * it returns false. * * @throws org.jruby.util.io.BadDescriptorException if isOpen returns false */ public void checkOpen() throws BadDescriptorException { if (!isOpen()) { throw new BadDescriptorException(); } }
/** * Check whether the isOpen returns true, raising a BadDescriptorException if * it returns false. * * @throws org.jruby.util.io.BadDescriptorException if isOpen returns false */ public void checkOpen() throws BadDescriptorException { if (!isOpen()) { throw new BadDescriptorException(); } }
void finish(boolean close) throws BadDescriptorException, IOException { synchronized (refCounter) { // if refcount is at or below zero, we're no longer valid if (refCounter.get() <= 0) { throw new BadDescriptorException(); } // if channel is already closed, we're no longer valid if (!channel.isOpen()) { throw new BadDescriptorException(); } // otherwise decrement and possibly close as normal if (close) { int count = refCounter.decrementAndGet(); if (DEBUG) LOG.info("Descriptor for fileno {} refs: {}", internalFileno, count); if (count <= 0) { // if we're the last referrer, close the channel try { channel.close(); } finally { unregisterDescriptor(internalFileno); } } } } }
void finish(boolean close) throws BadDescriptorException, IOException { synchronized (refCounter) { // if refcount is at or below zero, we're no longer valid if (refCounter.get() <= 0) { throw new BadDescriptorException(); } // if channel is already closed, we're no longer valid if (!channel.isOpen()) { throw new BadDescriptorException(); } // otherwise decrement and possibly close as normal int count = refCounter.decrementAndGet(); if (DEBUG) LOG.info("Descriptor for fileno {} refs: {}", internalFileno, count); if (count <= 0) { // if we're the last referrer, close the channel try { if (close) channel.close(); } finally { unregisterDescriptor(internalFileno); } } } }
void finish(boolean close) throws BadDescriptorException, IOException { synchronized (refCounter) { // if refcount is at or below zero, we're no longer valid if (refCounter.get() <= 0) { throw new BadDescriptorException(); } // if channel is already closed, we're no longer valid if (!channel.isOpen()) { throw new BadDescriptorException(); } // otherwise decrement and possibly close as normal if (close) { int count = refCounter.decrementAndGet(); if (DEBUG) LOG.info("Descriptor for fileno {} refs: {}", internalFileno, count); if (count <= 0) { // if we're the last referrer, close the channel try { channel.close(); } finally { unregisterDescriptor(internalFileno); } } } } }
/** * Perform a low-level read of the remaining number of bytes into the specified * byte buffer. The incoming bytes will be used to fill the remaining space in * the target byte buffer. This is equivalent to the read(2) POSIX function, * and like that function it ignores read and write buffers defined elsewhere. * * @param buffer the java.nio.ByteBuffer in which to put the incoming bytes * @return the number of bytes actually read * @throws java.io.IOException if there is an exception during IO * @throws org.jruby.util.io.BadDescriptorException if the associated * channel is already closed * @see java.nio.ByteBuffer */ public int read(ByteBuffer buffer) throws IOException, BadDescriptorException { checkOpen(); // TODO: It would be nice to throw a better error for this if (!isReadable()) { throw new BadDescriptorException(); } ReadableByteChannel readChannel = (ReadableByteChannel) channel; int bytesRead = 0; bytesRead = readChannel.read(buffer); return bytesRead; }
/** * Perform a low-level read of the remaining number of bytes into the specified * byte buffer. The incoming bytes will be used to fill the remaining space in * the target byte buffer. This is equivalent to the read(2) POSIX function, * and like that function it ignores read and write buffers defined elsewhere. * * @param buffer the java.nio.ByteBuffer in which to put the incoming bytes * @return the number of bytes actually read * @throws java.io.IOException if there is an exception during IO * @throws org.jruby.util.io.BadDescriptorException if the associated * channel is already closed * @see java.nio.ByteBuffer */ public int read(ByteBuffer buffer) throws IOException, BadDescriptorException { checkOpen(); // TODO: It would be nice to throw a better error for this if (!isReadable()) { throw new BadDescriptorException(); } ReadableByteChannel readChannel = (ReadableByteChannel) channel; int bytesRead = 0; bytesRead = readChannel.read(buffer); return bytesRead; }
/** * Perform a low-level read of the remaining number of bytes into the specified * byte buffer. The incoming bytes will be used to fill the remaining space in * the target byte buffer. This is equivalent to the read(2) POSIX function, * and like that function it ignores read and write buffers defined elsewhere. * * @param buffer the java.nio.ByteBuffer in which to put the incoming bytes * @return the number of bytes actually read * @throws java.io.IOException if there is an exception during IO * @throws org.jruby.util.io.BadDescriptorException if the associated * channel is already closed * @see java.nio.ByteBuffer */ public int read(ByteBuffer buffer) throws IOException, BadDescriptorException { checkOpen(); // TODO: It would be nice to throw a better error for this if (!isReadable()) { throw new BadDescriptorException(); } ReadableByteChannel readChannel = (ReadableByteChannel) channel; int bytesRead = 0; bytesRead = readChannel.read(buffer); return bytesRead; }
/** * Perform a low-level read of the remaining number of bytes into the specified * byte buffer. The incoming bytes will be used to fill the remaining space in * the target byte buffer. This is equivalent to the read(2) POSIX function, * and like that function it ignores read and write buffers defined elsewhere. * * @param buffer the java.nio.ByteBuffer in which to put the incoming bytes * @return the number of bytes actually read * @throws java.io.IOException if there is an exception during IO * @throws org.jruby.util.io.BadDescriptorException if the associated * channel is already closed * @see java.nio.ByteBuffer */ public int read(ByteBuffer buffer) throws IOException, BadDescriptorException { checkOpen(); // TODO: It would be nice to throw a better error for this if (!isReadable()) { throw new BadDescriptorException(); } ReadableByteChannel readChannel = (ReadableByteChannel) channel; int bytesRead = 0; bytesRead = readChannel.read(buffer); return bytesRead; }
/** * Write the bytes in the specified byte list to the associated channel. * * @param buffer the byte list containing the bytes to be written * @return the number of bytes actually written * @throws java.io.IOException if there is an exception during IO * @throws org.jruby.util.io.BadDescriptorException if the associated * channel is already closed */ public int internalWrite(ByteBuffer buffer) throws IOException, BadDescriptorException { checkOpen(); // TODO: It would be nice to throw a better error for this if (!isWritable()) { throw new BadDescriptorException(); } WritableByteChannel writeChannel = (WritableByteChannel)channel; // if appendable, we always seek to the end before writing if (isSeekable() && originalModes.isAppendable()) { // if already in append mode, we don't do our own seeking if (!isInAppendMode) { FileChannel fileChannel = (FileChannel)channel; fileChannel.position(fileChannel.size()); } } return writeChannel.write(buffer); }
/** * Write the bytes in the specified byte list to the associated channel. * * @param buffer the byte list containing the bytes to be written * @return the number of bytes actually written * @throws java.io.IOException if there is an exception during IO * @throws org.jruby.util.io.BadDescriptorException if the associated * channel is already closed */ public int internalWrite(ByteBuffer buffer) throws IOException, BadDescriptorException { checkOpen(); // TODO: It would be nice to throw a better error for this if (!isWritable()) { throw new BadDescriptorException(); } WritableByteChannel writeChannel = (WritableByteChannel)channel; // if appendable, we always seek to the end before writing if (isSeekable() && originalModes.isAppendable()) { // if already in append mode, we don't do our own seeking if (!isInAppendMode) { SeekableByteChannel fileChannel = (SeekableByteChannel) channel; fileChannel.position(fileChannel.size()); } } return writeChannel.write(buffer); }
/** * Write the bytes in the specified byte list to the associated channel. * * @param buffer the byte list containing the bytes to be written * @return the number of bytes actually written * @throws java.io.IOException if there is an exception during IO * @throws org.jruby.util.io.BadDescriptorException if the associated * channel is already closed */ public int internalWrite(ByteBuffer buffer) throws IOException, BadDescriptorException { checkOpen(); // TODO: It would be nice to throw a better error for this if (!isWritable()) { throw new BadDescriptorException(); } WritableByteChannel writeChannel = (WritableByteChannel)channel; // if appendable, we always seek to the end before writing if (isSeekable() && originalModes.isAppendable()) { // if already in append mode, we don't do our own seeking if (!isInAppendMode) { SeekableByteChannel fileChannel = (SeekableByteChannel) channel; fileChannel.position(fileChannel.size()); } } return writeChannel.write(buffer); }