Skip to content

Logger.interalLog not catching all possible JSON serialization exception #4

Description

@JuxBzh

The serialization of the context param in the Logger.internalLog method may throw an AssertionError that isn't caught by the try/catch block surrounding the call to the toJsonTree method.

Here is the piece of code (Logger.java line 158 to 166):

 try {
    if (context != null) {
       JsonElement root = gson.toJsonTree(context);
       if (root.isJsonObject()) event = root.getAsJsonObject();
    }
 } catch (Exception e) {
     Log.e(TAG,e.getMessage(), e);
 }

AssertionError extends Error that extends Throwable. A suggested correction would be:

 try {
    if (context != null) {
       JsonElement root = gson.toJsonTree(context);
       if (root.isJsonObject()) event = root.getAsJsonObject();
    }
 } catch (Throwable e) {
     Log.e(TAG,e.getMessage(), e);
 }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions