Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8233273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:04:31+00:00 2026-06-07T18:04:31+00:00

Sometimes (when I perform stress test) the object stored in memcache is corrupted (it

  • 0

Sometimes (when I perform stress test) the object stored in memcache is corrupted (it lacks a property and when I try to access it gives me “NullPointerException”).
Could it be related to wrong synchronization between different memcache writes? In fact in different part of my code I just update the UserAccount stored in Memcache in this way:

cache.put(tempUser.getKey(), tempUser);

.. and I try to retrieve in this way:

if (cache.contains(key)) {
    readObject = (T) cache.get(key);
    return readObject;
}

Related to this retrieving I get NullPointerException, when I try (for exampple) to retrieve:

readObject.getMyProperty()

I tried to understand this feature (https://developers.google.com/appengine/docs/java/memcache/overview#Safely_Handling_Concurrent_Memcache_Updates), but it doens’t seem very well documented.
I also had a look to these answers on stackoverflow:

  • GAE MemCache behaviour of put() + ADD_ONLY_IF_NOT_PRESENT
  • Safely Handling Concurrent Memcache Updates in AppEngine

.. but it doesn’t seem realated to my needs.
At the end I just need to be sure a value is well stored in the cache, without the risk of race condition could affect its integrity.

================================================================================
UPDATE:
I try to specify better the behaviour: I get “NullPointerException” in this row:

if(readObject!=null && readObject.getMyProperty.equals("test"))

so that it is not (only) totally null, but just a property. It seems really to be corrupted. Apart from that I know I have to improve the retrieve phase!

================================================================================

NEW UPDATE: I found the object in memcache with all the properties equals to null, apart from the key one

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:04:32+00:00Added an answer on June 7, 2026 at 6:04 pm

    Between the call to cache.contains() and cache.get() your entry may get evicted from memcache. A solution would be to just call cache.get() and check for a null result in which case the entry isn’t there anymore. You even save some milliseconds for the unneeded call. Never rely on an unchanged state between calls. Instead memcache gives you helpful atomic compound operations to avoid race condition like increment(), putIfUntouched() and put()+ADD_ONLY_IF_NOT_PRESENT.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I perform an asynchronous request with jQuery Ajax, sometimes the response is returned
Sometimes I need to perform a rebuild of my project but I don't want
Sometimes I feel the desire of mocking the subject under test itself, I know
Sometimes we need to perform small administrative tasks in SharePoint. A simple PowerShell script
When you perform ls in a bash shell, sometimes there are colours to indicate
I know Oracle sometimes judges that it's better to perform full table scan as
I am sometimes receiving the following exception when attempting to deserialise an object using
Sometimes I need to perform following command cp -rv demo demo_bkp However I want
Sometimes I want to perform a function (eg difference calculation) on a dataset and
I have a service listening to github service hooks, to perform automatic deployment. Sometimes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.