From: David ‘Bombe’ Roden Date: Sun, 20 Oct 2013 00:32:09 +0000 (+0200) Subject: Fix synchronisation. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=cbd4c084eaade252f637d69222f63e1aec4430a8;p=Sone.git Fix synchronisation. --- 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; } };