8000 Enums are incorrectly treated upon database load · Issue #372 · eclipse-store/store · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Enums are incorrectly treated upon database load #372
Open
@Bios-Marcel

Description

@Bios-Marcel

Environment Details

  • EclipseStore Version: 2.1.1
  • JDK version: 21
  • OS: Windows 11

Describe the bug

Enums seem to be persisted the first time they are encountered, not reflecting any changes on the enum fields.

I have an enum in which I have a collection. I added an item to the collection, but at runtime, its the old collection, without the added item.

If I print it first thing in main, it shows the new value. Once EclipseStore started up, the enum values were replaced with the persisted ones it seemed.

To Reproduce

import org.eclipse.store.storage.embedded.types.EmbeddedStorage;

import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

public class BugMain {
    enum EnumA {
        A1(List.of(EnumB.B1, EnumB.B2)),
        A2(List.of(EnumB.B1 /*, EnumB.B2 UNCOMMENT AFTER FIRST STARTT */)),
        ;
        final List<EnumB> enumBs;

        EnumA(List<EnumB> enumBs) {
            this.enumBs = new ArrayList<>(enumBs);
        }
    }

    enum EnumB {
        B1,
        B2,
        ;
    }

    static class Root {
        EnumA a = null;
    }

    public static void main(String[] args) {
        System.out.println("Before: " + EnumA.A2.enumBs);
        final var manager = EmbeddedStorage.start(Paths.get("./temp_db"));
        if (manager.root() == null) {
            Root newRoot = new Root();
            newRoot.a = EnumA.A2;
            manager.setRoot(newRoot);
            manager.storeRoot();
        }
        System.out.println("After: "+ EnumA.A2.enumBs);

    }
}
  1. Start once
  2. Uncomment EnumA.A2.B2
  3. Start again
  4. Enum is incorrect

Expected behavior

Enum values should always represent the same state as they did before restoring eclipse store data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0