{"record":{"id":"bc70aa48104669aa","repo":"Tencent/tinker","slug":"readandcheckpropertywithlock-fail","errorCode":null,"errorMessage":"readAndCheckPropertyWithLock fail","messagePattern":"readAndCheckPropertyWithLock fail","errorType":"exception","errorClass":"TinkerRuntimeException","httpStatus":null,"severity":"critical","filePath":"tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/loader/shareutil/SharePatchInfo.java","lineNumber":78,"sourceCode":"        this.isRemoveInterpretOATDir = isRemoveInterpretOATDir;\n    }\n\n    public static SharePatchInfo readAndCheckPropertyWithLock(File pathInfoFile, File lockFile) {\n        if (pathInfoFile == null || lockFile == null) {\n            return null;\n        }\n        File lockParentFile = lockFile.getParentFile();\n        if (!lockParentFile.exists()) {\n            lockParentFile.mkdirs();\n        }\n\n        SharePatchInfo patchInfo;\n        ShareFileLockHelper fileLock = null;\n        try {\n            fileLock = ShareFileLockHelper.getFileLock(lockFile);\n            patchInfo = readAndCheckProperty(pathInfoFile);\n        } catch (Exception e) {\n            throw new TinkerRuntimeException(\"readAndCheckPropertyWithLock fail\", e);\n        } finally {\n            try {\n                if (fileLock != null) {\n                    fileLock.close();\n                }\n            } catch (IOException e) {\n                ShareTinkerLog.w(TAG, \"releaseInfoLock error\", e);\n            }\n        }\n\n        return patchInfo;\n    }\n\n    public static boolean rewritePatchInfoFileWithLock(File pathInfoFile, SharePatchInfo info, File lockFile) {\n        if (pathInfoFile == null || info == null || lockFile == null) {\n            return false;\n        }\n        File lockParentFile = lockFile.getParentFile();","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/Tencent/tinker/blob/1b7ea02c239840f563ea64fb5bd286eb98d4011e/tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/loader/shareutil/SharePatchInfo.java#L60-L96","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Clean the patch directory (Tinker.with(context).cleanPatch()) and re-download/re-apply the patch to regenerate the info file.","Inspect the info file content on device (run-as / adb) to confirm which validation failed (missing or malformed fields).","Ensure tinker only applies patches from one process and the patch directory is on writable internal storage.","Upgrade tinker if the failure recurs across patches — old versions had weaker atomic-write behavior for info files."],"exampleFix":"// before\nSharePatchInfo info = SharePatchInfo.readAndCheckPropertyWithLock(infoFile, lockFile);\n\n// after\nSharePatchInfo info;\ntry {\n    info = SharePatchInfo.readAndCheckPropertyWithLock(infoFile, lockFile);\n} catch (TinkerRuntimeException e) {\n    ShareTinkerLog.e(TAG, \"patch info unreadable, clean and retry patch later\", e);\n    Tinker.with(context).cleanPatch();\n    info = null;\n}","handlingStrategy":"try-catch","validationCode":"File info = new File(patchDir, \"info\");\nif (!SharePatchFileUtil.isLegalFile(info)) {\n    // patch state missing/corrupt -> clean and re-apply later\n}","typeGuard":null,"tryCatchPattern":"catch TinkerRuntimeException with cause 'readAndCheckPropertyWithLock fail' -> Tinker.with(ctx).cleanPatch() and schedule re-download","preventionTips":["Let only one process write/read patch info under the tinker lock convention.","Validate patch package md5 before applying so corrupt info files are never persisted.","Treat unreadable patch info as 'no patch installed' rather than a crash."],"tags":["patch-info","file-lock","corruption","io"],"backgroundTag":null,"analyzedSha":"1b7ea02c239840f563ea64fb5bd286eb98d4011e","analyzedAt":"2026-08-14T15:16:52.110Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}