OK, looks better, more explicit so that we can find out why this is failing.

There's still a subtle issue in the reporting though. Consider if on attempt N the ServerSocket call gets a valid port but it's one of the reserved ports. Then, unusedRandomPort will be >= 0 and isReservedPort() will be true, so we'll get the "INFO" message.

Now on attempt N+1 suppose ServerSocket throws an exception. We'll get the exception stack trace, but then unusedRandomPort will still have its previous value, and we'll get the INFO message again, but spuriously this time. I hate to ask you to update this again, but as it stands I think the output will be quite confusing.

I think setting unusedRandomPort back to -1 at the top of the loop should fix 
it.

You need me to push this for you? I can drop in this change before I push, if you're OK with me doing this.

s'marks

On 12/5/12 12:51 PM, Jim Gish wrote:
Here's a new version for your consideration :-)

http://cr.openjdk.java.net/~jgish/Bug8004317-TestLibrary-getUnusedRandomPort-Failure/
<http://cr.openjdk.java.net/%7Ejgish/Bug8004317-TestLibrary-getUnusedRandomPort-Failure/>

Thanks,
    Jim

On 12/05/2012 02:45 PM, Stuart Marks wrote:
On 12/5/12 8:41 AM, Jim Gish wrote:
BTW printStackTrace() prints to standard error by default -- that's why I don't
explicitly have it in there.

Oh yes, so it does. Sorry, I was confused.

s'marks

--
Jim Gish | Consulting Member of Technical Staff | +1.781.442.0304
Oracle Java Platform Group | Core Libraries Team
35 Network Drive
Burlington, MA 01803
jim.g...@oracle.com

Reply via email to