accumulo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Keith Turner (JIRA)" <>
Subject [jira] [Commented] (ACCUMULO-2400) race condition in ExamplesIT
Date Tue, 25 Feb 2014 15:19:20 GMT


Keith Turner commented on ACCUMULO-2400:

LogWriter extends Daemon which extends Thread.   LogWriter is passed process.getInputStream()
and then lw.start() is called which starts the thread.  After exec returns the test reads
from process.getInputStream().   If the LogWriter thread has already read from process.getInputStream(),
then the test will fail.  I was thinking of having another exec method that does not start
log writer threads, instead it returns something like the following :

  class ProcessStreams{
     InputStream stdout;
     InputStream stderr;
  public ProcessStreams exec(...){
    //tee stdout
    String logFileNAme = ..;
    new TeeInputStream(process.getInputStream(), new FileOutputStream(logFileName)) {
       public void close(){
             //overidde this method to read all data not read by test before closing... test
need to close in finally block
    //also tee stder

   return new ProcessStreams(...)

> race condition in ExamplesIT
> ----------------------------
>                 Key: ACCUMULO-2400
>                 URL:
>             Project: Accumulo
>          Issue Type: Bug
>         Environment: 6395840418046d8b3a923a4bfb3e4ba486c5dcd0
>            Reporter: Keith Turner
>             Fix For: 1.6.0
> Saw ExamplesIT fail with the following exception.  Looking at the code I think there
is a race condition.  The test calls the MAC.exec() function to create a process and then
reads from stdout of the process.  The MAC exec function starts a background thread to read
from stdout.  If this background thread reads stdout before the test I think it will fail
in the following way.  Probably need to fix everywhere MAC exec is used in this way.  Could
either read from the file MAC creates or pass an option to MAC.exec() to not start the background
> {noformat}
> Stream closed
> 	at
> 	at
> 	at sun.nio.cs.StreamDecoder.readBytes(
> 	at sun.nio.cs.StreamDecoder.implRead(
> 	at
> 	at
> 	at
> 	at
> 	at
> 	at org.apache.accumulo.test.functional.ExamplesIT.testClasspath(
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> 	at java.lang.reflect.Method.invoke(
> 	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
> 	at
> 	at org.junit.runners.model.FrameworkMethod.invokeExplosively(
> 	at org.junit.internal.runners.statements.InvokeMethod.evaluate(
> 	at org.junit.internal.runners.statements.FailOnTimeout$
> {noformat}

This message was sent by Atlassian JIRA

View raw message