RFR(S): 8198655: test/lib/jdk/test/lib/apps/LingeredApp shouldn't inherit cout/cerr

Igor Ignatyev igor.ignatyev at oracle.com
Mon Mar 12 20:26:24 UTC 2018



> On Mar 12, 2018, at 8:53 AM, Chris Plummer <chris.plummer at oracle.com> wrote:
> 
> On 3/11/18 7:52 PM, David Holmes wrote:
>> Hi Chris,
>> 
>> On 10/03/2018 6:46 AM, Chris Plummer wrote:
>>> Hello,
>>> 
>>> Please help review the following:
>>> 
>>> https://bugs.openjdk.java.net/browse/JDK-8198655
>>> http://cr.openjdk.java.net/~cjplummer/8198655/webrev.00/webrev/
>>> 
>>> In the end there were two issues. The first was that the pb.redirectError() call was redirecting the LingeredApp's stderr to the console, which we don't want. The second was that nothing was capturing the LingeredApp's output and sending it to the driver app's output (jtr file). These changes make all the LingeredApp's output end up in the jtr file.
>> 
>> It isn't clear to me how the interleaving of the two streams by the two threads is handled in the copy routine. Are we guaranteed to get complete lines of output from each stream before writing to System.out?
> Hi David,
> 
> I'm hoping Igor will chime in here, since this is just cloned from some closed code he wrote, and he recommended this fix. Perhaps we are just doing something a bit non standard here. When spawning a separate test process, don't we normally just dump stdout and stderr separately via OutputAnalyzer.reportDiagnosticSummary() after the test completes, and then only if there is an error. I'm not sure why Igor felt LingeredApp tests should be handled differently.

I recommended this fix as one of possibilities and never claimed it's the best solution ;)  I don't know much of LingeredApp tests, so I just suggested the patch which only solves the problem I noticed (LingeredApp's cerr being printed into jtreg agent's cerr). OutputAnalyzer might not fit the use case of LingeredApp b/c it blocks till the process is finished. again, I don't know much about LingeredApp itself and the tests which use it. 

answering to David's question, copy routine handles interleaving of two streams similarly to printf routine, it does not do that at all. we are writing to System.out as we read data, the only guarantee we have is all the bytes we read into buffer will be written together (which might mean 1 byte at a time), no guarantees about lines. the behavior is pretty much the same as you expect to get from an interactive shell w/ both cout and cerr are being printed on the console.

Thanks,
-- Igor
> 
> thanks,
> 
> Chris
>> 
>> Thanks,
>> David
>> -----
>> 
>>> Tested by running all tests that use LingeredApp.
>>> 
>>> thanks,
>>> 
>>> Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/serviceability-dev/attachments/20180312/d7780fe9/attachment.html>


More information about the serviceability-dev mailing list