Closed Bug 1356639 Opened 9 years ago Closed 5 years ago

Upgrade to StandardCharsets.UTF_8 when minSdkVersion >= 19

Categories

(Firefox for Android Graveyard :: General, enhancement, P5)

enhancement

Tracking

(firefox55 affected)

RESOLVED INCOMPLETE
Tracking Status
firefox55 --- affected

People

(Reporter: ahunt, Unassigned)

References

Details

API 19 introduces StandardCharsets, along with StandardCharsets.UTF_8: https://developer.android.com/reference/java/nio/charset/StandardCharsets.html Currently we have many variations on the following, which could be made simpler with StandardCharsets: Charset c = Charset.forName("UTF-8"); Stream s = new SomeStream(new OtherStream(...), c); (Which in itself is safe enough, but Charset.forName() can throw which needs to be handled.) Then we also have things like: Stream s = new SomeStream(new OtherStream(...), Charset.forName("UTF-8")); That's bad - we'll leak the OtherStream if Charset.forName() throws. (Infer catches that, but we've historically ignored Infer.) And then we have examples like this: outputStreamWriter = new OutputStreamWriter(new FileOutputStream(f), "UTF-8"); Also bad, we leak the FileOutputStream if the charset can't be recognised (whereas OutputStreamWriter(OutputStream, Charset) doesn't throw, and can be sued with StandardCharsets). Once we can use API 19, we should just use StandardCharsets everywhere. (The various leaking cases can be tackled as part of the plentiful Infer bugs, see Bug 1175203.)
Blocks: api-19
It turns out we already have StringUtils.UTF_8 doing pretty much the same thing, we should probably use that for now (and replace it with StandardCharsets once it becomes available): https://dxr.mozilla.org/mozilla-central/source/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/StringUtils.java#28
Re-triaging per https://bugzilla.mozilla.org/show_bug.cgi?id=1473195 Needinfo :susheel if you think this bug should be re-triaged.
Priority: -- → P5
We have completed our launch of our new Firefox on Android. The development of the new versions use GitHub for issue tracking. If the bug report still reproduces in a current version of [Firefox on Android nightly](https://play.google.com/store/apps/details?id=org.mozilla.fenix) an issue can be reported at the [Fenix GitHub project](https://github.com/mozilla-mobile/fenix/). If you want to discuss your report please use [Mozilla's chat](https://wiki.mozilla.org/Matrix#Connect_to_Matrix) server https://chat.mozilla.org and join the [#fenix](https://chat.mozilla.org/#/room/#fenix:mozilla.org) channel.
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → INCOMPLETE
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.