public Resource.Lock acquire(String lockKey) { final int idx = getIndex(lockKey); locks[idx].lock(); return new Resource.Lock() { boolean released = false; public void release() { if (!released) { released = true; locks[idx].unlock(); } } public String toString() { return "MemoryLock " + idx; } }; }
@Test public void testInitLoggingLock() throws Exception { final File target = new File("./target"); FileUtils.deleteQuietly(new File(target, "logs")); GeoServerResourceLoader loader = new GeoServerResourceLoader(target); FileSystemResourceStore store = (FileSystemResourceStore) loader.getResourceStore(); store.setLockProvider(new MemoryLockProvider()); // make it copy the log files LoggingUtils.initLogging(loader, "DEFAULT_LOGGING.properties", false, null); // init once from default logging LoggingUtils.initLogging(loader, "DEFAULT_LOGGING.properties", false, null); // init twice, here it used to lock up LoggingUtils.initLogging(loader, "DEFAULT_LOGGING.properties", false, null); } }
public Resource.Lock acquire(final String lockKey) { final Resource.Lock memoryLock = memoryProvider.acquire(lockKey);
@Test public void testParseStyleTwiceLock() throws Exception { StyleInfo style = getCatalog().getStyles().get(0); FileSystemResourceStore store = (FileSystemResourceStore) getDataDirectory().getResourceStore(); store.setLockProvider(new MemoryLockProvider()); // parse twice to check we are not locking on it Resource resource = getDataDirectory().style(style); Styles.handler(style.getFormat()) .parse(resource, style.getFormatVersion(), new DefaultResourceLocator(), null); Styles.handler(style.getFormat()) .parse(resource, style.getFormatVersion(), new DefaultResourceLocator(), null); }