Return value changed after finally
- by Nestor
I have the following code:
public bool ProcessData(String data)
{
try
{
 result= CheckData(data);
 if (TextUtils.isEmpty(result))
   {
    summary="Data is invalid";
    return false;
   }
...
finally
    {
      Period period = new Period(startTime, new LocalDateTime());
      String duration = String.format("Duration: %s:%s",
        period.getMinutes(), period.getSeconds());
      LogCat(duration);
    }
return true;
As I learned from this question, the finally block is executed after the return statement. So I modified my code according to that, and in the finally I inserted code that does not modify the output.
Strangely, the code OUTSIDE the finally block does.
My method always returns true.
As suggested, it is not a good idea to have 2 return.
What should I do?