public boolean removeScript()

in src/main/java/org/apache/sling/scripting/core/impl/ScriptCacheImpl.java [100:125]


    public boolean removeScript(final String scriptPath) {
        writeLock.lock();
        try {
            boolean result = internalMap.remove(scriptPath) != null;
            if (result) {
                logger.debug("Removed script {} from script cache.", scriptPath);
            } else {
                // prefix removal
                final String prefix = scriptPath.concat("/");
                final Set<String> removal = new HashSet<>();
                for (final Map.Entry<String, SoftReference<CachedScript>> entry : internalMap.entrySet()) {
                    if (entry.getKey().startsWith(prefix)) {
                        removal.add(entry.getKey());
                    }
                }
                for (final String key : removal) {
                    internalMap.remove(key);
                    logger.debug("Detected removal for {} - removed entry {} from the cache.", scriptPath, key);
                    result = true;
                }
            }
            return result;
        } finally {
            writeLock.unlock();
        }
    }