feat(furnidata): shared lock serializing watcher reindex and editor writes

This commit is contained in:
simoleo89
2026-06-06 01:57:48 +02:00
parent 258a95a269
commit caf6ad35fa
2 changed files with 35 additions and 17 deletions
@@ -0,0 +1,13 @@
package com.eu.habbo.habbohotel.items;
import java.util.concurrent.locks.ReentrantLock;
/**
* One process-wide lock serializing every furnidata reindex and every editor-driven
* furnidata write, so an editor write never races the file watcher's reindex and the
* volatile index is never observed mid-swap by two writers.
*/
public final class FurnidataLock {
public static final ReentrantLock LOCK = new ReentrantLock();
private FurnidataLock() {}
}
@@ -116,6 +116,8 @@ public class FurnidataWatcher {
}
private void onChange() {
FurnidataLock.LOCK.lock();
try {
Path source = this.provider.getSource();
if (source == null) return;
@@ -136,6 +138,9 @@ public class FurnidataWatcher {
broadcast(composer);
LOGGER.info("FurnidataWatcher: broadcast {} ({} entries)",
delta.size() > this.deltaCap ? "reload-hint" : "delta", delta.size());
} finally {
FurnidataLock.LOCK.unlock();
}
}
private void broadcast(FurnitureDataReloadComposer composer) {