Skip to content

Commit b267345

Browse files
committed
Issue #12023 - Remove WriteFlusher.Listener.
WriteFlusher.Listener functionality was removed, and the class deprecated in 12.0.10 as part of the work for #9778 and #11839. Signed-off-by: Simone Bordet <[email protected]>
1 parent a0d8f07 commit b267345

File tree

4 files changed

+0
-113
lines changed
  • jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io
  • jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet
  • jetty-ee11/jetty-ee11-servlet/src/main/java/org/eclipse/jetty/ee11/servlet
  • jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested

4 files changed

+0
-113
lines changed

jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java

-33
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,6 @@ protected ByteBuffer[] flush(SocketAddress address, ByteBuffer[] buffers) throws
426426
if (LOG.isDebugEnabled())
427427
LOG.debug("Flushed={} written={} remaining={} {}", flushed, written, after, this);
428428

429-
if (written > 0)
430-
{
431-
Connection connection = _endPoint.getConnection();
432-
if (connection instanceof Listener listener)
433-
listener.onFlushed(written);
434-
}
435-
436429
if (flushed)
437430
return null;
438431

@@ -577,30 +570,4 @@ public String toString()
577570
State s = _state.get();
578571
return String.format("WriteFlusher@%x{%s}->%s", hashCode(), s, s instanceof PendingState ? ((PendingState)s)._callback : null);
579572
}
580-
581-
/**
582-
* <p>A listener of {@link WriteFlusher} events.
583-
* If implemented by a Connection class, the {@link #onFlushed(long)} event will be delivered to it.</p>
584-
*
585-
* @deprecated functionality removed, no replacement
586-
*/
587-
@Deprecated(since = "12.0.10", forRemoval = true)
588-
public interface Listener
589-
{
590-
/**
591-
* <p>Invoked when a {@link WriteFlusher} flushed bytes in a non-blocking way,
592-
* as part of a - possibly larger - write.</p>
593-
* <p>This method may be invoked multiple times, for example when writing a large
594-
* buffer: a first flush of bytes, then the connection became TCP congested, and
595-
* a subsequent flush of bytes when the connection became writable again.</p>
596-
* <p>This method is never invoked concurrently, but may be invoked by different
597-
* threads, so implementations may not rely on thread-local variables.</p>
598-
* <p>Implementations may throw an {@link IOException} to signal that the write
599-
* should fail, for example if the implementation enforces a minimum data rate.</p>
600-
*
601-
* @param bytes the number of bytes flushed
602-
* @throws IOException if the write should fail
603-
*/
604-
void onFlushed(long bytes) throws IOException;
605-
}
606573
}

jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/HttpOutput.java

-25
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.nio.charset.CoderResult;
2525
import java.nio.charset.CodingErrorAction;
2626
import java.util.concurrent.CancellationException;
27-
import java.util.concurrent.TimeUnit;
2827

2928
import jakarta.servlet.RequestDispatcher;
3029
import jakarta.servlet.ServletOutputStream;
@@ -1244,30 +1243,6 @@ public void setBufferSize(int size)
12441243
_commitSize = size;
12451244
}
12461245

1247-
/**
1248-
* <p>Invoked when bytes have been flushed to the network.</p>
1249-
*
1250-
* @param bytes the number of bytes flushed
1251-
* @throws IOException if the minimum data rate, when set, is not respected
1252-
* @see org.eclipse.jetty.io.WriteFlusher.Listener
1253-
*/
1254-
public void onFlushed(long bytes) throws IOException
1255-
{
1256-
if (_firstByteNanoTime == -1 || _firstByteNanoTime == Long.MAX_VALUE)
1257-
return;
1258-
long minDataRate = _servletChannel.getConnectionMetaData().getHttpConfiguration().getMinResponseDataRate();
1259-
_flushed += bytes;
1260-
long minFlushed = minDataRate * NanoTime.millisSince(_firstByteNanoTime) / TimeUnit.SECONDS.toMillis(1);
1261-
if (LOG.isDebugEnabled())
1262-
LOG.debug("Flushed bytes min/actual {}/{}", minFlushed, _flushed);
1263-
if (_flushed < minFlushed)
1264-
{
1265-
IOException ioe = new IOException(String.format("Response content data rate < %d B/s", minDataRate));
1266-
_servletChannel.abort(ioe);
1267-
throw ioe;
1268-
}
1269-
}
1270-
12711246
public void recycle()
12721247
{
12731248
try (AutoLock ignored = _channelState.lock())

jetty-ee11/jetty-ee11-servlet/src/main/java/org/eclipse/jetty/ee11/servlet/HttpOutput.java

-25
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.nio.charset.CoderResult;
2525
import java.nio.charset.CodingErrorAction;
2626
import java.util.concurrent.CancellationException;
27-
import java.util.concurrent.TimeUnit;
2827

2928
import jakarta.servlet.RequestDispatcher;
3029
import jakarta.servlet.ServletOutputStream;
@@ -1246,30 +1245,6 @@ public void setBufferSize(int size)
12461245
_commitSize = size;
12471246
}
12481247

