Commit 665e199b authored by MozLando's avatar MozLando
Browse files

Merge #5163



5163: Closes #5145: Remove INFO Tag from Socorro Java Stack Trace r=pocmo a=rocketsroger
Co-authored-by: default avatarRoger Yang <royang@mozilla.com>
parents f5240c81 dc96a1e7
......@@ -6,8 +6,6 @@ package mozilla.components.lib.crash.service
import mozilla.components.lib.crash.Crash
internal const val INFO_PREFIX = "[INFO]"
/**
* Interface to be implemented by external services that accept crash reports.
*/
......
......@@ -35,6 +35,9 @@ import kotlin.random.Random
/* This ID is used for all Mozilla products. Setting as default if no ID is passed in */
private const val MOZILLA_PRODUCT_ID = "{eeb82917-e434-4870-8148-5c03d4caa81b}"
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal const val CAUGHT_EXCEPTION_NOTE = "This is a caught exception, not a real crash"
/**
* A [CrashReporterService] implementation uploading crash reports to crash-stats.mozilla.com.
*
......@@ -134,8 +137,7 @@ class MozillaSocorroService(
}
throwable?.let {
sendPart(gzipOs, boundary, "JavaStackTrace", getExceptionStackTrace(it,
isCaughtException), nameSet)
sendPart(gzipOs, boundary, "JavaStackTrace", getExceptionStackTrace(it), nameSet)
}
miniDumpFilePath?.let {
......@@ -144,6 +146,10 @@ class MozillaSocorroService(
minidumpFile.delete()
}
if (isCaughtException) {
sendPart(gzipOs, boundary, "Notes", CAUGHT_EXCEPTION_NOTE, nameSet)
}
sendPackageInstallTime(gzipOs, boundary, nameSet)
sendProcessName(gzipOs, boundary, nameSet)
sendPart(gzipOs, boundary, "ReleaseChannel", BuildConfig.MOZ_UPDATE_CHANNEL, nameSet)
......@@ -321,15 +327,12 @@ class MozillaSocorroService(
return resultMap
}
private fun getExceptionStackTrace(throwable: Throwable, isCaughtException: Boolean): String {
private fun getExceptionStackTrace(throwable: Throwable): String {
val stringWriter = StringWriter()
val printWriter = PrintWriter(stringWriter)
throwable.printStackTrace(printWriter)
printWriter.flush()
return when (isCaughtException) {
true -> "$INFO_PREFIX $stringWriter"
false -> stringWriter.toString()
}
return stringWriter.toString()
}
}
......@@ -18,6 +18,8 @@ import io.sentry.event.interfaces.ExceptionInterface
import mozilla.components.Build
import mozilla.components.lib.crash.Crash
private const val INFO_PREFIX = "[INFO]"
/**
* A [CrashReporterService] implementation that uploads crash reports to a Sentry server.
*
......
......@@ -12,6 +12,7 @@ import mozilla.components.support.test.robolectric.testContext
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers.anyBoolean
......@@ -102,6 +103,7 @@ class MozillaSocorroServiceTest {
assert(request.contains("name=ReleaseChannel\r\n\r\nnightly"))
assert(request.contains("name=Android_PackageName\r\n\r\nmozilla.components.lib.crash.test"))
assert(request.contains("name=Android_Device\r\n\r\nrobolectric"))
assertFalse(request.contains("name=Notes\r\n\r\n$CAUGHT_EXCEPTION_NOTE"))
verify(service).report(crash)
verify(service).sendReport(crash.throwable, null, null, false)
......@@ -129,13 +131,14 @@ class MozillaSocorroServiceTest {
val bufferedReader = BufferedReader(reader)
var request = bufferedReader.readText()
assert(request.contains("name=JavaStackTrace\r\n\r\n$INFO_PREFIX java.lang.RuntimeException: Test"))
assert(request.contains("name=JavaStackTrace\r\n\r\njava.lang.RuntimeException: Test"))
assert(request.contains("name=Android_ProcessName\r\n\r\nmozilla.components.lib.crash.test"))
assert(request.contains("name=ProductID\r\n\r\n{eeb82917-e434-4870-8148-5c03d4caa81b}"))
assert(request.contains("name=Vendor\r\n\r\nMozilla"))
assert(request.contains("name=ReleaseChannel\r\n\r\nnightly"))
assert(request.contains("name=Android_PackageName\r\n\r\nmozilla.components.lib.crash.test"))
assert(request.contains("name=Android_Device\r\n\r\nrobolectric"))
assert(request.contains("name=Notes\r\n\r\n$CAUGHT_EXCEPTION_NOTE"))
verify(service).report(throwable)
verify(service).sendReport(throwable, null, null, true)
......@@ -167,7 +170,7 @@ class MozillaSocorroServiceTest {
val bufferedReader = BufferedReader(reader)
var request = bufferedReader.readText()
assert(request.contains("name=JavaStackTrace\r\n\r\n$INFO_PREFIX java.lang.RuntimeException: Test"))
assert(request.contains("name=JavaStackTrace\r\n\r\njava.lang.RuntimeException: Test"))
assert(request.contains("name=Android_ProcessName\r\n\r\nmozilla.components.lib.crash.test"))
assert(request.contains("name=ProductID\r\n\r\n{1234-1234-1234}"))
assert(request.contains("name=Version\r\n\r\n0.1"))
......@@ -176,6 +179,7 @@ class MozillaSocorroServiceTest {
assert(request.contains("name=ReleaseChannel\r\n\r\nnightly"))
assert(request.contains("name=Android_PackageName\r\n\r\nmozilla.components.lib.crash.test"))
assert(request.contains("name=Android_Device\r\n\r\nrobolectric"))
assert(request.contains("name=Notes\r\n\r\n$CAUGHT_EXCEPTION_NOTE"))
verify(service).report(throwable)
verify(service).sendReport(throwable, null, null, true)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment