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

Reloader doesn't work with ConcurrentMap #236

Closed
tschuehly opened this issue Jul 4, 2024 · 2 comments
Closed

Reloader doesn't work with ConcurrentMap #236

tschuehly opened this issue Jul 4, 2024 · 2 comments

Comments

@tschuehly
Copy link

Environment Details

  • EclipseStore Version: 1.3.2 && 2.0.0-SNAPSHOT
  • JDK version: openjdk-22
  • OS: Windows 10
  • Used frameworks: e.g. MicroFramework X, Spring, ...

Describe the bug

I want to reload the graph from storage in my tests to check if we persist stuff correctly.
I wanted to use the Reloader for that. We are using a ConcurrentHashMap in our Root Object:

final Map<Class<? extends Test>, Map<UUID, Test>> testMap = new ConcurrentHashMap<>();

static class Test{}

static class Item extends Test{
    public final UUID uuid = UUID.randomUUID();
    public String string;

    public Item(String string) {
        this.string = string;
    }
}

But when reloading the root with reloader.reloadDeep it doesn't load the items from storage.

Number of items in list: 1
Number of items in list after clear: 0 (surprise :) )
Number of items in list after reload: 0
[]

I created a reproducer here:
tschuehly@828119b#commitcomment-143840312

@hg-ms
Copy link
Contributor

hg-ms commented Jul 5, 2024

Hi,
thanks for the reproducer, it simplifies a lot.

When you use the eager storer instance to store the map after adding an item you need to call the storers commit method to persist that change. Just call commit() after the store:

 map.put(item.uuid, item);
 var storer = storageManager.createEagerStorer();
 storer.store(map);
 storer.commit();

@tschuehly
Copy link
Author

@hg-ms
Thank you for the quick response. I wish I could read, it's clearly in the docs O.o
Works now

@hg-ms hg-ms closed this as completed Sep 3, 2024
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