1249-
/**
1250-
* <p>Invoked when bytes have been flushed to the network.</p>
1251-
*
1252-
* @param bytes the number of bytes flushed
1253-
* @throws IOException if the minimum data rate, when set, is not respected
1254-
* @see org.eclipse.jetty.io.WriteFlusher.Listener
1255-
*/
1256-
public void onFlushed(long bytes) throws IOException
1257-
{
1258-
if (_firstByteNanoTime == -1 || _firstByteNanoTime == Long.MAX_VALUE)
1259-
return;
1260-
long minDataRate = _servletChannel.getConnectionMetaData().getHttpConfiguration().getMinResponseDataRate();
1261-
_flushed += bytes;
1262-
long minFlushed = minDataRate * NanoTime.millisSince(_firstByteNanoTime) / TimeUnit.SECONDS.toMillis(1);
1263-
if (LOG.isDebugEnabled())
1264-
LOG.debug("Flushed bytes min/actual {}/{}", minFlushed, _flushed);
1265-
if (_flushed < minFlushed)
1266-
{
1267-
IOException ioe = new IOException(String.format("Response content data rate < %d B/s", minDataRate));
1268-
_servletChannel.abort(ioe);
1269-
throw ioe;
1270-
}
1271-
}
1272-
12731248
public void recycle()
12741249
{
12751250
try (AutoLock ignored = _channelState.lock())

jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/HttpOutput.java

-30
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.nio.charset.CoderResult;
2525
import java.nio.charset.CodingErrorAction;
2626
import java.util.concurrent.CancellationException;
27-
import java.util.concurrent.TimeUnit;
2827

2928
import jakarta.servlet.RequestDispatcher;
3029
import jakarta.servlet.ServletOutputStream;
@@ -1418,35 +1417,6 @@ public void setBufferSize(int size)
14181417
_commitSize = size;
14191418
}
14201419

1421-
/**
1422-
* <p>Invoked when bytes have been flushed to the network.</p>
1423-
* <p>The number of flushed bytes may be different from the bytes written
1424-
* by the application if an {@link Interceptor} changed them, for example
1425-
* by compressing them.</p>
1426-
*
1427-
* @param bytes the number of bytes flushed
1428-
* @throws IOException if the minimum data rate, when set, is not respected
1429-
* @see org.eclipse.jetty.io.WriteFlusher.Listener
1430-
*/
1431-
public void onFlushed(long bytes) throws IOException
1432-
{
1433-
// TODO not called.... do we need this now?
1434-
if (_firstByteNanoTime == -1 || _firstByteNanoTime == Long.MAX_VALUE)
1435-
return;
1436-
long minDataRate = getHttpChannel().getHttpConfiguration().getMinResponseDataRate();
1437-
_flushed += bytes;
1438-
long elapsed = NanoTime.since(_firstByteNanoTime);
1439-
long minFlushed = minDataRate * TimeUnit.NANOSECONDS.toMillis(elapsed) / TimeUnit.SECONDS.toMillis(1);
1440-
if (LOG.isDebugEnabled())
1441-
LOG.debug("Flushed bytes min/actual {}/{}", minFlushed, _flushed);
1442-
if (_flushed < minFlushed)
1443-
{
1444-
IOException ioe = new IOException(String.format("Response content data rate < %d B/s", minDataRate));
1445-
_channel.abort(ioe);
1446-
throw ioe;
1447-
}
1448-
}
1449-
14501420
public void recycle()
14511421
{
14521422
try (AutoLock l = _channelState.lock())

0 commit comments

Comments
 (0)