wordpress-mobile / wordpress-fluxc-android Goto Github PK
View Code? Open in Web Editor NEWWordPress Network and Persistence layer based on the Flux architecture
License: GNU General Public License v2.0
WordPress Network and Persistence layer based on the Flux architecture
License: GNU General Public License v2.0
I see this issue occasionally, when running instrumentation tests:
org.greenrobot.eventbus.EventBusException: Invoking subscriber failed
at org.greenrobot.eventbus.EventBus.handleSubscriberException(EventBus.java:505)
at org.greenrobot.eventbus.EventBus.invokeSubscriber(EventBus.java:487)
at org.greenrobot.eventbus.EventBus.postToSubscription(EventBus.java:416)
at org.greenrobot.eventbus.EventBus.postSingleEventForEventType(EventBus.java:397)
at org.greenrobot.eventbus.EventBus.postSingleEvent(EventBus.java:370)
at org.greenrobot.eventbus.EventBus.post(EventBus.java:251)
at org.wordpress.android.stores.Dispatcher.post(Dispatcher.java:46)
at org.wordpress.android.stores.Dispatcher.dispatch(Dispatcher.java:38)
at org.wordpress.android.stores.release.ReleaseStack_PostTestXMLRPC.uploadPost(ReleaseStack_PostTestXMLRPC.java:167)
at org.wordpress.android.stores.release.ReleaseStack_PostTestXMLRPC.testEditingRemotePost(ReleaseStack_PostTestXMLRPC.java:82)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1879)
Caused by: java.lang.IllegalStateException: Cannot perform this operation because the connection pool has been closed.
at android.database.sqlite.SQLiteConnectionPool.throwIfClosedLocked(SQLiteConnectionPool.java:962)
at android.database.sqlite.SQLiteConnectionPool.waitForConnection(SQLiteConnectionPool.java:599)
at android.database.sqlite.SQLiteConnectionPool.acquireConnection(SQLiteConnectionPool.java:348)
at android.database.sqlite.SQLiteSession.acquireConnection(SQLiteSession.java:894)
at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:834)
at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:143)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132)
at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:219)
at android.database.AbstractCursor.moveToNext(AbstractCursor.java:268)
at com.yarolegovich.wellsql.SelectQuery.getAsModel(SelectQuery.java:151)
at com.yarolegovich.wellsql.SelectQuery.getAsModel(SelectQuery.java:144)
at org.wordpress.android.stores.network.HTTPAuthManager.getHTTPAuthModel(HTTPAuthManager.java:27)
at org.wordpress.android.stores.network.BaseRequest.setHTTPAuthHeaderOnMatchingURL(BaseRequest.java:33)
at org.wordpress.android.stores.network.xmlrpc.BaseXMLRPCClient.setRequestAuthParams(BaseXMLRPCClient.java:58)
at org.wordpress.android.stores.network.xmlrpc.BaseXMLRPCClient.add(BaseXMLRPCClient.java:43)
at org.wordpress.android.stores.network.xmlrpc.post.PostXMLRPCClient.pushPost(PostXMLRPCClient.java:324)
at org.wordpress.android.stores.store.PostStore.onAction(PostStore.java:319)
at org.greenrobot.eventbus.EventBus.invokeSubscriber(EventBus.java:485)
... 20 more
In this case the failing test was during a post test, but I've seen it happen with other instrumentation tests. The test was dispatching a PUSH_POST
action.
I've gone many days of running integration tests without seeing this error, and then I'll get it a few times in a row. Usually running 'Clean project' solves it, but not always.
See how it's done in wpandroid
And pull the login url from REST and XMLRPC APIs (options->login_url in REST)
Send modified settings / account to the server, not sure about the action names (POST_
).
Model
objects should ever be instantiated - they should only come by requesting them from their corresponding Store
Store
s can be referenced directly, but only for read-only operations; all modifications must be done through Action
sEventually call it as a commit hook - so we won't have any formatting issues
AccountStore.isSignedIn() should return true if user has an auth token OR a visible site (.org or .com).
And fetch it from getOptions
call. It's used by stats here.
Looks like this might be the underlying cause of #92. It seems that while all DB calls are transaction-wrapped and thus thread-safe, it might be possible that two concurrent calls to WellSql
can lead to a situation where one completes and closes the thread while the other is waiting, causing an IllegalStateException
(Cannot perform this operation because the connection pool has been closed.) when the second thread attempts to act on a closed DB.
It's possible that the problem is only applicable to tests (the instrumentation test thread has some threading limitations, e.g. a new Handler
can't be started off the instrumentation thread). We'll need to test and find the extent of the problem.
Do it before the project is too big and full of styling errors
https://docs.gradle.org/current/userguide/checkstyle_plugin.html
So we can pass it from activities to activities / fragments instead of an abstract "local blog id".
FATAL EXCEPTION: main
Process: org.wordpress.android.stores.example, PID: 2731
java.lang.NumberFormatException: Invalid long: "null"
at java.lang.Long.invalidLong(Long.java:124)
at java.lang.Long.parseLong(Long.java:345)
at java.lang.Long.parseLong(Long.java:321)
at java.lang.Long.valueOf(Long.java:511)
at org.wordpress.android.stores.network.xmlrpc.site.SiteXMLRPCClient.updateSiteFromOptions(SiteXMLRPCClient.java:145)
at org.wordpress.android.stores.network.xmlrpc.site.SiteXMLRPCClient.access$200(SiteXMLRPCClient.java:27)
at org.wordpress.android.stores.network.xmlrpc.site.SiteXMLRPCClient$3.onResponse(SiteXMLRPCClient.java:86)
at org.wordpress.android.stores.network.xmlrpc.XMLRPCRequest.deliverResponse(XMLRPCRequest.java:53)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
To allow users to sign up and create new sites. See https://github.com/wordpress-mobile/WordPress-Android/blob/23d7d289e2c0b39d70008a6bddad8ce182eeb814/WordPress/src/main/java/org/wordpress/android/ui/accounts/helpers/CreateUserAndBlog.java#L125-L137
It's currently not fetched from the REST API.
Only for wp.com sites
Tried to build and had to modify existing build.properties in order to even forward the import. Modified it to this and it's now spitting out this error.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.android.tools.build:gradle:2.2.0-alpha1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apply plugin: 'com.android.library'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'com.github.dcendents.android-maven'
repositories {
jcenter()
}
android {
publishNonDefault true
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
versionCode 4
versionName "0.1"
minSdkVersion 14
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
warning 'InvalidPackage'
}
}
dependencies {
// Support libs
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
// WordPress libs
compile ('org.wordpress:utils:1.8.0') {
// Using official volley package
exclude group: "com.mcxiaoke.volley";
}
// Custom WellSql version
compile 'org.wordpress:wellsql:1.0.6'
apt 'org.wordpress:wellsql-processor:1.0.6'
// External libs
compile 'com.squareup:otto:1.3.8'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.squareup.okhttp3:okhttp-urlconnection:3.2.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.code.gson:gson:2.4'
compile 'com.google.dagger:dagger:2.0.2'
apt 'com.google.dagger:dagger-compiler:2.0.2'
provided 'org.glassfish:javax.annotation:10.0-b28'
}
version android.defaultConfig.versionName
group = "org.wordpress"
archivesBaseName = "stores"
We're currently using metaWeblog
methods in several places (getting posts, editing posts, creating new posts) that since have equivalent wp
methods. We should switch over to wp
where feasible (or document why we're keeping metaWeblog
where not feasible).
Looking at the APIs doc and code, it's not obvious media ids are long or string. We should make sure to pick the correct type.
When we switched from Otto bus to EventBus in #61 - I thought the default mode was "Background" but it's actually "Posting". We might want to run all our actions in one (or multiple) background thread(s).
that deletes all account infos (and auth token).
Test site was: https://dh.wpmt.co
java.lang.NullPointerException
at org.wordpress.android.stores.network.xmlrpc.site.SiteXMLRPCClient.updateSiteFromOptions(SiteXMLRPCClient.java:144)
at org.wordpress.android.stores.network.xmlrpc.site.SiteXMLRPCClient.access$200(SiteXMLRPCClient.java:27)
at org.wordpress.android.stores.network.xmlrpc.site.SiteXMLRPCClient$3.onResponse(SiteXMLRPCClient.java:86)
at org.wordpress.android.stores.network.xmlrpc.XMLRPCRequest.deliverResponse(XMLRPCRequest.java:52)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Example actions:
FETCH_X - request fetch from the server
UPDATE_X - local change
REMOVE_X - local remove
DELETE_X - request deletion on the server
Example events:
onXRemoved(int n) - Keep X singular even if multiple X were removed
This has been implemented in WPAndroid: wordpress-mobile/WordPress-Android#3568
We're sending generic events to the dispatcher, some of them can make network calls. Clients should subscribe to network (or other kind of) errors occurring if an event fails to emit a OnChanged() event.
We'll need to implement our own version of WordPressDB.dangerouslyDeleteAllContent as part of the sign out flow.
Transform Volley into Offhand Volley and ignore cache control headers on REST and XMLRPC calls.
Needed in wpandroid
add a maxImageWidth field to SiteModel, I'm not sure if this field exists (and if there is a limit on .com sites).
We should use other events (not actions) and eventually a different bus for "wpstores confined actions" for instance:
FETCHED_SETTINGS
, FETCHED_ACCOUNT
, POSTED_SETTINGS
, etc... (generally looks like callback not actions)
Write some simple apps to demonstrate the ease of use of FluxC, for instance:
We're currently using siteId + site url as identifiers, but I think we might encounter problems if a .org site install jetpack and gets refreshed in the app.
See this note in code.
We need to setup these sites first.
FATAL EXCEPTION: main
Process: org.wordpress.android.beta, PID: 2272
java.lang.NullPointerException: Attempt to read from field 'byte[] com.android.volley.NetworkResponse.data' on a null object reference
at org.wordpress.android.stores.network.rest.wpcom.account.AccountRestClient$8.onErrorResponse(AccountRestClient.java:184)
at com.android.volley.Request.deliverError(Request.java:590)
at org.wordpress.android.stores.network.rest.wpcom.WPComGsonRequest.deliverError(WPComGsonRequest.java:49)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:101)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5422)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Apparently comes from an AppLog call.
Currently, HTTP
>HTTPS
(presumably also HTTP
>HTTP
) redirects are followed, but there's an issue when POST
ing to XML-RPC
: the POST
isn't re-submitted, and a GET
request is made instead, which results in a 405
error.
This is following HTTP guidelines, which try to limit cases of submitting multiple POST
s, or submitting POST
s to other URLs, without the user's explicit consent.
On WPAndroid we probe for the rsd
file with GET
first. We should do the same for Stores, as we improve XML-RPC endpoint discovery in general (see #4).
And store the array for post formats in SiteModel
So we should move them out the AccountStore
- maybe have another way to broadcast events from wpstores to the app for this kind of generic errors (auth error, timeout, etc.).
With the way Actions are currently structured, there's no simple way to know when calling Dispatcher.createAction
if a certain action needs a payload attached, and what type the payload should be.
One idea would be to create an annotation that generates a ThingActionBuilder
(working title) for every item in aThingAction
enum. The annotation declares whether the item needs to be accompanied by a payload, and what type that payload should take. Then, instead of calling Dispatcher.createAction(ThingAction.FETCH_THINGS, arbitraryPayload)
, we would have to call something like Dispatcher.createAction(ThingActionBuilder.createFetchThingsAction(stronglyTypedPayload))
.
Before sinking time into this, we could try manually creating ThingActionBuilder
and make sure it would actually make things simpler/clearer.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.