{"record":{"id":"65521742d739d8de","repo":"Tencent/tinker","slug":"getpatchresultextra-but-intent-is-null","errorCode":null,"errorMessage":"getPatchResultExtra, but intent is null","messagePattern":"getPatchResultExtra, but intent is null","errorType":"exception","errorClass":"TinkerRuntimeException","httpStatus":null,"severity":"error","filePath":"tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/service/TinkerPatchService.java","lineNumber":106,"sourceCode":"    }\n\n    public static String getPatchPathExtra(Intent intent) {\n        if (intent == null) {\n            throw new TinkerRuntimeException(\"getPatchPathExtra, but intent is null\");\n        }\n        return ShareIntentUtil.getStringExtra(intent, PATCH_PATH_EXTRA);\n    }\n\n    public static boolean getPatchUseEmergencyMode(Intent intent) {\n        if (intent == null) {\n            throw new TinkerRuntimeException(\"getPatchUseEmergencyMode, but intent is null\");\n        }\n        return ShareIntentUtil.getBooleanExtra(intent, PATCH_USE_EMERGENCY_MODE, false);\n    }\n\n    public static String getPatchResultExtra(Intent intent) {\n        if (intent == null) {\n            throw new TinkerRuntimeException(\"getPatchResultExtra, but intent is null\");\n        }\n        return ShareIntentUtil.getStringExtra(intent, RESULT_CLASS_EXTRA);\n    }\n\n    @Override\n    protected void onHandleIntent(Intent intent) {\n        increasingPriority();\n        doApplyPatch(this, intent);\n    }\n\n    /**\n     * set the tinker notification id you want\n     * @param id\n     */\n    public static void setTinkerNotificationId(int id) {\n        notificationId = id;\n    }\n","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/Tencent/tinker/blob/1b7ea02c239840f563ea64fb5bd286eb98d4011e/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/service/TinkerPatchService.java#L88-L124","documentation":"TinkerPatchService.getPatchResultExtra reads the result-service class name extra from the starting intent so the patch flow knows where to dispatch the final PatchResult. It throws on a null Intent, mirroring the other static accessors in this class.","triggerScenarios":"Calling getPatchResultExtra(intent) with a null Intent — for instance in a custom onHandleIntent or a subclass of TinkerPatchService that does not short-circuit null intents before delegating.","commonSituations":"System redelivery of a null intent to a sticky IntentService; custom patch service subclasses; unit tests constructing null intents to exercise patch logic.","solutions":["Short-circuit null intents at the service entry point before calling any get*Extra helper.","Start the patch service only via the provided TinkerPatchService.runPatchService / TinkerInstaller APIs that populate all extras.","In tests, construct the Intent with the required extras rather than passing null."],"exampleFix":"// before\nString resultClass = TinkerPatchService.getPatchResultExtra(intent);\n\n// after\nif (intent == null) return;\nString resultClass = TinkerPatchService.getPatchResultExtra(intent);","handlingStrategy":"validation","validationCode":"if (intent == null) return;\nString resultClass = TinkerPatchService.getPatchResultExtra(intent);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guard service entry points against null intents.","Start the patch service only via TinkerPatchService.runPatchService / TinkerInstaller APIs.","Log dropped null-intent cases to detect misbehaving external starters early."],"tags":["tinker","android","service","intent","null-check"],"backgroundTag":null,"analyzedSha":"1b7ea02c239840f563ea64fb5bd286eb98d4011e","analyzedAt":"2026-08-14T15:16:52.110Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}