- if (_contentState != STREAM)
- throw new IllegalStateException("state=" + _contentState);
- _contentState = ASYNC;
- _listener = readListener;
- _notReady = true;
+ readListener = Objects.requireNonNull(readListener);
+ boolean content;
+ synchronized (lock())
+ {
+ if (_contentState != STREAM)
+ throw new IllegalStateException("state=" + _contentState);
+ _contentState = ASYNC;
+ _listener = readListener;
+ _notReady = true;
+
+ content = getNextContent()!=null || isEOF();
+
+ }
+ if (content)
+ _channelState.onReadPossible();
+ else
+ unready();
+ }
+ catch(IOException e)
+ {
+ throw new RuntimeIOException(e);