Tencent/tinker · critical · TinkerRuntimeException

readAndCheckPropertyWithLock fail

Error message

readAndCheckPropertyWithLock fail

What it means

SharePatchInfo.readAndCheckPropertyWithLock takes a file lock on the lock file and then reads/validates /assets-patch info file (info file). Any exception from lock acquisition (ShareFileLockHelper.getFileLock) or from readAndCheckProperty (IO error, JSON/format validation failure) is wrapped in TinkerRuntimeException('readAndCheckPropertyWithLock fail'). The patch metadata is unusable, so loading cannot proceed.

Source

Thrown at tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/loader/shareutil/SharePatchInfo.java:78

        this.isRemoveInterpretOATDir = isRemoveInterpretOATDir;
    }

    public static SharePatchInfo readAndCheckPropertyWithLock(File pathInfoFile, File lockFile) {
        if (pathInfoFile == null || lockFile == null) {
            return null;
        }
        File lockParentFile = lockFile.getParentFile();
        if (!lockParentFile.exists()) {
            lockParentFile.mkdirs();
        }

        SharePatchInfo patchInfo;
        ShareFileLockHelper fileLock = null;
        try {
            fileLock = ShareFileLockHelper.getFileLock(lockFile);
            patchInfo = readAndCheckProperty(pathInfoFile);
        } catch (Exception e) {
            throw new TinkerRuntimeException("readAndCheckPropertyWithLock fail", e);
        } finally {
            try {
                if (fileLock != null) {
                    fileLock.close();
                }
            } catch (IOException e) {
                ShareTinkerLog.w(TAG, "releaseInfoLock error", e);
            }
        }

        return patchInfo;
    }

    public static boolean rewritePatchInfoFileWithLock(File pathInfoFile, SharePatchInfo info, File lockFile) {
        if (pathInfoFile == null || info == null || lockFile == null) {
            return false;
        }
        File lockParentFile = lockFile.getParentFile();

View on GitHub (pinned to 1b7ea02c23)

Solutions

  1. Clean the patch directory (Tinker.with(context).cleanPatch()) and re-download/re-apply the patch to regenerate the info file.
  2. Inspect the info file content on device (run-as / adb) to confirm which validation failed (missing or malformed fields).
  3. Ensure tinker only applies patches from one process and the patch directory is on writable internal storage.
  4. Upgrade tinker if the failure recurs across patches — old versions had weaker atomic-write behavior for info files.

Example fix

// before
SharePatchInfo info = SharePatchInfo.readAndCheckPropertyWithLock(infoFile, lockFile);

// after
SharePatchInfo info;
try {
    info = SharePatchInfo.readAndCheckPropertyWithLock(infoFile, lockFile);
} catch (TinkerRuntimeException e) {
    ShareTinkerLog.e(TAG, "patch info unreadable, clean and retry patch later", e);
    Tinker.with(context).cleanPatch();
    info = null;
}
Defensive patterns

Strategy: try-catch

Validate before calling

File info = new File(patchDir, "info");
if (!SharePatchFileUtil.isLegalFile(info)) {
    // patch state missing/corrupt -> clean and re-apply later
}

Try / catch

catch TinkerRuntimeException with cause 'readAndCheckPropertyWithLock fail' -> Tinker.with(ctx).cleanPatch() and schedule re-download

Prevention

When it happens

Trigger: Corrupted or truncated patch info file (bad JSON, missing keys — readAndCheckProperty validates fields); info file unreadable due to permissions/disk; lock file parent uncreatable (mkdirs failed on read-only storage); concurrent process holding the lock in a bad state.

Common situations: Patch install interrupted midway leaving a half-written info file; device storage corruption or full disk; process killed during upgrade; running tinker in multiple processes without the recommended single-process configuration.

Related errors


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