Revisiting MayHoldCloseableResource

Paul Benedict pbenedict at apache.org
Tue Aug 13 10:24:26 PDT 2013


If it's necessary for an intermediate function to manufacture streams, I
think there should be a general pattern (or API) to formally delegate the
creation and closing of them.

Perhaps you want to do something like this:

Files.walk(dir).flatMap(files::lines, new StreamProducer() {
  public String onStreamCreate(Object o) {
    // next line from Files::lines
  }
  public void onStreamComplete(Stream s) {
    // close the stream
  }
});

-- 
Cheers,
Paul


More information about the lambda-libs-spec-observers mailing list