{"record":{"id":"d9e3cffa6b2e153e","repo":"Tencent/tinker","slug":"tinkerloadverifyflag-is-already-set","errorCode":null,"errorMessage":"tinkerLoadVerifyFlag is already set.","messagePattern":"tinkerLoadVerifyFlag is already set\\.","errorType":"exception","errorClass":"TinkerRuntimeException","httpStatus":null,"severity":"error","filePath":"tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/tinker/Tinker.java","lineNumber":327,"sourceCode":"            this.patchInfoFile = SharePatchFileUtil.getPatchInfoFile(patchDirectory.getAbsolutePath());\n            this.patchInfoLockFile = SharePatchFileUtil.getPatchInfoLockFile(patchDirectory.getAbsolutePath());\n            ShareTinkerLog.w(TAG, \"tinker patch directory: %s\", patchDirectory);\n        }\n\n        public Builder tinkerFlags(int tinkerFlags) {\n            if (this.status != -1) {\n                throw new TinkerRuntimeException(\"tinkerFlag is already set.\");\n            }\n            this.status = tinkerFlags;\n            return this;\n        }\n\n        public Builder tinkerLoadVerifyFlag(Boolean verifyMd5WhenLoad) {\n            if (verifyMd5WhenLoad == null) {\n                throw new TinkerRuntimeException(\"tinkerLoadVerifyFlag must not be null.\");\n            }\n            if (this.tinkerLoadVerifyFlag != null) {\n                throw new TinkerRuntimeException(\"tinkerLoadVerifyFlag is already set.\");\n            }\n            this.tinkerLoadVerifyFlag = verifyMd5WhenLoad;\n            return this;\n        }\n\n        public Builder loadReport(LoadReporter loadReporter) {\n            if (loadReporter == null) {\n                throw new TinkerRuntimeException(\"loadReporter must not be null.\");\n            }\n            if (this.loadReporter != null) {\n                throw new TinkerRuntimeException(\"loadReporter is already set.\");\n            }\n            this.loadReporter = loadReporter;\n            return this;\n        }\n\n        public Builder patchReporter(PatchReporter patchReporter) {\n            if (patchReporter == null) {","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/Tencent/tinker/blob/1b7ea02c239840f563ea64fb5bd286eb98d4011e/tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/tinker/Tinker.java#L309-L345","documentation":"Tinker.Builder.tinkerLoadVerifyFlag(Boolean) is a set-once fluent setter: after the null check it throws TinkerRuntimeException(\"tinkerLoadVerifyFlag is already set.\") when the field has already been assigned. Like the other builder guards, this prevents two different code paths from each configuring the verify flag, which would silently change whether patches are md5-checked at load time.","triggerScenarios":"Calling tinkerLoadVerifyFlag(...) twice on the same Builder — e.g. a shared init helper sets true for QA builds and the app's own chain then sets false, or a duplicated chain line after merge/refactor.","commonSituations":"Debug/QA overlays that 'adjust' a base configuration; builder kept as a long-lived field receiving repeated configuration; two SDKs both embedding Tinker init logic.","solutions":["Resolve the final flag once (prefer the stricter true when in doubt) and call the setter a single time.","Compute the decision before building: boolean verify = isQa || cfgFlag; builder.tinkerLoadVerifyFlag(verify).","Create a fresh Builder per initialization and never share/reuse it across code paths."],"exampleFix":"// before\nbuilder.tinkerLoadVerifyFlag(true);          // QA default\nif (!isQa) builder.tinkerLoadVerifyFlag(false); // throws: already set\n\n// after\nbuilder.tinkerLoadVerifyFlag(isQa); // single decision, one call","handlingStrategy":"validation","validationCode":"boolean verify = isQaBuild || Boolean.TRUE.equals(cfgFlag);\nbuilder.tinkerLoadVerifyFlag(verify); // single call","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One decision point for the verify flag; prefer the stricter (true) value on conflict","Never share a Builder instance across configuration layers"],"tags":["android","tinker","builder","configuration"],"backgroundTag":null,"analyzedSha":"1b7ea02c239840f563ea64fb5bd286eb98d4011e","analyzedAt":"2026-08-14T15:16:52.110Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}