# HG changeset patch # User xiaofeya # Date 1474965391 25200 # Node ID 44ba1622deee5a55272ea69e8d9c5f93ec18f29f # Parent 01650fdf328462daaa6ddba1be399b88e9b759af 8154525: java/net/ServerSocket/ThreadStop.java fails intermittently with error while cleaning up threads after test Reviewed-by: chegar diff -r 01650fdf3284 -r 44ba1622deee jdk/test/java/net/ServerSocket/ThreadStop.java --- a/jdk/test/java/net/ServerSocket/ThreadStop.java Mon Sep 26 13:37:10 2016 -0700 +++ b/jdk/test/java/net/ServerSocket/ThreadStop.java Tue Sep 27 01:36:31 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, 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 @@ -68,23 +68,23 @@ thr.start(); // give server time to block in ServerSocket.accept() - Thread.currentThread().sleep(2000); + Thread.sleep(2000); // "stop" the thread thr.stop(); // give thread time to stop - Thread.currentThread().sleep(2000); + Thread.sleep(2000); // it's platform specific if Thread.stop interrupts the // thread - on Linux/Windows most likely that thread is // still in accept() so we connect to server which causes // it to unblock and do JNI-stuff with a pending exception - try { - Socket s = new Socket("localhost", svr.localPort()); - } catch (IOException ioe) { } - + try (Socket s = new Socket("localhost", svr.localPort())) { + } catch (IOException ioe) { + } + thr.join(); } }