On 3/24/2014 4:22 PM, Endi Sukma Dewata wrote:
4. In getConnForOp() if op is null it will remove an element but
will
still return a null:
private IHttpConnection getConnForOp(String op) {
IHttpConnection retConn = null;
if (op == null) {
retConn = mConns.elementAt(mNumConns);
mConns.removeElementAt(mNumConns);
} else {
...
}
return retConn; // return null?
}
Is this the correct behavior? Or should it return the removed element?
Sorry, I misread the code. The method does return the removed element.
In general it's still better to return from the method as early as possible:
private IHttpConnection getConnForOp(String op) {
...
if (op == null) {
// return immediately
return mConns.remove(mNumConns);
}
// otherwise continue with the method
IHttpConnection retConn = null;
...
}
--
Endi S. Dewata