Created
December 6, 2016 19:22
-
-
Save invisiblek/bd04096082fa22dfad4a87a7b838926a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/luni/src/test/java/libcore/java/net/DatagramSocketTest.java b/luni/src/test/java/libcore/java/net/DatagramSocketTest.java | |
index 2e091ab..067291a 100644 | |
--- a/luni/src/test/java/libcore/java/net/DatagramSocketTest.java | |
+++ b/luni/src/test/java/libcore/java/net/DatagramSocketTest.java | |
@@ -19,12 +19,10 @@ package libcore.java.net; | |
import junit.framework.TestCase; | |
import java.lang.reflect.Field; | |
-import java.net.DatagramPacket; | |
import java.net.DatagramSocket; | |
+import java.net.InetSocketAddress; | |
import java.net.DatagramSocketImpl; | |
import java.net.InetAddress; | |
-import java.net.InetSocketAddress; | |
-import java.net.SocketException; | |
public class DatagramSocketTest extends TestCase { | |
@@ -60,36 +58,6 @@ public class DatagramSocketTest extends TestCase { | |
assertEquals(-1, ds.getLocalPort()); | |
assertNull(ds.getLocalSocketAddress()); | |
} | |
- | |
- public void testPendingException() throws Exception { | |
- final int port = 9999; | |
- | |
- try (DatagramSocket s = new DatagramSocket()) { | |
- s.connect(InetAddress.getLocalHost(), port); | |
- | |
- // connect may set pendingConnectException on internal failure; since we have no reliable way | |
- // to make connect fail, set pendingConnectException through reflection. | |
- Field pendingConnectException = s.getClass().getDeclaredField("pendingConnectException"); | |
- pendingConnectException.setAccessible(true); | |
- pendingConnectException.set(s, new SocketException()); | |
- | |
- byte[] data = new byte[100]; | |
- DatagramPacket p = new DatagramPacket(data, data.length); | |
- | |
- try { | |
- s.send(p); | |
- fail(); | |
- } catch (SocketException expected) { | |
- } | |
- | |
- try { | |
- s.receive(p); | |
- fail(); | |
- } catch (SocketException expected) { | |
- } | |
- } | |
- } | |
- | |
// Socket should become connected even if impl.connect() failed and threw exception. | |
public void test_b31218085() throws Exception { | |
final int port = 9999; | |
diff --git a/ojluni/src/main/java/java/net/DatagramSocket.java b/ojluni/src/main/java/java/net/DatagramSocket.java | |
index 1eca3a4..6565e34 100755 | |
--- a/ojluni/src/main/java/java/net/DatagramSocket.java | |
+++ b/ojluni/src/main/java/java/net/DatagramSocket.java | |
@@ -155,10 +155,10 @@ class DatagramSocket implements java.io.Closeable { | |
connectState = ST_CONNECTED_NO_IMPL; | |
} else { | |
try { | |
+ getImpl().connect(address, port); | |
// socket is now connected by the impl | |
connectState = ST_CONNECTED; | |
- getImpl().connect(address, port); | |
} catch (SocketException se) { | |
// connection will be emulated by DatagramSocket | |
connectState = ST_CONNECTED_NO_IMPL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment