Skip to content

Commit

Permalink
8264824: java/net/Inet6Address/B6206527.java doesn't close ServerSock…
Browse files Browse the repository at this point in the history
…et properly

Reviewed-by: aefimov, dfuchs, michaelm, vtewari
  • Loading branch information
c-cleary authored and AlekseiEfimov committed Apr 15, 2021
1 parent 6b90715 commit 6293299
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions test/jdk/java/net/Inet6Address/B6206527.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -40,22 +40,24 @@ public class B6206527 {
public static void main (String[] args) throws Exception {
Inet6Address addr = getLocalAddr();
if (addr == null) {
System.out.println ("Could not find a link-local address");
System.out.println("Could not find a link-local address");
return;
}

ServerSocket ss = new ServerSocket();
System.out.println ("trying LL addr: " + addr);
ss.bind(new InetSocketAddress(addr, 0));
try (ServerSocket ss = new ServerSocket()) {
System.out.println("trying LL addr: " + addr);
ss.bind(new InetSocketAddress(addr, 0));
}

// need to remove the %scope suffix
addr = (Inet6Address)InetAddress.getByAddress (
addr = (Inet6Address) InetAddress.getByAddress (
addr.getAddress()
);

System.out.println ("trying LL addr: " + addr);
ss = new ServerSocket();
ss.bind(new InetSocketAddress(addr, 0));
try (ServerSocket ss = new ServerSocket()) {
System.out.println("trying LL addr: " + addr);
ss.bind(new InetSocketAddress(addr, 0));
}
}

public static Inet6Address getLocalAddr() throws Exception {
Expand Down

1 comment on commit 6293299

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.