public static boolean release()

in src/main/java/org/apache/sling/distribution/packaging/impl/DistributionPackageUtils.java [392:431]


    public static boolean release(File file, @NotNull String[] holderNames) throws IOException {
        if (holderNames.length == 0) {
            throw new IllegalArgumentException("holder name cannot be null or empty");
        }

        synchronized (filelock) {
            ObjectInputStream inputStream = null;
            ObjectOutputStream outputStream = null;
            try {

                HashSet<String> set;

                if (file.exists()) {
                    inputStream = getSafeObjectInputStream(new FileInputStream(file));
                    @SuppressWarnings("unchecked") //type is known by design
                    HashSet<String> fromStreamSet = (HashSet<String>) inputStream.readObject();
                    set = fromStreamSet;
                } else {
                    set = new HashSet<String>();
                }

                set.removeAll(Arrays.asList(holderNames));

                if (set.isEmpty()) {
                    FileUtils.deleteQuietly(file);
                    return true;
                }

                outputStream = new ObjectOutputStream(new FileOutputStream(file));
                outputStream.writeObject(set);
            }
            catch (ClassNotFoundException e) {
                log.error("Cannot release file", e);
            } finally {
                IOUtils.closeQuietly(inputStream);
                IOUtils.closeQuietly(outputStream);
            }
        }
        return false;
    }