Skip to content

Commit

Permalink
Merge pull request #75 from marcomorain/filename-can-be-null
Browse files Browse the repository at this point in the history
The filename property of callstack can be null
  • Loading branch information
marcomorain authored Sep 23, 2016
2 parents 43938bc + 4af2e4d commit c205861
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions sentry-android/src/main/java/com/joshdholtz/sentry/Sentry.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -1027,7 +1027,7 @@ private static Map<String, String> 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);
}

Expand Down Expand Up @@ -1065,7 +1065,7 @@ private static Map<String, String> 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);
}

Expand Down Expand Up @@ -1093,4 +1093,12 @@ private static Map<String, String> packageContext(Context context) {
}
return pack;
}


/**
* Take the idea of `present?` from ActiveSupport.
*/
private static boolean Present(String s) {
return s != null && s.length() > 0;
}
}

0 comments on commit c205861

Please sign in to comment.