[ 
https://issues.apache.org/jira/browse/BEAM-3158?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Etienne Chauchot updated BEAM-3158:
-----------------------------------
    Description: 
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}

  was:
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}


> 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)

Reply via email to