You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by "Etienne Chauchot (JIRA)" <ji...@apache.org> on 2017/11/08 15:40:00 UTC

[jira] [Created] (BEAM-3158) DoFnTester should call close() in catch bloc and then re-throw exception

Etienne Chauchot created BEAM-3158:
--------------------------------------

             Summary: DoFnTester should call close() in catch bloc and then re-throw exception
                 Key: BEAM-3158
                 URL: https://issues.apache.org/jira/browse/BEAM-3158
             Project: Beam
          Issue Type: Improvement
          Components: testing
            Reporter: Etienne Chauchot
            Assignee: Etienne Chauchot
            Priority: Minor


In {{CLONE_ONCE}} and {{DO_NOT_CLONE}} cloning behaviors, it is required to explicitly call {{DoFnTester.close()}}. If an exception is raised by the DoFnTester, the user needs to use a try/catch bloc to call DoFnTester.close() himself. If this DoFnTester were doing 
{code}
try{
...
} catch(Exception e){
close();
throw e;
}
{code}
then the user would no longer need to call {{DoFnTester.close()}} (to release resources, stop threads ...) and thus no longer need the try/catch. This will allow him to use the Junit @Rule ExpectedException in place of something ugly like 
{code}
// need to avoid flow interruption to close the DoFnTester
    Exception raisedException = null;
    try {
      fnTester.processBundle(input);
    } catch (IOException exception) {
      raisedException = exception;
    }
    fnTester.close();
    assertTrue(raisedException != null);
{code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)