summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Ebinger <breadley@google.com>2021-04-29 13:59:16 -0700
committerBrad Ebinger <breadley@google.com>2021-04-29 21:15:21 +0000
commit9ee6f302730d426b33d5f80bd1fca761af566d88 (patch)
treed9e31bf868b300eb4189c9c34e9d4e33b96b7f4e
parentc2c84d169a872f5c8c41fc8bf8ca0bb3a4f63e75 (diff)
Bound Telecom logging recursion
Put a bound on the recursion in Session#toString to ensure we do not accidently cause a Stack overflow Bug: 186694546 Test: atest TeleServiceTests Merged-In: I52f44dd02d0d860d0894e9b84fded8cf5ff5a18e Change-Id: I52f44dd02d0d860d0894e9b84fded8cf5ff5a18e
-rw-r--r--telecomm/java/android/telecom/Logging/Session.java22
1 files changed, 11 insertions, 11 deletions
diff --git a/telecomm/java/android/telecom/Logging/Session.java b/telecomm/java/android/telecom/Logging/Session.java
index 4aa3614fa004..e2fb6019f30a 100644
--- a/telecomm/java/android/telecom/Logging/Session.java
+++ b/telecomm/java/android/telecom/Logging/Session.java
@@ -453,19 +453,19 @@ public class Session {
@Override
public String toString() {
- if (mParentSession != null && mIsStartedFromActiveSession) {
+ Session sessionToPrint = this;
+ if (getParentSession() != null && isStartedFromActiveSession()) {
// Log.startSession was called from within another active session. Use the parent's
// Id instead of the child to reduce confusion.
- return mParentSession.toString();
- } else {
- StringBuilder methodName = new StringBuilder();
- methodName.append(getFullMethodPath(false /*truncatePath*/));
- if (mOwnerInfo != null && !mOwnerInfo.isEmpty()) {
- methodName.append("(");
- methodName.append(mOwnerInfo);
- methodName.append(")");
- }
- return methodName.toString() + "@" + getFullSessionId();
+ sessionToPrint = getRootSession("toString");
+ }
+ StringBuilder methodName = new StringBuilder();
+ methodName.append(sessionToPrint.getFullMethodPath(false /*truncatePath*/));
+ if (sessionToPrint.getOwnerInfo() != null && !sessionToPrint.getOwnerInfo().isEmpty()) {
+ methodName.append("(");
+ methodName.append(sessionToPrint.getOwnerInfo());
+ methodName.append(")");
}
+ return methodName.toString() + "@" + sessionToPrint.getFullSessionId();
}
}