From cbd4c084eaade252f637d69222f63e1aec4430a8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 20 Oct 2013 02:32:09 +0200 Subject: [PATCH] Fix synchronisation. --- .../net/pterodactylus/sone/database/memory/MemoryDatabase.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java index 8c5c64f..8817016 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java +++ b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java @@ -218,7 +218,12 @@ public class MemoryDatabase extends AbstractService implements Database { @Override public Sone build(Optional soneCreated) throws IllegalStateException { Sone sone = super.build(soneCreated); - sones.put(sone.getId(), sone); + lock.writeLock().lock(); + try { + sones.put(sone.getId(), sone); + } finally { + lock.writeLock().unlock(); + } return sone; } }; -- 2.7.4