Issue #7286 - fix potential issue with websocket write timeout
Let websocket-core handle any idleTimeout & writeTimeouts instead of bad attempt to do it in Jetty/Javax API layers. Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
a3c2055e10
commit
eaeb64f3b1
|
@ -17,7 +17,6 @@ import java.io.IOException;
|
|||
import java.io.OutputStream;
|
||||
import java.io.Writer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import jakarta.websocket.EncodeException;
|
||||
import jakarta.websocket.RemoteEndpoint;
|
||||
|
@ -64,7 +63,7 @@ public class JakartaWebSocketBasicRemote extends JakartaWebSocketRemoteEndpoint
|
|||
|
||||
FutureCallback b = new FutureCallback();
|
||||
sendFrame(new Frame(OpCode.BINARY).setPayload(data), b, false);
|
||||
b.block(getBlockingTimeout(), TimeUnit.MILLISECONDS);
|
||||
b.block();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,7 +95,7 @@ public class JakartaWebSocketBasicRemote extends JakartaWebSocketRemoteEndpoint
|
|||
frame.setFin(isLast);
|
||||
FutureCallback b = new FutureCallback();
|
||||
sendFrame(frame, b, false);
|
||||
b.block(getBlockingTimeout(), TimeUnit.MILLISECONDS);
|
||||
b.block();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -104,7 +103,7 @@ public class JakartaWebSocketBasicRemote extends JakartaWebSocketRemoteEndpoint
|
|||
{
|
||||
FutureCallback b = new FutureCallback();
|
||||
super.sendObject(data, b);
|
||||
b.block(getBlockingTimeout(), TimeUnit.MILLISECONDS);
|
||||
b.block();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,7 +117,7 @@ public class JakartaWebSocketBasicRemote extends JakartaWebSocketRemoteEndpoint
|
|||
|
||||
FutureCallback b = new FutureCallback();
|
||||
sendFrame(new Frame(OpCode.TEXT).setPayload(text), b, false);
|
||||
b.block(getBlockingTimeout(), TimeUnit.MILLISECONDS);
|
||||
b.block();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -150,12 +149,6 @@ public class JakartaWebSocketBasicRemote extends JakartaWebSocketRemoteEndpoint
|
|||
frame.setFin(isLast);
|
||||
FutureCallback b = new FutureCallback();
|
||||
sendFrame(frame, b, false);
|
||||
b.block(getBlockingTimeout(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
private long getBlockingTimeout()
|
||||
{
|
||||
long idleTimeout = getIdleTimeout();
|
||||
return (idleTimeout > 0) ? idleTimeout + 1000 : idleTimeout;
|
||||
b.block();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ package org.eclipse.jetty.ee9.websocket.jakarta.common;
|
|||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import jakarta.websocket.EncodeException;
|
||||
import jakarta.websocket.Encoder;
|
||||
|
@ -63,7 +62,7 @@ public class JakartaWebSocketRemoteEndpoint implements jakarta.websocket.RemoteE
|
|||
{
|
||||
FutureCallback b = new FutureCallback();
|
||||
coreSession.flush(b);
|
||||
b.block(getBlockingTimeout(), TimeUnit.MILLISECONDS);
|
||||
b.block();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -225,7 +224,7 @@ public class JakartaWebSocketRemoteEndpoint implements jakarta.websocket.RemoteE
|
|||
|
||||
FutureCallback b = new FutureCallback();
|
||||
sendFrame(new Frame(OpCode.PING).setPayload(data), b, batch);
|
||||
b.block(getBlockingTimeout(), TimeUnit.MILLISECONDS);
|
||||
b.block();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -236,7 +235,7 @@ public class JakartaWebSocketRemoteEndpoint implements jakarta.websocket.RemoteE
|
|||
|
||||
FutureCallback b = new FutureCallback();
|
||||
sendFrame(new Frame(OpCode.PONG).setPayload(data), b, batch);
|
||||
b.block(getBlockingTimeout(), TimeUnit.MILLISECONDS);
|
||||
b.block();
|
||||
}
|
||||
|
||||
protected void assertMessageNotNull(Object data)
|
||||
|
@ -254,10 +253,4 @@ public class JakartaWebSocketRemoteEndpoint implements jakarta.websocket.RemoteE
|
|||
throw new IllegalArgumentException("SendHandler cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
private long getBlockingTimeout()
|
||||
{
|
||||
long idleTimeout = getIdleTimeout();
|
||||
return (idleTimeout > 0) ? idleTimeout + 1000 : idleTimeout;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.io.IOException;
|
|||
import java.net.SocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.ee9.websocket.api.BatchMode;
|
||||
import org.eclipse.jetty.ee9.websocket.api.WriteCallback;
|
||||
|
@ -79,7 +78,7 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.ee9.webso
|
|||
{
|
||||
FutureCallback b = new FutureCallback();
|
||||
sendPartialBytes(fragment, isLast, b);
|
||||
b.block(getBlockingTimeout(), TimeUnit.MILLISECONDS);
|
||||
b.block();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -121,7 +120,7 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.ee9.webso
|
|||
{
|
||||
FutureCallback b = new FutureCallback();
|
||||
sendPartialText(fragment, isLast, b);
|
||||
b.block(getBlockingTimeout(), TimeUnit.MILLISECONDS);
|
||||
b.block();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -188,7 +187,7 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.ee9.webso
|
|||
{
|
||||
FutureCallback b = new FutureCallback();
|
||||
coreSession.sendFrame(frame, b, false);
|
||||
b.block(getBlockingTimeout(), TimeUnit.MILLISECONDS);
|
||||
b.block();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -231,12 +230,6 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.ee9.webso
|
|||
{
|
||||
FutureCallback b = new FutureCallback();
|
||||
coreSession.flush(b);
|
||||
b.block(getBlockingTimeout(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
private long getBlockingTimeout()
|
||||
{
|
||||
long idleTimeout = coreSession.getIdleTimeout().toMillis();
|
||||
return (idleTimeout > 0) ? idleTimeout + 1000 : idleTimeout;
|
||||
b.block();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue