Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[shared_preferences] Fix possible clash of string with double entry #3895

Merged
merged 13 commits into from Aug 20, 2021

Conversation

Cobinja
Copy link
Contributor

@Cobinja Cobinja commented May 15, 2021

This prevents clashing of a string entry with a double entry.
This was already checked for string lists and big integers, yet doubles remained previously unchecked although being stored as strings as well.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides. (Note that unlike the flutter/flutter repo, the flutter/plugins repo does use dart format. See plugin_tool format)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@stuartmorgan
Copy link
Contributor

No new tests written because tests currently use InMemorySharedPreferencesStore

Limitations in existing testing isn't a reason to not add new tests. Is there a reason this is not easily testable? It seems like a unit test calling the method handler and validating that result.error is called should be straightforward. Failing that, it seems like an integration test covering this scenario would also be straightforward.

@Cobinja
Copy link
Contributor Author

Cobinja commented May 18, 2021

Is testing of the Android side already available? If so, can you point me to how that's done?
If it's not already available, I think it should be added by someone who knows the testing environment.

@stuartmorgan
Copy link
Contributor

It looks like Android unit tests aren't set up for this plugin yet. Integration tests should be fine for this though.

See https://github.com/flutter/flutter/wiki/Plugin-Tests for pointers to where the test files are and how to run them.

This prevents overwriting a double entry with a string on Android
This adds integration tests for string clashes, but limits them to Android
@Cobinja
Copy link
Contributor Author

Cobinja commented May 20, 2021

Integration test for string clashes are added and succeed

@Cobinja
Copy link
Contributor Author

Cobinja commented May 30, 2021

Resolved a merge conflict that was caused by a different PR/push adding an issue tracker to pubspec.yaml

@stuartmorgan stuartmorgan self-requested a review August 1, 2021 12:02
@@ -1,6 +1,7 @@
## NEXT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be updated to bump the version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in the new commit.

@@ -128,6 +128,15 @@ class SharedPreferences {
_setValue('Double', key, value);

/// Saves a string [value] to persistent storage in the background.
///
/// Note: Due to limitations in Android's SharedPreferences,
/// values cannot start with either one of the following:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: s/either one/any of/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in the new commit.

Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but unfortunately you'll need to merge in the latest master again so that the CI checks will run, due to an infra issue that required updates to in-repo configuration to resolve.

Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@stuartmorgan stuartmorgan added the waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land. label Aug 20, 2021
@fluttergithubbot fluttergithubbot merged commit 5ea96e5 into flutter:master Aug 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes p: shared_preferences platform-android waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land.
Projects
None yet
3 participants