lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shai Erera <>
Subject WriteLineDocTask does not release resources
Date Sat, 11 Apr 2009 05:04:24 GMT
WriteLineDocTask instantiates a BufferedWriter, but never closes it. This
causes some problems in LUCENE-1591 since I want to wrap CBZip2OutputStream,
and the stream has to be closed in order for the archive to be valid
(flush() is not enough).

Unlike DocMaker, which has a resetInputs method, tasks have no such
*finalizer* method which can be called upon test completion, or even by
ResetInputsTask. I assume that's because tasks are viewed as stateless
objects, or at least very lightweight. Indeed, all tasks (besides this one)
use the information stored in PerfRunData to operate, and thus are
"stateless". Someone can include a *finalizer* task, such as CloseIndex, if
the test used any resource that need to be closed.

setup() and tearDown() are called once for every doLogic(), so we cannot
release such resources there.

I was thinking how to solve it:
* Include a map of <Task, TaskResources> in PerfRunData, and create a new
task WriteLineDocFinalizerTask which will get the resources used by
WriteLineDocTask and close them (in this case the Writer used to output
data). WLDT will store the writer in this map.
* Introduce PerfTask.releaseResources() which will have empty impl in
PerfTask, and extended in WLDT to close the writer. That method will be
called upon test completion (on all tasks).

I like option (1) better. TaskResources can be just an interface, with no
methods, and each task will have its own implementation.

What do you think?


View raw message