saravanarajan / acra

Automatically exported from code.google.com/p/acra
0 stars 0 forks source link

NPE in EmailIntentSender.buildBody() when a field is null #41

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What is the expected output? What do you see instead?
ACRA crashes when generating email report with a NullPointerException.

What version of the product are you using? On what operating system?
Android 2.2.1, HTC Desire Z, ACRA 3.1.0 (svn r300)

Please provide any additional information below.
If a CrashReportData value is null, the EmailIntentSender will throw an 
uncaught NPE when building the email body.
This is because on the following line:
builder.append(errorContent.get(field).toString());

errorContent.get(field) returns null, which causes the toString() to fail.  
Acutally, toString() is not required here, because CrashReportData extends 
EnumMap<ReportField, String>, where String is the value type.  Passing null to 
builder.append() is safe, as it will convert it to the string "null".

What steps will reproduce the problem?
1. Enable READ_PHONE_STATE permission in a project using ACRA.
2. Enable email reporting by defining the mailTo property in the 
@ReportsCrashes annotation.
2. Enable reporting of IMEI by defining ReportField.DEVICE_ID for 
mailReportFields property in the @ReportsCrashes annotation.
3. Eject the SIM card from the phone so reading the IMEI will return null.
4. Start the test app and report a crash.
5. ACRA will bomb out with an NPE and no email will be sent.

Original issue reported on code.google.com by nudgeee@gmail.com on 16 Mar 2011 at 2:32

GoogleCodeExporter commented 9 years ago
Actually, my reproduce steps are completely wrong.  Here are the updated steps:

What steps will reproduce the problem?
1. Remove READ_PHONE_STATE permission in a project using ACRA.
2. Enable email reporting by defining the mailTo property in the 
@ReportsCrashes annotation.
2. Enable reporting of IMEI by defining ReportField.DEVICE_ID for 
mailReportFields property in the @ReportsCrashes annotation.
4. Start the test app and report a crash.
5. ACRA will bomb out with an NPE and no email will be sent because the 
ReportField.DEVICE_ID field does not exist in CrashReportData structure.

Original comment by nudgeee@gmail.com on 16 Mar 2011 at 2:35

GoogleCodeExporter commented 9 years ago
Hi,

For your information, you are using an unstable version of ACRA, which will 
soon (hopefully) become ACRA 3.2.0. The 
@ReportsCrashes(mailTo="reports@yourdomain.com") is a new feature which has not 
been completely tested yet... so you're the first ACRA 3.2 alpha tester ;-)

I will fix this ASAP and warn you as soon as it is commited.

Thanks for your help!

Kevin

Original comment by kevin.gaudin on 17 Mar 2011 at 10:42

GoogleCodeExporter commented 9 years ago
You can test with r309.

Original comment by kevin.gaudin on 17 Mar 2011 at 11:07

GoogleCodeExporter commented 9 years ago

Original comment by kevin.gaudin on 22 Dec 2011 at 9:06