Fixes concurrency issue in Session's toString

Currently, there is the possibility of Log.endSession() running at the
same time as Session.toString() in a different thread (for example, when
Log.i(...) is called). This can rarely cause the parent of a subsession
to be set to null after getFullSessionId has checked to see if the
parent is null, leading to a NPE.

We now cache the parentSession locally in getFullSessionId to ensure
that another thread does not unlink the parent and the child during
cleanup while toString is running.

Bug: 26693271
Change-Id: Ife7bcd5bb4db295c9b46898306119932dd24a508
1 file changed