Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in HttpSender.java for USER_COMMENT field #592

Closed
betfix opened this issue Jul 25, 2017 · 1 comment
Closed

NullPointerException in HttpSender.java for USER_COMMENT field #592

betfix opened this issue Jul 25, 2017 · 1 comment

Comments

@betfix
Copy link

betfix commented Jul 25, 2017

I use ACRA version 4.9.2. But when the app crashes, no reports are sent to the backend and instead I can see the following in the logcat:

...
D/ACRA: Connect to http://192.168.0.12/acra-backend/report.php
E/ACRA: Failed to send crash reports for /data/data/com.my.app/app_ACRA-approved/2017-06-13T07:46:49.808+0000-IS_SILENT.stacktrace 
java.lang.NullPointerException
    at org.acra.sender.HttpSender.remap(HttpSender.java:254)
...

During debugging I discovered that in line 254 in HttpSender.java (https://github.com/ACRA/acra/blob/acra-4.9.2/src/main/java/org/acra/sender/HttpSender.java) when field is equal to "USER_COMMENT" then report.get(field) is NULL, and this causes the null pointer exception with flatten() function. It's the only NULL field of all 28 fields. By the way, the IS_SILENT field is false (but maybe that's ok)

So in order to really send the report I made a local copy and changed this line in HttpSender.java:

String value = TextUtils.join("\n", report.get(field).flatten());

into this code:

Element element = report.get(field);
String[] flattened;
if (element != null) {
    flattened = element.flatten();
} else {
    flattened = new String[0];
}
String value = TextUtils.join("\n", flattened);

It looks like an error in ACRA, but then it would be for everyone and not only for me. Perhaps I messed some configuration? How to deal with it without hacking?

P.S.

My Application config is as follows:

@ReportsCrashes(
    formUri = "http://192.168.0.12/acra-backend/report.php"
)
public class MyApplication extends Application {
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        ACRA.DEV_LOGGING = true;
        ACRA.init(this);

    }
}
@F43nd1r
Copy link
Member

F43nd1r commented Jul 25, 2017

Duplicate of #541

@F43nd1r F43nd1r marked this as a duplicate of #541 Jul 25, 2017
@F43nd1r F43nd1r closed this as completed Jul 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants