git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [3/3] ant git commit: Use try-with-resources


On 2018-11-17, <gintas@xxxxxxxxxx> wrote:

in EchoXml

> -        } catch (BuildException e) {
> -            throw e;
> -        } catch (Exception e) {
> +        } catch (IOException e) {
>              throw new BuildException(e);

before your change we'd wrap arbitrary RuntimeExceptions into
BuildExceptions, after your change they'll just escape the method
unwrapped.

Please revert this part.

In Manifest

>      /** Encoding to be used for JAR files. */
> -    public static final String JAR_ENCODING = "UTF-8";
> +    public static final Charset JAR_ENCODING = StandardCharsets.UTF_8;

chnages the type of a public constant which is not backwards
compatible. Besides, this really is not related to try-with-resources at
all.

Please revert this part.

In AntAnalyzer

> -                    ZipFile zipFile = null;
> -                    InputStream inStream = null;
> -                    try {
...
> +                    try (InputStream inStream = container.getName().endsWith(".class")
> +                            ? Files.newInputStream(Paths.get(container.getPath()))
> +                            : new ZipFile(container.getPath()).getInputStream(new ZipEntry(
> +                                    classname.replace('.', '/') + ".class"))) {

I believe this will not close the ZipFile (which implements
AutoCloseable itself). Please ensure it is closes when needed.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xxxxxxxxxxxxxx
For additional commands, e-mail: dev-help@xxxxxxxxxxxxxx