Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken client tls negotiation #11999

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ default int skip(int length)
*/
default Chunk asReadOnly()
{
if (getByteBuffer().isReadOnly())
if (!getByteBuffer().hasRemaining() || getByteBuffer().isReadOnly())
return this;
if (canRetain())
return asChunk(getByteBuffer().asReadOnlyBuffer(), isLast(), this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public class QuicStreamEndPoint extends AbstractEndPoint
{
private static final Logger LOG = LoggerFactory.getLogger(QuicStreamEndPoint.class);
private static final ByteBuffer LAST_FLAG = ByteBuffer.allocate(0);
private static final ByteBuffer EMPTY_WRITABLE_BUFFER = ByteBuffer.allocate(0);

private final QuicSession session;
private final long streamId;
Expand Down Expand Up @@ -272,7 +271,7 @@ public boolean onReadable()
// Check if the stream was finished normally.
try
{
fill(EMPTY_WRITABLE_BUFFER);
fill(BufferUtil.EMPTY_BUFFER);
}
catch (EOFException x)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,20 @@
package org.eclipse.jetty.server;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLEngineResult;

import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.BufferUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class NegotiatingServerConnection extends AbstractConnection
{
private static final Logger LOG = LoggerFactory.getLogger(NegotiatingServerConnection.class);
private static final ByteBuffer EMPTY_WRITABLE_BUFFER = ByteBuffer.allocate(0);

public interface CipherDiscriminator
{
Expand Down Expand Up @@ -145,7 +144,7 @@ private int fill()
{
try
{
return getEndPoint().fill(EMPTY_WRITABLE_BUFFER);
return getEndPoint().fill(BufferUtil.EMPTY_BUFFER);
}
catch (IOException x)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public class BufferUtil
};

public static final byte[] EMPTY_BYTES = new byte[0];
public static final ByteBuffer EMPTY_BUFFER = ByteBuffer.wrap(EMPTY_BYTES).asReadOnlyBuffer();
public static final ByteBuffer EMPTY_BUFFER = ByteBuffer.wrap(EMPTY_BYTES);

/**
* Allocate ByteBuffer in flush mode.
Expand Down
Loading