Tencent/tinker · error · NullPointerException

entryName == null

Error message

entryName == null

What it means

getEntry explicitly rejects a null entry name with NullPointerException('entryName == null') before consulting the entries map. This is a fail-fast guard for programmer error rather than file corruption — the map lookup would otherwise return null and the caller would misread a bug as 'entry missing'. The check runs after checkNotClosed(), so a closed file fails first with IllegalStateException.

Source

Thrown at third-party/tinker-ziputils/src/main/java/com/tencent/tinker/ziputils/ziputil/TinkerZipFile.java:314

     * See {@link ZipOutputStream#setComment}.
     *
     * @throws IllegalStateException if this zip file has been closed.
     * @since 1.7
     */
    public String getComment() {
        checkNotClosed();
        return comment;
    }

    /**
     * Returns the zip entry with the given name, or null if there is no such entry.
     *
     * @throws IllegalStateException if this zip file has been closed.
     */
    public TinkerZipEntry getEntry(String entryName) {
        checkNotClosed();
        if (entryName == null) {
            throw new NullPointerException("entryName == null");
        }
        TinkerZipEntry ze = entries.get(entryName);
        if (ze == null) {
            ze = entries.get(entryName + "/");
        }
        return ze;
    }

    /**
     * Returns an input stream on the data of the specified {@code ZipEntry}.
     *
     * @param entry
     *            the ZipEntry.
     * @return an input stream of the data contained in the {@code ZipEntry}.
     * @throws IOException
     *             if an {@code IOException} occurs.
     * @throws IllegalStateException if this zip file has been closed.
     */

View on GitHub (pinned to 1b7ea02c23)

Solutions

  1. Validate the name is non-null (and non-empty) before the call and fail with your own contextual message identifying which config/source produced it.
  2. Trace where the null came from: usually a missing property or map key one frame up the stack.
  3. Add a default/required check at the config boundary so the name can never reach the zip layer unset.

Example fix

// before
String name = System.getProperty("patch.entry"); // null if unset
zf.getEntry(name);

// after
String name = System.getProperty("patch.entry");
if (name == null || name.isEmpty()) {
    throw new IllegalArgumentException("patch.entry property is required");
}
TinkerZipEntry e = zf.getEntry(name);
Defensive patterns

Strategy: validation

Validate before calling

Objects.requireNonNull(entryName, "entryName must come from config key 'patch.entry'");
if (entryName.isEmpty()) {
    throw new IllegalArgumentException("entryName is empty");
}
TinkerZipEntry e = zf.getEntry(entryName);

Prevention

When it happens

Trigger: Calling getEntry(null): typically a variable that was never assigned, a map.get() that returned null and was passed straight through, or a config key/property that was absent from the environment.

Common situations: Reading the entry name from a config file or command-line argument that was not provided; downstream of a failed lookup ('get the entry for X' where X itself was computed from missing data); refactoring that dropped an initialization.

Related errors


AI-assisted analysis of Tencent/tinker@1b7ea02c23 (2026-08-14). Data as JSON: /api/errors/ce8d5f6112103356. Report an issue: GitHub.