You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by kr...@apache.org on 2026/08/14 03:17:19 UTC

(opennlp) 01/16: util: General installer for user-supplied third-party resources

This is an automated email from the ASF dual-hosted git repository.

krickert pushed a commit to branch OPENNLP-1909-resource-installer
in repository https://gitbox.apache.org/repos/asf/opennlp.git

commit f8c991ab677a4be624ce086e6d392cfa11d52bb9
Author: Kristian Rickert <kr...@gmail.com>
AuthorDate: Wed Jul 15 13:51:33 2026 -0400

    util: General installer for user-supplied third-party resources
    
    ResourceInstaller fetches a user-chosen location, verifies an optional
    SHA-256 before anything is unpacked, detects the format from bytes, and
    extracts tar.gz and zip archives with path-escape rejection; plain gzip
    and raw files store under their source names. Nothing is bundled and no
    location is built in, so externally licensed data stays entirely
    outside the distribution. The tar plumbing moves to an internal reader
    shared with the dictionary installer.
---
 .../java/opennlp/tools/util/ResourceInstaller.java | 239 +++++++++++++++++++++
 .../java/opennlp/tools/util/archive/TarStream.java | 204 ++++++++++++++++++
 .../opennlp/tools/util/ResourceInstallerTest.java  | 168 +++++++++++++++
 3 files changed, 611 insertions(+)

