Skip to content

doClose() executed twice on exit when defining no input #59

@fshofmann

Description

@fshofmann

When creating a new pipeline without any input (e.g. the pipeline input would be done directly with an abstract pipelinestep in this case) any doClose is executed twice. This of course can cause strange behavior when doing anything in these methods (see code snippet below).

Although it could go against the intend, it would be nice that one could define an empty input. This would be especially helpful when one has a step generating samples in some manner or a customized reader that can't be defined as a marshaller.

new Pipeline()
                .step(new AbstractPipelineStep() {
                    @Override
                    public void start(TaskPool pool) throws IOException {
                        super.start(pool);

                        // some generated dummy
                        output.writeSample(new Sample(Header.EMPTY_HEADER, new double[0], new Date()));

                        super.close();
                    }
                })
                .step(new AbstractPipelineStep() {
                    Sample s;

                    @Override
                    public void writeSample(Sample sample) throws IOException {
                        s = sample; // save output for later
                        output.writeSample(s);
                    }

                    @Override
                    protected void doClose() throws IOException {
                        output.writeSample(s);
                    }
                })
                .outputCsv("") // just some path, two files (second one with only one sample)
                .runAndWait();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions