Skip to content

Commit

Permalink
Fixes #6410 - Use SocketAddress instead of InetSocketAddress.
Browse files Browse the repository at this point in the history
Restored fake socket addresses in ByteArrayEndPoint,
as too many tests depend on these fake socket addresses.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
  • Loading branch information
sbordet committed Jun 15, 2021
1 parent 2387a00 commit f34c541
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java
Expand Up @@ -15,6 +15,9 @@

import java.io.EOFException;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.charset.Charset;
Expand All @@ -35,7 +38,20 @@
*/
public class ByteArrayEndPoint extends AbstractEndPoint
{
private static SocketAddress noSocketAddress()
{
try
{
return new InetSocketAddress(InetAddress.getByName("0.0.0.0"), 0);
}
catch (Throwable x)
{
throw new RuntimeIOException(x);
}
}

private static final Logger LOG = LoggerFactory.getLogger(ByteArrayEndPoint.class);
private static final SocketAddress NO_SOCKET_ADDRESS = noSocketAddress();
private static final int MAX_BUFFER_SIZE = Integer.MAX_VALUE - 1024;
private static final ByteBuffer EOF = BufferUtil.allocate(0);

Expand Down Expand Up @@ -96,6 +112,18 @@ public ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, ByteBuffer input,
onOpen();
}

@Override
public SocketAddress getLocalSocketAddress()
{
return NO_SOCKET_ADDRESS;
}

@Override
public SocketAddress getRemoteSocketAddress()
{
return NO_SOCKET_ADDRESS;
}

@Override
public void doShutdownOutput()
{
Expand Down

0 comments on commit f34c541

Please sign in to comment.