Skip to content

Commit 9d18c72

Browse files
committed
clean up
1 parent b2f2902 commit 9d18c72

File tree

1 file changed

+5
-7
lines changed
  • packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view

1 file changed

+5
-7
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import android.view.ViewParent;
2626
import android.view.ViewStructure;
2727
import android.view.animation.Animation;
28+
import android.util.Log;
2829
import androidx.annotation.Nullable;
2930
import com.facebook.common.logging.FLog;
3031
import com.facebook.infer.annotation.Assertions;
@@ -655,11 +656,7 @@ public void onViewRemoved(View child) {
655656
boolean matches = java.util.Arrays.stream(removalTrackedChildrenIDs)
656657
.anyMatch(nativeID::equals);
657658
if (matches) {
658-
StringBuilder stackTraceBuilder = new StringBuilder();
659-
for (StackTraceElement element : new Exception().getStackTrace()) {
660-
stackTraceBuilder.append("\n at ").append(element.toString());
661-
}
662-
String stackTrace = stackTraceBuilder.toString();
659+
String stackTrace = android.util.Log.getStackTraceString(new Throwable());
663660
FLog.e(ReactConstants.TAG, "onViewRemoved of one of the tracked children: " + nativeID + " with stack trace: " + "\n" + stackTrace);
664661
}
665662
}
@@ -1035,10 +1032,11 @@ protected void dispatchDraw(Canvas canvas) {
10351032
try {
10361033
ancestry = describeViewAncestry(this);
10371034
} catch (Throwable ignore) {}
1038-
FLog.e(TAG, "NullPointerException in dispatchDraw of " + e.getStackTrace() + getClass().getName() + ": " + e.getMessage() + "\n Failing view ancestry: " + ancestry);
1035+
FLog.e(TAG, "NullPointerException in dispatchDraw of " + getClass().getName() + ": " + e.getMessage() + "\n Failing view ancestry: " + ancestry);
10391036
FLog.e(TAG, "Child info: \n" + childrenCountInfo + "\n" + childrenViewInfo);
1037+
String caughtErrorStackTrace = android.util.Log.getStackTraceString(e);
10401038
throw new NullPointerException(
1041-
"NullPointerException in dispatchDraw of " + getClass().getName() + ": " + e.getMessage() + "\n" + e.getStackTrace());
1039+
"NullPointerException in dispatchDraw of " + getClass().getName() + ": " + e.getMessage() + "\n" + caughtErrorStackTrace);
10421040
}
10431041
}
10441042

0 commit comments

Comments
 (0)