提交 025527ab 编写于 作者: A alanb

7015410: test/java/net/Socks/SocksProxyVersion.java needs to be updated due to 7013420

Reviewed-by: chegar
上级 2d8a59b3
...@@ -36,15 +36,22 @@ import java.io.DataInputStream; ...@@ -36,15 +36,22 @@ import java.io.DataInputStream;
import java.io.IOException; import java.io.IOException;
public class SocksProxyVersion implements Runnable { public class SocksProxyVersion implements Runnable {
ServerSocket ss; final ServerSocket ss;
volatile boolean failed; volatile boolean failed;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
new SocksProxyVersion(); new SocksProxyVersion();
} }
@SuppressWarnings("try")
public SocksProxyVersion() throws Exception { public SocksProxyVersion() throws Exception {
ss = new ServerSocket(0); ss = new ServerSocket(0);
try (ServerSocket socket = ss) {
runTest();
}
}
void runTest() throws Exception {
int port = ss.getLocalPort(); int port = ss.getLocalPort();
Thread serverThread = new Thread(this); Thread serverThread = new Thread(this);
serverThread.start(); serverThread.start();
...@@ -75,22 +82,21 @@ public class SocksProxyVersion implements Runnable { ...@@ -75,22 +82,21 @@ public class SocksProxyVersion implements Runnable {
} }
public void run() { public void run() {
try (ss) { try {
Socket s = ss.accept(); try (Socket s = ss.accept()) {
int version = (s.getInputStream()).read(); int version = (s.getInputStream()).read();
if (version != 4) { if (version != 4) {
System.out.println("Got " + version + ", expected 4"); System.out.println("Got " + version + ", expected 4");
failed = true; failed = true;
}
} }
s.close(); try (Socket s = ss.accept()) {
int version = (s.getInputStream()).read();
s = ss.accept(); if (version != 5) {
version = (s.getInputStream()).read(); System.out.println("Got " + version + ", expected 5");
if (version != 5) { failed = true;
System.out.println("Got " + version + ", expected 5"); }
failed = true;
} }
s.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册