{"record":{"id":"52ea33e5d8dd946f","repo":"alibaba/nacos","slug":"getdescription-cannot-be-resolved-in-the-file-52ea33","errorCode":null,"errorMessage":"{getDescription()} cannot be resolved in the file system for checking its last-modified timestamp","messagePattern":"(.+?) cannot be resolved in the file system for checking its last-modified timestamp","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/com/alibaba/nacos/common/packagescan/resource/AbstractResource.java","lineNumber":191,"sourceCode":"                if (logger.isDebugEnabled()) {\n                    logger.debug(\"Could not close content-length InputStream for \" + getDescription(), ex);\n                }\n            }\n        }\n    }\n\n    /**\n     * This implementation checks the timestamp of the underlying File,\n     * if available.\n     *\n     * @see #getFileForLastModifiedCheck()\n     */\n    @Override\n    public long lastModified() throws IOException {\n        File fileToCheck = getFileForLastModifiedCheck();\n        long lastModified = fileToCheck.lastModified();\n        if (lastModified == 0L && !fileToCheck.exists()) {\n            throw new FileNotFoundException(getDescription()\n                    + \" cannot be resolved in the file system for checking its last-modified timestamp\");\n        }\n        return lastModified;\n    }\n\n    /**\n     * Determine the File to use for timestamp checking.\n     * The default implementation delegates to {@link #getFile()}.\n     *\n     * @return the File to use for timestamp checking (never {@code null})\n     * @throws FileNotFoundException if the resource cannot be resolved as\n     *                               an absolute file path, i.e. is not available in a file system\n     * @throws IOException           in case of general resolution/reading failures\n     */\n    protected File getFileForLastModifiedCheck() throws IOException {\n        return getFile();\n    }\n","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/common/src/main/java/com/alibaba/nacos/common/packagescan/resource/AbstractResource.java#L173-L209","documentation":"Thrown by the default AbstractResource.lastModified() (the AbstractResource version, distinct from AbstractFileResolvingResource) when getFileForLastModifiedCheck() returns a File whose lastModified() is 0 and which does not exist. FileNotFoundException indicates the resource could not be resolved to an existing file for timestamp checking.","triggerScenarios":"Calling lastModified() on an AbstractResource subclass where getFileForLastModifiedCheck() (defaulting to getFile()) returns a non-existent path; resource that has no file representation so getFile() yields a phantom path.","commonSituations":"A resource subclass whose getFile() returns a path inside a jar or a deleted file; stale resource handle after the underlying file was removed; subclass that overrode getFileForLastModifiedCheck() to return a wrong path.","solutions":["Check the file exists (file.exists()) before calling lastModified().","Override getFileForLastModifiedCheck() in your subclass to return a real, existing File, or rely on a URL-based timestamp.","Catch FileNotFoundException and treat timestamp as unknown rather than fatal.","Use AbstractFileResolvingResource (URL-connection fallback) instead of bare AbstractResource if the resource may not be file-backed."],"exampleFix":"// before\nlong ts = resource.lastModified(); // throws if file missing\n\n// after\nFile f = resource.getFileForLastModifiedCheck();\nlong ts = f.exists() ? f.lastModified() : -1L;","handlingStrategy":"validation","validationCode":"File f = resource.getFileForLastModifiedCheck();\nif (!f.exists()) {\n    return -1L;\n}\nreturn resource.lastModified();","typeGuard":"boolean hasFileTimestamp(Resource r) {\n    try { return r.getFileForLastModifiedCheck().exists(); }\n    catch (IOException e) { return false; }\n}","tryCatchPattern":"try {\n    long ts = resource.lastModified();\n} catch (FileNotFoundException e) {\n    log.debug(\"No file for timestamp: {}\", e.getMessage());\n    ts = -1L;\n}","preventionTips":["Check the file from getFileForLastModifiedCheck() exists first.","Override getFileForLastModifiedCheck() to return a real file when applicable.","Prefer AbstractFileResolvingResource for URL-backed resources needing timestamps."],"tags":["resource","io","file","lifecycle"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}