Persistence broke

13 views
Skip to first unread message

Rick Mann

unread,
Oct 7, 2016, 6:48:51 AM10/7/16
to Baratine
I've been building up a simple @Service. It has a HashMap of <String,User>, that was originally declared like this:

HashMap<String, User> users = new HashMap<String, User>();

I referred to it as this.users in my code, and everything was working fine. I added @Asset to my @Service, and was very pleased to see everything magically persist across re-launches of my server.

Then I spent some fruitless hours trying to get YAML configuration to work. Somewhere in there, I renamed "this.users" to "mUsers" but otherwise left the declaration the same (notably, it has the initializer you see).

Now when I run, mUsers is null, and my code throws an exception. If I remove @Asset from the @Service, it works fine. But with @Asset, it's always null.

So, how do I fix this? I thought I might be able to delete the persistent store and start over, but I can't find the files. Where are those written?

Why did the name change affect things like this? Shouldn't it just look like a new member variable to persist?

Thanks,

--
Rick Mann
rm...@latencyzero.com


Alex Rojkov

unread,
Oct 7, 2016, 11:24:52 AM10/7/16
to Rick Mann, Baratine
When you change field name the old value is no longer connected to
that field. Deleting the folder with data will reset the state.

System property "baratine.root" effectively sets data folder. By
default it's in a tmp directory which Baratine outputs on startup:

WebServerImpl: baratine.root = /var/folders/x2/6ldtrkbn32sfklb796xdcm7m0000gn/T
> --
> You received this message because you are subscribed to the Google Groups "Baratine" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to baratine-io...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Message has been deleted

Rick Mann

unread,
Oct 7, 2016, 6:42:00 PM10/7/16
to Alex Rojkov, Baratine
Ah, that was the missing piece of info, the path. I didn't even notice it in the startup log; kept looking in the working directory for it.

I get why it disconnected because of the name change, but I'm worried that it didn't just start over with empty data. It was null, rather than initialized. If I add new fields, will they get picked up?
--
Rick Mann
rm...@latencyzero.com


Alex Rojkov

unread,
Oct 7, 2016, 7:13:55 PM10/7/16
to Rick Mann, Baratine
The new fields will be saved. The renamed field (mUsers) will be saved
once it gets initialized. The old data for .users will be discarded.

Alex

Rick Mann

unread,
Oct 7, 2016, 7:17:30 PM10/7/16
to Alex Rojkov, Baratine
That's not the behavior I experienced. The new field mUsers is always null. It's not even initialized to the empty HashMap.
--
Rick Mann
rm...@latencyzero.com


Alex Rojkov

unread,
Oct 7, 2016, 7:18:36 PM10/7/16
to Rick Mann, Baratine
Right, because the record for the service is loaded from the database
as a map of fields and in that map mUsers field is null.
Reply all
Reply to author
Forward
0 new messages