Return unwrapped SocketOutputStream from PseudoTcpSocket
JDK17 introduced a wrapper around SocketOutputStream in Socket.getOutputStream that doesn't forward flush. Directly return our implementation in PseudoTcpSocket making sure that the original intent of closing the socket when the stream is closed is still followed.
This commit is contained in:
parent
a1b3c9b503
commit
626c35e460
@ -245,6 +245,7 @@ public class PseudoTcpSocket extends Socket
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public synchronized void close()
|
||||
throws IOException
|
||||
{
|
||||
@ -256,6 +257,12 @@ public class PseudoTcpSocket extends Socket
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() throws IOException
|
||||
{
|
||||
return socketImpl.getOutputStream();
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to set up the remote address directly.
|
||||
* Otherwise, when using the other <tt>accept</tt> methods,
|
||||
|
||||
@ -1160,6 +1160,7 @@ class PseudoTcpSocketImpl
|
||||
@Override
|
||||
public void close() throws IOException
|
||||
{
|
||||
PseudoTcpSocketImpl.this.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -91,11 +91,15 @@ public class PseudoTcpStreamTest
|
||||
{
|
||||
client.setDebugName("R");
|
||||
client.connect(serverAddress, 5000);
|
||||
OutputStream os = client.getOutputStream();
|
||||
|
||||
// write single array
|
||||
for (int i = 0; i < singleStepCount; i++)
|
||||
client.getOutputStream().write(bufferSingle[i]);
|
||||
os.write(bufferSingle[i]);
|
||||
|
||||
// write whole array
|
||||
client.getOutputStream().write(bufferA);
|
||||
os.write(bufferA);
|
||||
|
||||
// write by parts
|
||||
int partCount = 7;
|
||||
boolean notExact = sizeB % partCount != 0;
|
||||
@ -111,11 +115,11 @@ public class PseudoTcpStreamTest
|
||||
int written = 0;
|
||||
for (int j : partsSize)
|
||||
{
|
||||
client.getOutputStream().write(bufferB, written, j);
|
||||
os.write(bufferB, written, j);
|
||||
written += j;
|
||||
}
|
||||
assertEquals(sizeB, written);
|
||||
client.getOutputStream().flush();
|
||||
os.flush();
|
||||
client.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
|
||||
@ -51,6 +51,7 @@ java.util.logging.ConsoleHandler.formatter = org.ice4j.util.Ice4jLogFormatter
|
||||
|
||||
# Things coming from ice4j
|
||||
org.ice4j.level = INFO
|
||||
org.ice4j.pseudotcp.PseudoTCPBase.level = SEVERE
|
||||
test.level = INFO
|
||||
#org.ice4j.ice.checks.levell = FINEST
|
||||
#org.ice4j.ice.ConnectivityCheckClient.level = FINER
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user