#vulnerable code 
                                public void adviser(final String pid, final String adviser)
        throws IOException {
        if (!this.exists(pid)) {
            throw new IllegalArgumentException(
                new Par(
                    "Project %s doesn't exist, can't get adviser"
                ).say(pid)
            );
        }
        try (final Item item = this.item()) {
            new Xocument(item.path()).modify(
                new Directives().xpath(
                    String.format(
                        "/catalog/project[@id = '%s']",
                        pid
                    )
                ).addIf("adviser").set(adviser)
            );
        }
    } 
                            #location 7 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                public void adviser(final String pid, final String adviser)
        throws IOException {
        this.checkExist(pid);
        try (final Item item = this.item()) {
            new Xocument(item.path()).modify(
                new Directives().xpath(
                    String.format(
                        "/catalog/project[@id = '%s']",
                        pid
                    )
                ).addIf("adviser").set(adviser)
            );
        }
    }