application/org.openjdk.jmc.rjmx.services.jfr/src/main/java/org/openjdk/jmc/rjmx/services/jfr/internal/JfrRecordingInputStreamV1.java [79:161]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
			boolean removeOnClose) {
		this(helper, recording, null, null, removeOnClose);
	}

	@Override
	public synchronized int read() throws IOException {
		if (pos >= buf.length) {
			if (closed || endOfStream) {
				return -1;
			}
			fill();
			if (endOfStream) {
				return -1;
			}
		}
		return buf[pos++] & 0xff;
	}

	private void fill() throws IOException {
		if (UNKNOWN_STREAM.equals(streamIdentifier)) {
			readStreamIdentifier();
		}
		buf = readStream(streamIdentifier);
		if (buf != null) {
			count += buf.length;
			pos = 0;
		} else {
			pos = 0;
			count = 0;
			buf = new byte[0];
			endOfStream = true;
		}
	}

	private void readStreamIdentifier() throws IOException {
		if (startTime == null) {
			streamIdentifier = openStream(recording);
		} else {
			streamIdentifier = openStream(recording, startTime, endTime);
		}
	}

	private void ensureOpen() throws IOException {
		if (closed) {
			throw new IOException("Stream closed"); //$NON-NLS-1$
		}
	}

	@Override
	public synchronized int available() throws IOException {
		ensureOpen();
		return count - pos;
	}

	@Override
	public void close() throws IOException {
		if (closed == true) {
			return;
		}
		closed = true;
		if (!UNKNOWN_STREAM.equals(streamIdentifier)) {
			closeStream(streamIdentifier);
		}
		if (removeOnClose) {
			try {
				helper.closeRecording(recording);
			} catch (FlightRecorderException e) {
				IOException ioe = new IOException(e.getMessage());
				ioe.initCause(e);
				throw ioe;
			}
		}
	}

	private void closeStream(Long streamIdentifier) throws IOException {
		invokeOperation(CLOSE_STREAM, streamIdentifier);
	}

	private byte[] readStream(Long streamIdentifier) throws IOException {
		return (byte[]) invokeOperation(READ_STREAM, streamIdentifier);
	}

	private Long openStream(IRecordingDescriptor descriptor) throws IOException {
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



application/org.openjdk.jmc.rjmx.services.jfr/src/main/java/org/openjdk/jmc/rjmx/services/jfr/internal/JfrRecordingInputStreamV2.java [84:166]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
			boolean removeOnClose) {
		this(helper, recording, null, null, removeOnClose);
	}

	@Override
	public synchronized int read() throws IOException {
		if (pos >= buf.length) {
			if (closed || endOfStream) {
				return -1;
			}
			fill();
			if (endOfStream) {
				return -1;
			}
		}
		return buf[pos++] & 0xff;
	}

	private void fill() throws IOException {
		if (UNKNOWN_STREAM.equals(streamIdentifier)) {
			readStreamIdentifier();
		}
		buf = readStream(streamIdentifier);
		if (buf != null) {
			count += buf.length;
			pos = 0;
		} else {
			pos = 0;
			count = 0;
			buf = new byte[0];
			endOfStream = true;
		}
	}

	private void readStreamIdentifier() throws IOException {
		if (startTime == null) {
			streamIdentifier = openStream(recording);
		} else {
			streamIdentifier = openStream(recording, startTime, endTime);
		}
	}

	private void ensureOpen() throws IOException {
		if (closed) {
			throw new IOException("Stream closed"); //$NON-NLS-1$
		}
	}

	@Override
	public synchronized int available() throws IOException {
		ensureOpen();
		return count - pos;
	}

	@Override
	public void close() throws IOException {
		if (closed == true) {
			return;
		}
		closed = true;
		if (!UNKNOWN_STREAM.equals(streamIdentifier)) {
			closeStream(streamIdentifier);
		}
		if (removeOnClose) {
			try {
				helper.closeRecording(recording);
			} catch (FlightRecorderException e) {
				IOException ioe = new IOException(e.getMessage());
				ioe.initCause(e);
				throw ioe;
			}
		}
	}

	private void closeStream(Long streamIdentifier) throws IOException {
		invokeOperation(CLOSE_STREAM, streamIdentifier);
	}

	private byte[] readStream(Long streamIdentifier) throws IOException {
		return (byte[]) invokeOperation(READ_STREAM, streamIdentifier);
	}

	private Long openStream(IRecordingDescriptor descriptor) throws IOException {
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



