Skip to content

Commit

Permalink
#7281 handle comments
Browse files Browse the repository at this point in the history
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
  • Loading branch information
lorban committed Jan 10, 2022
1 parent f0491d8 commit 8355849
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -324,33 +324,35 @@ private HttpInput.Content nextTransformedContent()

while (true)
{
if (_transformedContent != null && (_transformedContent.isSpecial() || !_transformedContent.isEmpty()))
if (_transformedContent != null)
{
if (_transformedContent.isSpecial() && !_error)
if (_transformedContent.isSpecial() || !_transformedContent.isEmpty())
{
// 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; do not do that
// if the _error flag was set, meaning the current error is definitive.
HttpInput.Content refreshedRawContent = produceRawContent();
if (refreshedRawContent != null)
_rawContent = _transformedContent = refreshedRawContent;
_error = _rawContent.getError() != null;
if (_transformedContent.isSpecial() && !_error)
{
// 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; do not do that
// if the _error flag was set, meaning the current error is definitive.
HttpInput.Content refreshedRawContent = produceRawContent();
if (refreshedRawContent != null)
_rawContent = _transformedContent = refreshedRawContent;
_error = _rawContent.getError() != null;
if (LOG.isDebugEnabled())
LOG.debug("refreshed raw content: {} {}", _rawContent, this);
}

if (LOG.isDebugEnabled())
LOG.debug("refreshed raw content: {} {}", _rawContent, this);
LOG.debug("transformed content not yet depleted, returning it {}", this);
return _transformedContent;
}
else
{
if (LOG.isDebugEnabled())
LOG.debug("current transformed content depleted {}", this);
_transformedContent.succeeded();
_transformedContent = null;
}

if (LOG.isDebugEnabled())
LOG.debug("transformed content not yet depleted, returning it {}", this);
return _transformedContent;
}

if (_transformedContent != null && _transformedContent.isEmpty() && !_transformedContent.isSpecial())
{
if (LOG.isDebugEnabled())
LOG.debug("current transformed content depleted {}", this);
_transformedContent.succeeded();
_transformedContent = null;
}

if (_rawContent == null)
Expand Down Expand Up @@ -390,7 +392,7 @@ private void transformRawContent()
return;
}

// If the interceptor generated a null content, recycle the raw content now if its empty.
// If the interceptor generated a null content, recycle the raw content now if it is empty.
if (_transformedContent == null && _rawContent.isEmpty() && !_rawContent.isSpecial())
{
if (LOG.isDebugEnabled())
Expand All @@ -400,14 +402,13 @@ private void transformRawContent()
return;
}

// If the interceptor returned the raw content, recycle the raw content now if its empty.
// If the interceptor returned the raw content, recycle the raw content now if it is empty.
if (_transformedContent == _rawContent && _rawContent.isEmpty() && !_rawContent.isSpecial())
{
if (LOG.isDebugEnabled())
LOG.debug("interceptor returned the raw content, recycle the empty raw content now {}", this);
_rawContent.succeeded();
_rawContent = _transformedContent = null;
return;
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public String toString()
* When {@link Content} instances are generated, they are passed to the registered interceptor (if any)
* that is then responsible for providing the actual content that is consumed by {@link #read(byte[], int, int)} and its
* sibling methods.</p>
* <p>A minimal implementation could be as simple as:
* A minimal implementation could be as simple as:
* <pre>
* public HttpInput.Content readFrom(HttpInput.Content content)
* {
Expand Down Expand Up @@ -453,11 +453,11 @@ public String toString()
* occur only after the contained byte buffer is empty (see above) or at any time if the returned content was special.</li>
* <li>Once {@link #readFrom(Content)} returned a special content, subsequent calls to {@link #readFrom(Content)} must
* always return the same special content.</li>
* <li>When {@link #readFrom(Content)} gets passed a non-special content, it must either return the content it was
* passed or fully consume the contained byte buffer.</li>
* <li>Implementations implementing both this interface and {@link Destroyable} will have their
* {@link Destroyable#destroy()} method called when {@link #recycle()} is called.</li>
* </ul>
* </p>
* <p></p>
* @see org.eclipse.jetty.server.handler.gzip.GzipHttpInputInterceptor
*/
public interface Interceptor
Expand Down

0 comments on commit 8355849

Please sign in to comment.