RFR: 8169335: Add a crypto.policy fallback in case Security Property 'crypto.policy' does not exist

Wang Weijun weijun.wang at oracle.com
Thu Nov 17 02:49:47 UTC 2016


> On Nov 17, 2016, at 9:33 AM, Bradford Wetmore <bradford.wetmore at oracle.com> wrote:
> 
>        try (PrintWriter out = new PrintWriter(FILENAME)) {
>            Files.lines(path)
>                    .filter(x -> !x.trim().startsWith("crypto.policy"))
>                    .forEach(out::println);
>        }

Not very sure. Although IMHO a terminate method like forEach *should* close the stream, the spec has not said so:

* <p>Streams have a {@link #close()} method and implement {@link AutoCloseable}.
* Operating on a stream after it has been closed will throw {@link IllegalStateException}.
* Most stream instances do not actually need to be closed after use, as they
* are backed by collections, arrays, or generating functions, which require no
* special resource management. Generally, only streams whose source is an IO channel,
* such as those returned by {@link Files#lines(Path)}, will require closing. If a
* stream does require closing, it must be opened as a resource within a try-with-resources
* statement or similar control structure to ensure that it is closed promptly after its
* operations have completed.

I know you use Windows, so if you haven't seen any test failure, maybe it's safe.

Thanks
Max




More information about the security-dev mailing list