diff --git a/opennlp-core/opennlp-runtime/src/main/java/opennlp/tools/util/ResourceInstaller.java b/opennlp-core/opennlp-runtime/src/main/java/opennlp/tools/util/ResourceInstaller.java
new file mode 100644
index 000000000..739833634
--- /dev/null
+++ b/opennlp-core/opennlp-runtime/src/main/java/opennlp/tools/util/ResourceInstaller.java
@@ -0,0 +1,239 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package opennlp.tools.util;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import opennlp.tools.util.archive.TarStream;
+
+/**
+ * Fetches a user-chosen third-party resource, a training corpus, a dictionary archive,
+ * a lexicon, into a local directory. The user supplies the location and thereby
+ * accepts that resource's license; nothing is bundled and no location is built in,
+ * which keeps externally licensed data entirely outside this library's distribution.
+ *
+ * <p>An optional SHA-256 checksum is verified against the downloaded bytes before
+ * anything is unpacked, so a corrupted or substituted archive fails loud without side
+ * effects. The content format is detected from the bytes, not the name: gzip-compressed
+ * tar archives and zip archives are unpacked with their relative structure, entries
+ * that would escape the target directory are rejected, plain gzip files are
+ * decompressed, and anything else is stored as a file under its source name.</p>
+ *
+ * @see DownloadUtil DownloadUtil, which fetches this project's own published models
+ * @since 3.0.0
+ */
+public final class ResourceInstaller {
+
+  private ResourceInstaller() {
+    // static installer only
+  }
+
+  /**
+   * Fetches and unpacks a resource without checksum verification.
+   *
+   * @param source The resource location. Must not be {@code null}.
+   * @param targetDirectory The directory to install into; created when absent. Must
+   *                        not be {@code null}.
+   * @return The target directory. Never {@code null}.
+   * @throws IOException Thrown if fetching, verification, or unpacking fails.
+   * @throws IllegalArgumentException Thrown if a parameter is {@code null}.
+   */
+  public static Path install(URI source, Path targetDirectory) throws IOException {
+    return install(source, targetDirectory, null);
+  }
+
+  /**
+   * Fetches, verifies, and unpacks a resource.
+   *
+   * @param source The resource location. Must not be {@code null}.
+   * @param targetDirectory The directory to install into; created when absent. Must
+   *                        not be {@code null}.
+   * @param sha256 The expected SHA-256 of the downloaded bytes as a hex string,
+   *               compared case-insensitively, or {@code null} to skip verification.
+   * @return The target directory. Never {@code null}.
+   * @throws IOException Thrown if fetching fails, the checksum does not match, or
+   *         unpacking fails.
+   * @throws IllegalArgumentException Thrown if {@code source} or
+   *         {@code targetDirectory} is {@code null}, or {@code sha256} is blank.
+   */
+  public static Path install(URI source, Path targetDirectory, String sha256)
+      throws IOException {
+    if (source == null || targetDirectory == null) {
+      throw new IllegalArgumentException("source and targetDirectory must not be null");
+    }
+    if (sha256 != null && sha256.isBlank()) {
+      throw new IllegalArgumentException("sha256 must not be blank; pass null to skip");
+    }
+    Files.createDirectories(targetDirectory);
+    final Path downloaded = Files.createTempFile("opennlp-resource", ".download");
+    try {
+      try (InputStream in = source.toURL().openStream()) {
+        Files.copy(in, downloaded, StandardCopyOption.REPLACE_EXISTING);
+      }
+      if (sha256 != null) {
+        verify(downloaded, sha256);
+      }
+      unpack(downloaded, sourceName(source), targetDirectory);
+      return targetDirectory;
+    } finally {
+      Files.deleteIfExists(downloaded);
+    }
+  }
+
+  /** Compares the file's SHA-256 with the expected hex digest. */
+  private static void verify(Path file, String expected) throws IOException {
+    final MessageDigest digest;
+    try {
+      digest = MessageDigest.getInstance("SHA-256");
+    } catch (NoSuchAlgorithmException e) {
+      throw new IOException("SHA-256 is unavailable in this runtime", e);
+    }
+    try (InputStream in = Files.newInputStream(file)) {
+      final byte[] buffer = new byte[8192];
+      int read;
+      while ((read = in.read(buffer)) >= 0) {
+        digest.update(buffer, 0, read);
+      }
+    }
+    final StringBuilder actual = new StringBuilder();
+    for (final byte b : digest.digest()) {
+      actual.append(Character.forDigit((b >> 4) & 0xF, 16))
+          .append(Character.forDigit(b & 0xF, 16));
+    }
+    if (!actual.toString().equalsIgnoreCase(expected.trim())) {
+      throw new IOException(
+          "checksum mismatch: expected " + expected + " but downloaded " + actual);
+    }
+  }
+
+  /** Detects the content format from its leading bytes and unpacks accordingly. */
+  private static void unpack(Path downloaded, String name, Path target)
+      throws IOException {
+    try (InputStream raw = new BufferedInputStream(Files.newInputStream(downloaded))) {
+      raw.mark(2);
+      final int first = raw.read();
+      final int second = raw.read();
+      raw.reset();
+      if (first == 0x1F && second == 0x8B) {
+        unpackGzip(raw, name, target);
+      } else if (first == 'P' && second == 'K') {
+        unpackZip(raw, target);
+      } else {
+        Files.copy(raw, safeChild(target, name), StandardCopyOption.REPLACE_EXISTING);
+      }
+    }
+  }
+
+  /** Unpacks gzip content: a tar archive inside when present, a plain file otherwise. */
+  private static void unpackGzip(InputStream raw, String name, Path target)
+      throws IOException {
+    final BufferedInputStream decompressed =
+        new BufferedInputStream(new GZIPInputStream(raw), 8192);
+    decompressed.mark(512);
+    final boolean tar = looksLikeTar(decompressed);
+    decompressed.reset();
+    if (tar) {
+      final TarStream entries = new TarStream(decompressed);
+      while (entries.next()) {
+        if (!entries.isFile()) {
+          continue;
+        }
+        final Path file = safeChild(target, entries.name());
+        Files.createDirectories(file.getParent());
+        Files.copy(entries.entryStream(), file, StandardCopyOption.REPLACE_EXISTING);
+      }
+    } else {
+      final String plainName = name.endsWith(".gz")
+          ? name.substring(0, name.length() - 3) : name;
+      Files.copy(decompressed, safeChild(target, plainName),
+          StandardCopyOption.REPLACE_EXISTING);
+    }
+  }
+
+  private static void unpackZip(InputStream raw, Path target) throws IOException {
+    final ZipInputStream zip = new ZipInputStream(raw);
+    ZipEntry entry;
+    while ((entry = zip.getNextEntry()) != null) {
+      if (entry.isDirectory()) {
+        continue;
+      }
+      final Path file = safeChild(target, entry.getName());
+      Files.createDirectories(file.getParent());
+      Files.copy(zip, file, StandardCopyOption.REPLACE_EXISTING);
+    }
+  }
+
+  /** Peeks whether gzip content holds a tar archive, by the ustar magic or a header. */
+  private static boolean looksLikeTar(InputStream decompressed) throws IOException {
+    final byte[] block = new byte[512];
+    int filled = 0;
+    while (filled < block.length) {
+      final int read = decompressed.read(block, filled, block.length - filled);
+      if (read < 0) {
+        return false;
+      }
+      filled += read;
+    }
+    if (block[257] == 'u' && block[258] == 's' && block[259] == 't'
+        && block[260] == 'a' && block[261] == 'r') {
+      return true;
+    }
+    // classic tar: a name and a valid octal size field
+    if (block[0] == 0) {
+      return false;
+    }
+    for (int i = 124; i < 136; i++) {
+      final byte b = block[i];
+      if (b != 0 && b != ' ' && (b < '0' || b > '7')) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  /** Resolves an archive entry inside the target, rejecting escaping paths. */
+  private static Path safeChild(Path target, String entryName) throws IOException {
+    final Path resolved = target.resolve(entryName).normalize();
+    if (!resolved.startsWith(target.normalize())) {
+      throw new IOException("archive entry escapes the target directory: " + entryName);
+    }
+    return resolved;
+  }
+
+  /** Derives a file name from the source URI for non-archive content. */
+  private static String sourceName(URI source) {
+    final String path = source.getPath();
+    if (path == null || path.isEmpty()) {
+      return "resource";
+    }
+    final int slash = path.lastIndexOf('/');
+    final String name = slash < 0 ? path : path.substring(slash + 1);
+    return name.isEmpty() ? "resource" : name;
+  }
+}
diff --git a/opennlp-core/opennlp-runtime/src/main/java/opennlp/tools/util/archive/TarStream.java b/opennlp-core/opennlp-runtime/src/main/java/opennlp/tools/util/archive/TarStream.java
new file mode 100644
index 000000000..db7b4f4f4
--- /dev/null
+++ b/opennlp-core/opennlp-runtime/src/main/java/opennlp/tools/util/archive/TarStream.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package opennlp.tools.util.archive;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+
+import opennlp.tools.commons.Internal;
+
+/**
+ * A forward-only reader over a tar stream: {@link #next()} advances to the following
+ * entry, skipping whatever remains of the current one, and {@link #entryStream()}
+ * exposes exactly the current entry's bytes. No external archive library is involved.
+ *
+ * <p>Reads classic and ustar headers: entry name, octal size, and type flag. Long-name
+ * extensions are not interpreted; such entries appear under their extension header
+ * names and are skippable like any other.</p>
+ */
+@Internal
+public final class TarStream {
+
+  private static final int BLOCK = 512;
+  private static final int NAME_LENGTH = 100;
+  private static final int SIZE_OFFSET = 124;
+  private static final int SIZE_LENGTH = 12;
+  private static final int TYPE_OFFSET = 156;
+
+  private final InputStream in;
+  private final byte[] header = new byte[BLOCK];
+
+  private String name;
+  private long size;
+  private char type;
+  private long remaining;
+
+  /**
+   * Initializes the reader.
+   *
+   * @param in The tar content. Must not be {@code null}. Not closed by this class.
+   * @throws IllegalArgumentException Thrown if {@code in} is {@code null}.
+   */
+  public TarStream(InputStream in) {
+    if (in == null) {
+      throw new IllegalArgumentException("in must not be null");
+    }
+    this.in = in;
+  }
+
+  /**
+   * Advances to the next entry.
+   *
+   * @return {@code true} if an entry is available, {@code false} at the end of the
+   *         archive.
+   * @throws IOException Thrown if the archive is truncated or a header is malformed.
+   */
+  public boolean next() throws IOException {
+    skip(remaining + padding(size));
+    if (!readBlock()) {
+      return false;
+    }
+    if (isEndBlock()) {
+      return false;
+    }
+    int nameEnd = 0;
+    while (nameEnd < NAME_LENGTH && header[nameEnd] != 0) {
+      nameEnd++;
+    }
+    name = new String(header, 0, nameEnd, StandardCharsets.UTF_8);
+    size = parseOctal();
+    remaining = size;
+    type = (char) header[TYPE_OFFSET];
+    return true;
+  }
+
+  /**
+   * @return The current entry's name as stored in the archive. Never {@code null}
+   *         after a successful {@link #next()}.
+   */
+  public String name() {
+    return name;
+  }
+
+  /**
+   * @return The current entry's size in bytes.
+   */
+  public long size() {
+    return size;
+  }
+
+  /**
+   * @return {@code true} if the current entry is a regular file.
+   */
+  public boolean isFile() {
+    return type == '0' || type == 0;
+  }
+
+  /**
+   * Opens the current entry's content.
+   *
+   * @return A stream over exactly this entry's bytes; reading past the end returns end
+   *         of stream. Never {@code null}. Closing it is not required.
+   */
+  public InputStream entryStream() {
+    return new InputStream() {
+      @Override
+      public int read() throws IOException {
+        if (remaining <= 0) {
+          return -1;
+        }
+        final int b = in.read();
+        if (b < 0) {
+          throw new IOException("truncated tar entry: " + name);
+        }
+        remaining--;
+        return b;
+      }
+
+      @Override
+      public int read(byte[] buffer, int offset, int length) throws IOException {
+        if (remaining <= 0) {
+          return -1;
+        }
+        final int read = in.read(buffer, offset, (int) Math.min(length, remaining));
+        if (read < 0) {
+          throw new IOException("truncated tar entry: " + name);
+        }
+        remaining -= read;
+        return read;
+      }
+    };
+  }
+
+  private boolean readBlock() throws IOException {
+    int filled = 0;
+    while (filled < header.length) {
+      final int read = in.read(header, filled, header.length - filled);
+      if (read < 0) {
+        if (filled == 0) {
+          return false;
+        }
+        throw new IOException("truncated tar header");
+      }
+      filled += read;
+    }
+    return true;
+  }
+
+  private boolean isEndBlock() {
+    for (final byte b : header) {
+      if (b != 0) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  private long parseOctal() throws IOException {
+    long value = 0;
+    for (int i = SIZE_OFFSET; i < SIZE_OFFSET + SIZE_LENGTH; i++) {
+      final byte b = header[i];
+      if (b == 0 || b == ' ') {
+        continue;
+      }
+      if (b < '0' || b > '7') {
+        throw new IOException("malformed tar size field in entry header");
+      }
+      value = value * 8 + (b - '0');
+    }
+    return value;
+  }
+
+  private long padding(long entrySize) {
+    final long remainder = entrySize % BLOCK;
+    return remainder == 0 ? 0 : BLOCK - remainder;
+  }
+
+  private void skip(long bytes) throws IOException {
+    long toSkip = bytes;
+    final byte[] buffer = new byte[8192];
+    while (toSkip > 0) {
+      final int read = in.read(buffer, 0, (int) Math.min(buffer.length, toSkip));
+      if (read < 0) {
+        throw new IOException("truncated tar archive");
+      }
+      toSkip -= read;
+    }
+  }
+}
diff --git a/opennlp-core/opennlp-runtime/src/test/java/opennlp/tools/util/ResourceInstallerTest.java b/opennlp-core/opennlp-runtime/src/test/java/opennlp/tools/util/ResourceInstallerTest.java
new file mode 100644
index 000000000..5c937e7da
--- /dev/null
+++ b/opennlp-core/opennlp-runtime/src/test/java/opennlp/tools/util/ResourceInstallerTest.java
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package opennlp.tools.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.security.MessageDigest;
+import java.util.zip.GZIPOutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+public class ResourceInstallerTest {
+
+  /** Writes one ustar entry: a 512-byte header block and padded content. */
+  private static void tarEntry(ByteArrayOutputStream tar, String name, byte[] content)
+      throws IOException {
+    final byte[] header = new byte[512];
+    final byte[] nameBytes = name.getBytes(StandardCharsets.UTF_8);
+    System.arraycopy(nameBytes, 0, header, 0, nameBytes.length);
+    final String size = String.format("%011o", content.length);
+    System.arraycopy(size.getBytes(StandardCharsets.US_ASCII), 0, header, 124, 11);
+    header[156] = '0';
+    tar.write(header);
+    tar.write(content);
+    final int padding = (512 - content.length % 512) % 512;
+    tar.write(new byte[padding]);
+  }
+
+  private static byte[] tarGz(String[][] entries) throws IOException {
+    final ByteArrayOutputStream tar = new ByteArrayOutputStream();
+    for (final String[] entry : entries) {
+      tarEntry(tar, entry[0], entry[1].getBytes(StandardCharsets.UTF_8));
+    }
+    tar.write(new byte[1024]);
+    final ByteArrayOutputStream compressed = new ByteArrayOutputStream();
+    try (GZIPOutputStream gzip = new GZIPOutputStream(compressed)) {
+      gzip.write(tar.toByteArray());
+    }
+    return compressed.toByteArray();
+  }
+
+  private static String sha256(byte[] content) throws Exception {
+    final StringBuilder hex = new StringBuilder();
+    for (final byte b : MessageDigest.getInstance("SHA-256").digest(content)) {
+      hex.append(Character.forDigit((b >> 4) & 0xF, 16))
+          .append(Character.forDigit(b & 0xF, 16));
+    }
+    return hex.toString();
+  }
+
+  @Test
+  void testTarGzUnpacksWithStructure(@TempDir Path source, @TempDir Path target)
+      throws Exception {
+    final byte[] archive = tarGz(new String[][] {
+        {"corpus-1.0/train.conllu", "# sent_id = 1\n"},
+        {"corpus-1.0/sub/readme.txt", "hello"}});
+    final Path file = source.resolve("corpus.tgz");
+    Files.write(file, archive);
+
+    ResourceInstaller.install(file.toUri(), target, sha256(archive));
+
+    Assertions.assertEquals("# sent_id = 1\n",
+        Files.readString(target.resolve("corpus-1.0/train.conllu")));
+    Assertions.assertEquals("hello",
+        Files.readString(target.resolve("corpus-1.0/sub/readme.txt")));
+  }
+
+  @Test
+  void testChecksumMismatchFailsBeforeUnpacking(@TempDir Path source,
+      @TempDir Path target) throws Exception {
+    final byte[] archive = tarGz(new String[][] {{"a/file.txt", "content"}});
+    final Path file = source.resolve("archive.tar.gz");
+    Files.write(file, archive);
+
+    Assertions.assertThrows(IOException.class, () -> ResourceInstaller.install(
+        file.toUri(), target, "00000000000000000000000000000000"
+            + "00000000000000000000000000000000"));
+    Assertions.assertEquals(0, Files.list(target).count());
+  }
+
+  @Test
+  void testEscapingEntriesAreRejected(@TempDir Path source, @TempDir Path target)
+      throws Exception {
+    final byte[] archive = tarGz(new String[][] {{"../escape.txt", "bad"}});
+    final Path file = source.resolve("evil.tar.gz");
+    Files.write(file, archive);
+
+    Assertions.assertThrows(IOException.class,
+        () -> ResourceInstaller.install(file.toUri(), target));
+    Assertions.assertTrue(Files.notExists(target.getParent().resolve("escape.txt")));
+  }
+
+  @Test
+  void testZipUnpacks(@TempDir Path source, @TempDir Path target) throws Exception {
+    final ByteArrayOutputStream out = new ByteArrayOutputStream();
+    try (ZipOutputStream zip = new ZipOutputStream(out)) {
+      zip.putNextEntry(new ZipEntry("lexicon/words.txt"));
+      zip.write("cat 100\n".getBytes(StandardCharsets.UTF_8));
+      zip.closeEntry();
+    }
+    final Path file = source.resolve("lexicon.zip");
+    Files.write(file, out.toByteArray());
+
+    ResourceInstaller.install(file.toUri(), target);
+
+    Assertions.assertEquals("cat 100\n",
+        Files.readString(target.resolve("lexicon/words.txt")));
+  }
+
+  @Test
+  void testPlainGzipDecompressesToTheSourceName(@TempDir Path source,
+      @TempDir Path target) throws Exception {
+    final ByteArrayOutputStream out = new ByteArrayOutputStream();
+    try (GZIPOutputStream gzip = new GZIPOutputStream(out)) {
+      gzip.write("word\tlemma\n".getBytes(StandardCharsets.UTF_8));
+    }
+    final Path file = source.resolve("lexicon.tsv.gz");
+    Files.write(file, out.toByteArray());
+
+    ResourceInstaller.install(file.toUri(), target);
+
+    Assertions.assertEquals("word\tlemma\n",
+        Files.readString(target.resolve("lexicon.tsv")));
+  }
+
+  @Test
+  void testPlainFilesAreStoredUnderTheirSourceName(@TempDir Path source,
+      @TempDir Path target) throws Exception {
+    final Path file = source.resolve("frequencies.txt");
+    Files.writeString(file, "cat 100");
+
+    ResourceInstaller.install(file.toUri(), target);
+
+    Assertions.assertEquals("cat 100", Files.readString(target.resolve("frequencies.txt")));
+  }
+
+  @Test
+  void testInvalidArguments(@TempDir Path target) {
+    Assertions.assertThrows(IllegalArgumentException.class,
+        () -> ResourceInstaller.install(null, target));
+    Assertions.assertThrows(IllegalArgumentException.class,
+        () -> ResourceInstaller.install(target.toUri(), null));
+    Assertions.assertThrows(IllegalArgumentException.class,
+        () -> ResourceInstaller.install(target.toUri(), target, " "));
+  }
+}