Skip to content

Commit c17a012

Browse files
committed
8278961: Enable debug logging in java/net/DatagramSocket/SendDatagramToBadAddress.java
Reviewed-by: dfuchs, msheppar
1 parent b61a4af commit c17a012

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

test/jdk/java/net/DatagramSocket/SendDatagramToBadAddress.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,7 @@
2828
*
2929
* @summary DatagramSocket.send should throw exception when connected
3030
* to an invalid destination (on platforms that support it).
31-
* @run main/othervm SendDatagramToBadAddress
31+
* @run main/othervm SendDatagramToBadAddress -d
3232
*/
3333

3434
import java.net.*;
@@ -70,6 +70,8 @@ public void receive (int loop, boolean expectError) throws Exception {
7070
for (int i=0; i<loop; i++) {
7171
try {
7272
server.receive (pack);
73+
print("received data from address " + pack.getAddress()
74+
+ " port " + pack.getPort());
7375
} catch (Exception e) {
7476
if (expectError) {
7577
print ("Got expected error: " + e);
@@ -116,12 +118,15 @@ private void test(DatagramSocket sock) throws Exception {
116118
DatagramPacket p;
117119
byte[] buf;
118120
int port = serversock.getLocalPort ();
121+
print("tests will be run against destination address " + addr + " port " + port);
119122
final int loop = 5;
120123
Server s = new Server (serversock);
121124
int i;
122125

123126
print ("Checking send to connected address ...");
124127
sock.connect(addr, port);
128+
print("socket is locally bound to address " + sock.getLocalAddress()
129+
+ " port " + sock.getLocalPort());
125130

126131
for (i = 0; i < loop; i++) {
127132
try {
@@ -170,6 +175,8 @@ private void test(DatagramSocket sock) throws Exception {
170175
sock.send(p);
171176
p = new DatagramPacket(buf, buf.length, addr, port);
172177
sock.receive (p);
178+
print("(unexpectedly) received data from address " + p.getAddress()
179+
+ " port " + p.getPort() + " on attempt " + i);
173180
} catch (InterruptedIOException ex) {
174181
print ("socket timeout");
175182
} catch (Exception ex) {

0 commit comments

Comments
 (0)