Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache problem with null values #42

Closed
MFlisar opened this issue Jan 16, 2017 · 3 comments
Closed

Cache problem with null values #42

MFlisar opened this issue Jan 16, 2017 · 3 comments

Comments

@MFlisar
Copy link

MFlisar commented Jan 16, 2017

With cache enabled, generated code may look like following:

 @Override
  public DataManager.ExistingDataSources existingDataSources() {
	DataManager.ExistingDataSources __result = (DataManager.ExistingDataSources) cache.get("existingDataSources");
	if (__result == null) {
	  Serializer __serializer = Esperandro.getSerializer();
	  __result = __serializer.deserialize(preferences.getString("existingDataSources", null), com.michaelflisar.gallery.data.DataManager.ExistingDataSources.class);
	  cache.put("existingDataSources", __result);;
	}
	return __result;
  }

This is a custom serialisable field of mine, the problem is, if it is not initialised or is null, the cache.put("existingDataSources", __result);; will throw a java.lang.NullPointerException: key == null || value == null exception.

Can this be changed to allow null values? Any reasons, why this is not possible yet?

Btw, the code generator is generating double ; as you can see in my code example... Not a big deal though, so I'm just mentioning it here...

PS: currently I'm using following version:

compile 'de.devland.esperandro:esperandro-api:2.3.1'
apt 'de.devland.esperandro:esperandro:2.3.1'
@dkunzler
Copy link
Owner

I will release a fix tomorrow.

@MFlisar
Copy link
Author

MFlisar commented Jan 17, 2017

Thanks

@dkunzler
Copy link
Owner

2.4.0 should be available in maven central in a few hours.
Cached and GenerateStringResource Annotations moved to experimental package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants