It looks like this sometimes fails (the log statement branch if nothing else). Why not return a boolean indicating whether it succeeded?