From 1dd0737b4535e252db7f13e479cf3866345d8f21 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Thu, 7 Dec 2017 23:34:43 -0500 Subject: [PATCH] Resolve Java 6/7/8 concurrent map compatibility & cleanup imports for Android MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FIXES litehelpers/Cordova-sqlite-storage#726 (keySet error) THANKS to @NeoLSN (Jason Yang/楊朝傑) for pointer to the solution in litehelpers/Cordova-sqlite-storage#727 --- CHANGES.md | 4 ++-- README.md | 1 + package.json | 2 +- plugin.xml | 2 +- src/android/io/sqlc/SQLitePlugin.java | 28 +++++++++++++++++---------- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b21ae4104..43e2cf8fe 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,8 @@ # Changes -###### cordova-sqlite-legacy-express-core 1.0.3-pre01 +###### cordova-sqlite-legacy-express-core 1.0.3 -TBD +- Resolved Java 6/7/8 concurrent map compatibility issue reported in litehelpers/Cordova-sqlite-storage#726, THANKS to pointer by @NeoLSN (Jason Yang/楊朝傑) in litehelpers/Cordova-sqlite-storage#727. ###### cordova-sqlite-legacy-express-core 1.0.2 diff --git a/README.md b/README.md index aa82691de..378d8b638 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase ## Announcements +- Resolved Java 6/7/8 concurrent map compatibility issue reported in [litehelpers/Cordova-sqlite-storage#726](https://github.com/litehelpers/Cordova-sqlite-storage/issues/726), THANKS to pointer by [@NeoLSN (Jason Yang/楊朝傑)](https://github.com/NeoLSN) in [litehelpers/Cordova-sqlite-storage#727](https://github.com/litehelpers/Cordova-sqlite-storage/issues/727). - Fixed iOS/macOS platform version to use [PSPDFThreadSafeMutableDictionary.m](https://gist.github.com/steipete/5928916) to avoid threading issue ref: [litehelpers/Cordova-sqlite-storage#716](https://github.com/litehelpers/Cordova-sqlite-storage/issues/716) - Resolved transaction problem after window.location (page) change with possible data loss ref: [litehelpers/Cordova-sqlite-storage#666](https://github.com/litehelpers/Cordova-sqlite-storage/issues/666) - [brodybits / cordova-sqlite-test-app](https://github.com/brodybits/cordova-sqlite-test-app) project is a CC0 (public domain) starting point (NOTE that this plugin must be added) and may also be used to reproduce issues with this plugin. diff --git a/package.json b/package.json index 4d3f8ba77..a8fa46d87 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-sqlite-legacy-express-core", - "version": "1.0.3-pre01", + "version": "1.0.3", "description": "Native interface to SQLite for PhoneGap/Cordova (legacy express core version)", "cordova": { "id": "cordova-sqlite-legacy-express-core", diff --git a/plugin.xml b/plugin.xml index b196fa4c9..11689aa60 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.0.3"> Cordova sqlite storage plugin - legacy express core version diff --git a/src/android/io/sqlc/SQLitePlugin.java b/src/android/io/sqlc/SQLitePlugin.java index 9ad6d49e4..f4fb74cf8 100755 --- a/src/android/io/sqlc/SQLitePlugin.java +++ b/src/android/io/sqlc/SQLitePlugin.java @@ -8,15 +8,18 @@ import android.annotation.SuppressLint; -import android.util.Base64; import android.util.Log; import java.io.File; + import java.lang.IllegalArgumentException; import java.lang.Number; -import java.util.concurrent.ConcurrentHashMap; + +import java.util.Map; import java.util.concurrent.BlockingQueue; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.LinkedBlockingQueue; + import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -27,19 +30,24 @@ import org.json.JSONException; import org.json.JSONObject; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.IOException; - public class SQLitePlugin extends CordovaPlugin { /** * Multiple database runner map (static). - * NOTE: no public static accessor to db (runner) map since it would not work with db threading. - * FUTURE put DBRunner into a public class that can provide external accessor. + * + * NOTE: no public static accessor to db (runner) map since it is not + * expected to work properly with db threading. + * + * FUTURE TBD put DBRunner into a public class that can provide external accessor. + * + * ADDITIONAL NOTE: Storing as Map to avoid portabiity issue + * between Java 6/7/8 as discussed in: + * https://gist.github.com/AlainODea/1375759b8720a3f9f094 + * + * THANKS to @NeoLSN (Jason Yang/楊朝傑) for giving the pointer in: + * https://github.com/litehelpers/Cordova-sqlite-storage/issues/727 */ - static ConcurrentHashMap dbrmap = new ConcurrentHashMap(); + static Map dbrmap = new ConcurrentHashMap(); /** * NOTE: Using default constructor, no explicit constructor.