unblock readers after consumeAll

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
Ludovic Orban 2021-02-08 12:07:37 +01:00
parent 9611a252a5
commit d297e9c473
5 changed files with 30 additions and 28 deletions

View File

@ -177,6 +177,10 @@ class AsyncContentProducer implements ContentProducer
_rawContent.failed(x);
_rawContent = null;
}
HttpInput.ErrorContent errorContent = new HttpInput.ErrorContent(x);
_transformedContent = errorContent;
_rawContent = errorContent;
}
@Override
@ -274,6 +278,13 @@ class AsyncContentProducer implements ContentProducer
{
// TODO does EOF need to be passed to the interceptors?
// In case the _rawContent was set by consumeAll(), check the httpChannel
// to see if it has a more precise error. Otherwise, the exact same
// special content will be returned by the httpChannel.
HttpInput.Content refreshedRawContent = produceRawContent();
if (refreshedRawContent != null)
_rawContent = refreshedRawContent;
_error = _rawContent.getError() != null;
if (LOG.isDebugEnabled())
LOG.debug("raw content is special (with error = {}), returning it {}", _error, this);

View File

@ -76,7 +76,9 @@ class BlockingContentProducer implements ContentProducer
@Override
public boolean consumeAll(Throwable x)
{
return _asyncContentProducer.consumeAll(x);
boolean eof = _asyncContentProducer.consumeAll(x);
_semaphore.release();
return eof;
}
@Override

View File

@ -135,7 +135,6 @@ public class HttpInput extends ServletInputStream implements Runnable
if (isFinished())
return !isError();
//TODO move to early EOF and notify blocking reader
return false;
}

View File

@ -1,19 +1,14 @@
//
// ========================================================================
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// ========================================================================
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.server;

View File

@ -1,19 +1,14 @@
//
// ========================================================================
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// ========================================================================
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.http.client;