pivot-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sandro Martini <sandro.mart...@gmail.com>
Subject Re: FindBugs Analysis
Date Mon, 20 Jun 2011 14:17:24 GMT
>I understand. But it doesn't provide any explanation as to *why* the file
might not have been deleted. Was it because the file didn't exist? Because
there was some internal error in the file system? Something else?
Yes, I agree with you, it's not clear, but could be due to many things (file
not existing, not enough permissions to delete, etc) ...

> The method signature does not need to change. If the file doesn't exist,
> an HTTP 404 should be returned via QueryException. If any other error
> occurs, it should also be returned via QueryException (using whatever HTTP
> status code is appropriate).

This is the description of the issue (form FingBugs):
This method returns a value that is not checked. The return value should be
checked since it can indicate an unusual or unexpected function execution.
For example, the File.delete() method returns false if the file could not be
successfully deleted (rather than throwing an Exception). If you don't check
the result, you won't notice if the method invocation signals unexpected
behavior by returning an atypical return value. 

on the line:
        file.delete();
inside the doDelete method of RESTDemoServlet.

Reading better, it says that after the call to delete you can't be sure that
the delete is successfully done (because you don't read the returned value
from the call to delete).
Maybe we could only read the returned value there and if it's false throw a
QueryException (all inside there), without changing other signatures etc,
right ? Do you like this ?
So this could be another (small) "best practice" shown in our demos ...


Thank you very much, for the patience too :-) .

Bye



--
View this message in context: http://apache-pivot-developers.417237.n3.nabble.com/FindBugs-Analysis-tp3076403p3086408.html
Sent from the Apache Pivot - Developers mailing list archive at Nabble.com.

Mime
View raw message