Skip to content

Commit

Permalink
bug(SharedPreference): prevent SharedPreference causing rare app crash
Browse files Browse the repository at this point in the history
  • Loading branch information
YYChen01988 committed Jun 29, 2023
2 parents dfac185 + 2888547 commit fe8c946
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
* ANR or NDK detection warnings can be suppressed (using `enabledErrorTypes`) when plugin is excluded.
[#1832](https://github.com/bugsnag/bugsnag-android/pull/1832)

### Bug fixes

* Prevent rare app crash while migrating old `SharedPreferences` data from older versions of `bugsnag-android
[#1860](https://github.com/bugsnag/bugsnag-android/pull/1860)

## 5.29.0 (2023-03-23)

### Enhancements
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2023.0218.1)
multi_test (0.1.2)
nokogiri (1.15.1-arm64-darwin)
racc (~> 1.4)
nokogiri (1.15.1-x86_64-darwin)
racc (~> 1.4)
optimist (3.0.1)
Expand Down Expand Up @@ -121,6 +123,7 @@ GEM
rexml

PLATFORMS
arm64-darwin-22
x86_64-darwin-20

DEPENDENCIES
Expand Down
18 changes: 9 additions & 9 deletions features/full_tests/trimming.feature
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ Feature: Excess data is trimmed when the payload is too big
Then I wait to receive an error
And the error is valid for the error reporting API version "4.0" for the "Android Bugsnag Notifier" notifier
And the exception "message" equals "EventTooBigScenario"
And the event has 98 breadcrumbs
And the event "breadcrumbs.97.name" equals "Removed, along with 2 older breadcrumbs, to reduce payload size"
And the event "usage.system.breadcrumbsRemoved" equals 3
And the event has less than 99 breadcrumbs
Then the event last breadcrumb has a message that matches the regex "Removed, along with [0-9]+ older breadcrumbs, to reduce payload size"
And the event "usage.system.breadcrumbsRemoved" is not null
And the event "usage.system.breadcrumbBytesRemoved" is not null
And I close and relaunch the app
Then I wait to receive an error
And the error is valid for the error reporting API version "4.0" for the "Android Bugsnag Notifier" notifier
And the exception "message" equals "EventTooBigScenario"
And the event has 98 breadcrumbs
And the event "breadcrumbs.97.name" equals "Removed, along with 2 older breadcrumbs, to reduce payload size"
And the event "usage.system.breadcrumbsRemoved" equals 3
And the event has less than 99 breadcrumbs
Then the event last breadcrumb has a message that matches the regex "Removed, along with [0-9]+ older breadcrumbs, to reduce payload size"
And the event "usage.system.breadcrumbsRemoved" is not null
And the event "usage.system.breadcrumbBytesRemoved" is not null

Scenario: Payload is too big by 3 breadcrumbs, handled exception
Expand All @@ -75,9 +75,9 @@ Feature: Excess data is trimmed when the payload is too big
Then I wait to receive an error
And the error is valid for the error reporting API version "4.0" for the "Android Bugsnag Notifier" notifier
And the exception "message" equals "EventTooBigScenario"
And the event has 98 breadcrumbs
And the event "breadcrumbs.97.name" equals "Removed, along with 2 older breadcrumbs, to reduce payload size"
And the event "usage.system.breadcrumbsRemoved" equals 3
And the event has less than 99 breadcrumbs
Then the event last breadcrumb has a message that matches the regex "Removed, along with [0-9]+ older breadcrumbs, to reduce payload size"
And the event "usage.system.breadcrumbsRemoved" is not null
And the event "usage.system.breadcrumbBytesRemoved" is not null

Scenario: Payload is too big by 3 breadcrumbs, jvm exception
Expand Down
14 changes: 14 additions & 0 deletions features/steps/android_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,17 @@ def click_if_present(element)
end
end
end

Then("the event has less than {int} breadcrumb(s)") do |expected|
breadcrumbs = Maze::Server.errors.current[:body]['events'].first['breadcrumbs']
Maze.check.operator(
breadcrumbs&.length || 0, :<, expected,
"Expected event to have less '#{expected}' breadcrumbs, but got: #{breadcrumbs}"
)
end

Then("the event last breadcrumb has a message that matches the regex {string}") do |pattern|
lastBreadcrumbName = Maze::Server.errors.current[:body]['events'].first['breadcrumbs'].last['name']
regex = Regexp.new pattern
Maze.check.match regex, lastBreadcrumbName
end

0 comments on commit fe8c946

Please sign in to comment.