View | Details | Raw Unified | Return to bug 57799
Collapse All | Expand All

(-)java/org/apache/coyote/http11/InternalInputBuffer.java (-1 / +1 lines)
Lines 76-82 Link Here
76
     * tested for == 0 or > 0.
76
     * tested for == 0 or > 0.
77
     */
77
     */
78
    @Override
78
    @Override
79
    public int available() {
79
    public int available(boolean read) {
80
        return 1;
80
        return 1;
81
    }
81
    }
82
82
(-)java/org/apache/coyote/http11/AbstractHttp11Processor.java (-1 / +1 lines)
Lines 873-879 Link Here
873
            break;
873
            break;
874
        }
874
        }
875
        case AVAILABLE: {
875
        case AVAILABLE: {
876
            request.setAvailable(inputBuffer.available());
876
            request.setAvailable(inputBuffer.available(param == Boolean.TRUE));
877
            break;
877
            break;
878
        }
878
        }
879
        case NB_WRITE_INTEREST: {
879
        case NB_WRITE_INTEREST: {
(-)java/org/apache/catalina/connector/InputBuffer.java (-1 / +1 lines)
Lines 241-247 Link Here
241
            available = cb.getLength();
241
            available = cb.getLength();
242
        }
242
        }
243
        if (available == 0) {
243
        if (available == 0) {
244
            coyoteRequest.action(ActionCode.AVAILABLE, null);
244
            coyoteRequest.action(ActionCode.AVAILABLE, Boolean.valueOf(coyoteRequest.getReadListener() != null));
245
            available = (coyoteRequest.getAvailable() > 0) ? 1 : 0;
245
            available = (coyoteRequest.getAvailable() > 0) ? 1 : 0;
246
        }
246
        }
247
        return available;
247
        return available;
(-)java/org/apache/tomcat/util/net/Nio2Channel.java (-1 / +21 lines)
Lines 26-31 Link Here
26
import java.util.concurrent.TimeUnit;
26
import java.util.concurrent.TimeUnit;
27
import java.util.concurrent.TimeoutException;
27
import java.util.concurrent.TimeoutException;
28
28
29
import org.apache.juli.logging.Log;
30
import org.apache.juli.logging.LogFactory;
29
import org.apache.tomcat.util.net.SecureNio2Channel.ApplicationBufferHandler;
31
import org.apache.tomcat.util.net.SecureNio2Channel.ApplicationBufferHandler;
30
32
31
/**
33
/**
Lines 35-40 Link Here
35
 */
37
 */
36
public class Nio2Channel implements AsynchronousByteChannel {
38
public class Nio2Channel implements AsynchronousByteChannel {
37
39
40
    private static final Log log = LogFactory.getLog(Nio2Channel.class);
38
    protected static ByteBuffer emptyBuf = ByteBuffer.allocate(0);
41
    protected static ByteBuffer emptyBuf = ByteBuffer.allocate(0);
39
42
40
    protected AsynchronousSocketChannel sc = null;
43
    protected AsynchronousSocketChannel sc = null;
Lines 128-136 Link Here
128
        return super.toString()+":"+this.sc.toString();
131
        return super.toString()+":"+this.sc.toString();
129
    }
132
    }
130
133
134
    private volatile Exception stack = null;
131
    @Override
135
    @Override
132
    public Future<Integer> read(ByteBuffer dst) {
136
    public Future<Integer> read(ByteBuffer dst) {
133
        return sc.read(dst);
137
        Exception previous = stack;
138
        try {
139
            throw new Exception(Thread.currentThread().getName());
140
        } catch (Exception e) {
141
            stack = e;
142
        }
143
        try {
144
            return sc.read(dst);
145
        } catch (java.nio.channels.ReadPendingException e) {
146
            log.error("Read pending exception, previous read stack was: ", previous);
147
            throw e;
148
        }
134
    }
149
    }
135
150
136
    @Override
151
    @Override
Lines 142-147 Link Here
142
    public <A> void read(ByteBuffer dst,
157
    public <A> void read(ByteBuffer dst,
143
            long timeout, TimeUnit unit, A attachment,
158
            long timeout, TimeUnit unit, A attachment,
144
            CompletionHandler<Integer, ? super A> handler) {
159
            CompletionHandler<Integer, ? super A> handler) {
160
        try {
161
            throw new Exception(Thread.currentThread().getName());
162
        } catch (Exception e) {
163
            stack = e;
164
        }
145
        sc.read(dst, timeout, unit, attachment, handler);
165
        sc.read(dst, timeout, unit, attachment, handler);
146
    }
166
    }
147
167
(-)java/org/apache/coyote/http11/AbstractInputBuffer.java (-11 / +13 lines)
Lines 326-332 Link Here
326
     * Available bytes in the buffers (note that due to encoding, this may not
326
     * Available bytes in the buffers (note that due to encoding, this may not
327
     * correspond).
327
     * correspond).
328
     */
328
     */
329
    public int available() {
329
    public int available(boolean read) {
330
        int available = lastValid - pos;
330
        int available = lastValid - pos;
331
        if ((available == 0) && (lastActiveFilter >= 0)) {
331
        if ((available == 0) && (lastActiveFilter >= 0)) {
332
            for (int i = 0; (available == 0) && (i <= lastActiveFilter); i++) {
332
            for (int i = 0; (available == 0) && (i <= lastActiveFilter); i++) {
Lines 337-353 Link Here
337
            return available;
337
            return available;
338
        }
338
        }
339
339
340
        try {
340
        if (read) {
341
            fill(false);
341
            try {
342
            available = lastValid - pos;
342
                fill(false);
343
        } catch (IOException ioe) {
343
                available = lastValid - pos;
344
            if (getLog().isDebugEnabled()) {
344
            } catch (IOException ioe) {
345
                getLog().debug(sm.getString("iib.available.readFail"), ioe);
345
                if (getLog().isDebugEnabled()) {
346
                    getLog().debug(sm.getString("iib.available.readFail"), ioe);
347
                }
348
                // Not ideal. This will indicate that data is available which should
349
                // trigger a read which in turn will trigger another IOException and
350
                // that one can be thrown.
351
                available = 1;
346
            }
352
            }
347
            // Not ideal. This will indicate that data is available which should
348
            // trigger a read which in turn will trigger another IOException and
349
            // that one can be thrown.
350
            available = 1;
351
        }
353
        }
352
        return available;
354
        return available;
353
    }
355
    }

Return to bug 57799