Skip to content

Commit

Permalink
Feature flags should be modified in-place. (#1940)
Browse files Browse the repository at this point in the history
* fix(feature flags) refactor feature flags are modified in-place.

* Time limitation for thread collection (#1935)

* fix(threadStack timeout) add time limitation for thread stack

* fix(threadStack timeout) add time limitation for thread stack
  • Loading branch information
SmartbearYing authored and YYChen01988 committed Nov 27, 2023
1 parent 6be1acc commit 9200853
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@

### Enhancements

* The maximum time taken to collect Event.threads can now be controlled using 'Configuration.threadCollectionTimeLimitMillis' (default 5000ms)
* The maximum time taken to collect Event.threads can now be controlled using `Configuration.threadCollectionTimeLimitMillis` (default 5000ms)
[#1935](https://github.com/bugsnag/bugsnag-android/pull/1935)

### Bug fixes

* Updating existing feature flags no longer causes them to change location.
[#1940](https://github.com/bugsnag/bugsnag-android/pull/1940)


## 6.0.0 (2023-11-20)

### Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ internal class FeatureFlags(
}

@Synchronized override fun addFeatureFlag(name: String, variant: String?) {
store.remove(name)
store[name] = variant ?: emptyVariant
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[
{
"featureFlag": "demo_mode"
},
{
"featureFlag": "sample_group",
"variant": "b"
},
{
"featureFlag": "demo_mode"
}
]
16 changes: 6 additions & 10 deletions bugsnag-plugin-android-ndk/src/main/jni/featureflags.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,11 @@ static void insert_new(bugsnag_event *const event, const char *const name,
event->feature_flag_count++;
}

static void modify_at_index_and_reinsert(bugsnag_event *const event,
const int index,
const char *const variant) {
bsg_feature_flag flag = event->feature_flags[index];
free(flag.variant);
set_flag_variant(&flag, variant);

remove_at_index_and_compact(event, index);
event->feature_flags[event->feature_flag_count - 1] = flag;
static void modify_at_index(bugsnag_event *const event, const int index,
const char *const variant) {
bsg_feature_flag *flag = &event->feature_flags[index];
free(flag->variant);
set_flag_variant(flag, variant);
}

void bsg_set_feature_flag(bugsnag_event *event, const char *const name,
Expand All @@ -101,7 +97,7 @@ void bsg_set_feature_flag(bugsnag_event *event, const char *const name,
if (index == INDEX_NOT_FOUND) {
insert_new(event, name, variant);
} else {
modify_at_index_and_reinsert(event, index, variant);
modify_at_index(event, index, variant);
}
bsg_seqlock_release_write(&bsg_feature_flag_lock);
}
Expand Down
8 changes: 4 additions & 4 deletions bugsnag-plugin-android-ndk/src/test/cpp/test_featureflags.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ TEST test_set_feature_flag(void) {
ASSERT_STR_EQ("sample_group", event->feature_flags[0].name);
ASSERT_STR_EQ("a", event->feature_flags[0].variant);

ASSERT_STR_EQ("zzz", event->feature_flags[1].name);
ASSERT_EQ(NULL, event->feature_flags[1].variant);
ASSERT_STR_EQ("demo_mode", event->feature_flags[1].name);
ASSERT_STR_EQ("yes", event->feature_flags[1].variant);

ASSERT_STR_EQ("demo_mode", event->feature_flags[2].name);
ASSERT_STR_EQ("yes", event->feature_flags[2].variant);
ASSERT_STR_EQ("zzz", event->feature_flags[2].name);
ASSERT_EQ(NULL, event->feature_flags[2].variant);

bsg_free_feature_flags(event);
free(event);
Expand Down

0 comments on commit 9200853

Please sign in to comment.