On 27/03/2020 22:00, ma...@apache.org wrote:
> This is an automated email from the ASF dual-hosted git repository.
> 
> markt pushed a commit to branch master
> in repository https://gitbox.apache.org/repos/asf/tomcat.git
> 
> 
> The following commit(s) were added to refs/heads/master by this push:
>      new 03f9d50  Refactor to silence some false positives leak warnings in 
> Eclipse
> 03f9d50 is described below
> 
> commit 03f9d50283b25c1dd3f371d2f0757ef036d726f7
> Author: Mark Thomas <ma...@apache.org>
> AuthorDate: Fri Mar 27 21:59:45 2020 +0000
> 
>     Refactor to silence some false positives leak warnings in Eclipse

<snip/>

> diff --git a/java/org/apache/catalina/valves/ErrorReportValve.java 
> b/java/org/apache/catalina/valves/ErrorReportValve.java
> index 007f10f..b669ba2 100644
> --- a/java/org/apache/catalina/valves/ErrorReportValve.java
> +++ b/java/org/apache/catalina/valves/ErrorReportValve.java
> @@ -197,7 +197,9 @@ public class ErrorReportValve extends ValveBase {
>              if (throwable != null) {
>                  String exceptionMessage = throwable.getMessage();
>                  if (exceptionMessage != null && exceptionMessage.length() > 
> 0) {
> -                    message = Escape.htmlElementContent((new 
> Scanner(exceptionMessage)).nextLine());
> +                    try (Scanner scanner = new Scanner(exceptionMessage)) {
> +                        message = 
> Escape.htmlElementContent(scanner.nextLine());
> +                    }
>                  }
>              }
>              if (message == null) {

Ideally the false positives would get fixed but irrespective of that I
don't mind the other fixes but this one I am less keen on.
Unfortunately, I can't see a better way of fixing it. I thought about
silencing the warning but that has to be at the method level and could
silence a genuine leak in a future commit. Overall this seemed like the
least bad option to get back to zero IDE errors.

And I do find zero IDE errors helpful as it means as soon as I see a
warning I know I've done something wring and can fix it.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to