Fix broken client tls negotiation (#11999)

#11965 make EMPTY_BUFFER not read-only anymore

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
Ludovic Orban 2024-07-10 16:52:51 +02:00 committed by GitHub
parent d8f2a8167a
commit 8f5207e6ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 5 additions and 7 deletions

View File

@ -1024,7 +1024,7 @@ public class Content
*/
default Chunk asReadOnly()
{
if (getByteBuffer().isReadOnly())
if (!getByteBuffer().hasRemaining() || getByteBuffer().isReadOnly())
return this;
if (canRetain())
return asChunk(getByteBuffer().asReadOnlyBuffer(), isLast(), this);

View File

@ -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;
@ -272,7 +271,7 @@ public class QuicStreamEndPoint extends AbstractEndPoint
// Check if the stream was finished normally.
try
{
fill(EMPTY_WRITABLE_BUFFER);
fill(BufferUtil.EMPTY_BUFFER);
}
catch (EOFException x)
{

View File

@ -14,7 +14,6 @@
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;
@ -22,13 +21,13 @@ 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
{
@ -145,7 +144,7 @@ public abstract class NegotiatingServerConnection extends AbstractConnection
{
try
{
return getEndPoint().fill(EMPTY_WRITABLE_BUFFER);
return getEndPoint().fill(BufferUtil.EMPTY_BUFFER);
}
catch (IOException x)
{

View File

@ -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.