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 8920391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:15:29+00:00 2026-06-15T06:15:29+00:00

We have a class Document which uses a private member of type Map<String, Object>

  • 0

We have a class Document which uses a private member of type Map<String, Object> as storage. Objects of this type are kept in memory and are (very frequently) modified by (potentially) multiple threads. It also happens that these objects (or, specifically the underlying Maps) are serialized out over HTTP on request. The serialization format is Json, and the library in use is currently Google’s Gson

When serialization occurs simultaneously as a modification that introduces a new Map.Entry we see ConcurrentModificationExceptions. This makes a lot of sense intuitively, since Gson is probably iterating over the entrySet which is being modified.

How can we avoid this? Do we need to resort to always passing a deep copy of the Map to Gson? In that case, how would you implement said deep copy, given that the map can contain all Json primitives, including List and Map?

  • 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-15T06:15:30+00:00Added an answer on June 15, 2026 at 6:15 am

    While I question the wisdom of serializing an object that is being updated so often, using a ConcurrentHashMap should at least alleviate your concurrency issues.

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

Sidebar

Related Questions

I have three models: class User include Mongoid::Document field :name, :type => String has_many
I have model: # encoding: utf-8 class Tag include Mongoid::Document field :name, type: String
Problem: I have a document class which contains a list of objects. These objects
I have a class which contains this method /** * Uses the native RegExp
I have a model: class SimpleAction include Mongoid::Document field :set_date, :type => Date and
I have a relationship like this class User include Mongoid::Document include Mongoid::Timestamps embeds_one :setting
I have a Greasemonkey script which uses jQuery and detects if a class is
I have written a program which uses a SQL exception class and then use
I have a Document class, Intro class and Nav class. The Intro class runs
Possible Duplicate: How to Deserialize XML document Suppose that I have a class that

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.