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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Stefan Bodewig
On 2018-11-17, <[hidden email]> 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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Stefan Bodewig
On 2018-11-18, Stefan Bodewig wrote:

> 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.

Just saw you've already taken care of this part in your next commit.
Thank you.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]