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/09 11:26:00 UTC
[jira] [Closed] (BEAM-3158) DoFnTester should call close() in catch
bloc and then re-throw exception to allow using @Rule ExpectedException
[ https://issues.apache.org/jira/browse/BEAM-3158?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Etienne Chauchot closed BEAM-3158.
----------------------------------
Resolution: Won't Do
Fix Version/s: Not applicable
> DoFnTester should call close() in catch bloc and then re-throw exception to allow using @Rule ExpectedException
> ---------------------------------------------------------------------------------------------------------------
>
> 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
> Fix For: Not applicable
>
>
> 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}
> But maybe {{DoFnTester}} cannot always be safely closed if a exception was raised.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)