Is it safe to return a size of a container then changing that container in a finally block?
<p>I'm writing a function that detaches the data from a container and returns the number of elements detached: </p>

<pre><code>int detach(foo f)
{
    try {
        /*some code*/
        return m_ids.size();
    } finally {
        m_ids.clear();
    }
}
</code></pre>

<p><code>foo</code> is an object that receives the data in <code>m_ids</code>, which is a <code>java.util.List</code>.</p>

<p>My concern: is this code safe? Will it return the size of <code>m_ids</code> before it's cleared?</p>