android


Gson fromJson parsing a list sometimes returning null


I have an application communicating to a server through Json data. Sometimes the server answers back with a list of objects and the application parses the json string using the syntax :
List<My_Object_Type> list = new Gson().fromJson(json, new TypeToken<List<My_Object_Type>>() {}.getType());
Through my application log, i always print what the server answer in order to be able to check if everything is correct and diagnosis errors. Thus i'm able to see if the gson syntax is correct, if the server encountered a problem or...
The application works fine, almost 99% of the time, but in the little 1% remaining the json List is null. And that's not even a problem about the data structure, neither the json String because in the same application log i saw the exact same json line in the exact same query being answered, and there was no problem.
Question : if the gson deserialization is called on another Thread (asynTask), could it lead to it to fail deserializing ? I dont see any reason why the first call works, the second one too, but not the third one.
In order to further get any problem, I copy/past the Json string and directly called the deserialization through the exact same call (also copy/pasted)... And it worked.
Worked first --> no data structure error
Worked with copy/pasted string --> No string error
what could be other problems with deserialization ?
PS: I read other questions leading to "wrong json string" or "wrong object structure" and it seems not being the case as it worked with the exact same string before.... Of course, I could deal with the null variable and prevent problems, but as it does not take data sent by the server it may lead to inappropriate behaviors....

Related Links

Android - Dynamically change language
Showing notification to user at specific time, but it appears every time when i closed or open my application?
Add shadow on right and bottom side of the layout
ndk-gdb with gradle flavor
Android Dual Pane - Going From Details To List
Is there any method to check Appium android Listview Scrollable property for true or false
Maintaining backward compatibility with Material Design
handler.removeCallbacksAndMessages not working
How to send mutiple text messages from an android app?
How to access chrome developer tools for an android device connected to a remote machine?
Android facebook button loginfacebook setReadPermissions no action
How to insert CSV file into SQLite database on android?
Android - Support Multilanguage app in a ViewPager
Why my listview inside fragment is not filtering
Android RecyclerView Edittext issue
Example of implementing ViewHolder with multiple layouts

Categories

HOME
uml
algorithm
phantom-dsl
twitter-bootstrap-3
api
webdriver
angular-formly
apache-spark-mllib
serialization
components
solver
spring-data-redis
can
grafana
tivoli
square
hpc
pearson-correlation
jquery-ui
spring-session
trac
discrete-mathematics
teechart
accessibility
jquery-ui-sortable
watson-conversation
php-5.6
zerobrane
3nf
package-managers
modbus-tcp
azure-iot-hub
null-pointer
android-7.0-nougat
sigma.js
bourbon
string-concatenation
roslyn
resourcebundle
custom-post-type
rpgle
exchangewebservices
openmdao
iis-express
carrierwave
ntp
installshield-le
browser-extension
mnist
numpy-broadcasting
jvmti
dcmtk
attributeerror
portforwarding
monkey-testing
procfile
openresty
linter
rserve
zenhub
static-cast
gameplay-kit
change-tracking
stripe-connect
chromium-os
simplepie
angular2-testing
flex-monkey
adafruit
uicolor
omniauth-facebook
project-organization
uiactionsheet
grass
mobiledoc-kit
user-management
directdraw
grgit
java-money
xenomai
rewrite
extjs-grid
sha512
sql-server-data-tools
linked-tables
graphics2d
cwrsync
ghcjs
sonarqube-5.0
cbind
reflector
terminate
maven-scm
cfcache
amslidemenu
scriptaculous
away3d
jeromq
time.h
node-blade
fb.ui
argouml
usertype
urlrewriter
exponentiation
ie-compatibility-mode
maven-1
easyb
nstokenfield
django-piston
tui
todos
movieplayer

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App