cactoos: WriterAsOutputStream does not close the enclosed Writer

WriterAsOutputStream does not override close(), hence leaving the enclosed writer open.

Example writing contents to a file and then deleting the file:

        final Path temp = Files.createTempFile("", "");
        new TextOf(
            new TeeInput(
                new ResourceOf("org/cactoos/large-text.txt"),
                new OutputTo(
                    new WriterAsOutputStream(
                        new OutputStreamWriter(
                            new FileOutputStream(temp.toFile()),
                            StandardCharsets.UTF_8
                        ),
                        StandardCharsets.UTF_8,
                        345
                    )
                )
            )
        ).asString();
        Files.delete(temp);    //IOException "the file is being used by another process"

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

@rexim yes, it is consistently reproducible on Windows.