public static void acquire()

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


    public static void acquire(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.addAll(Arrays.asList(holderNames));

                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);
            }
        }


    }