diff --git a/sentry-android/src/main/java/com/joshdholtz/sentry/Sentry.java b/sentry-android/src/main/java/com/joshdholtz/sentry/Sentry.java index ddb2aeb..737538e 100755 --- a/sentry-android/src/main/java/com/joshdholtz/sentry/Sentry.java +++ b/sentry-android/src/main/java/com/joshdholtz/sentry/Sentry.java @@ -969,12 +969,12 @@ static JSONObject frameJson(StackTraceElement ste) throws JSONException { final JSONObject frame = new JSONObject(); final String method = ste.getMethodName(); - if (method.length() != 0) { + if (Present(method)) { frame.put("function", method); } final String fileName = ste.getFileName(); - if (fileName.length() > 0) { + if (Present(fileName)) { frame.put("filename", fileName); } @@ -1027,7 +1027,7 @@ private static Map deviceContext(Context context) { device.put("model_id", Build.MODEL); final String architecture = System.getProperty("os.arch"); - if (architecture != null) { + if (Present(architecture)) { device.put("arch", architecture); } @@ -1065,7 +1065,7 @@ private static Map osContext() { os.put("build", Integer.toString(Build.VERSION.SDK_INT)); } final String kernelVersion = System.getProperty("os.version"); - if (kernelVersion != null) { + if (Present(kernelVersion)) { os.put("kernel_version", kernelVersion); } @@ -1093,4 +1093,12 @@ private static Map packageContext(Context context) { } return pack; } + + + /** + * Take the idea of `present?` from ActiveSupport. + */ + private static boolean Present(String s) { + return s != null && s.length() > 0; + } }