{"record":{"id":"5cb2ec8a4f11a437","repo":"apereo/cas","slug":"loggingutils-warn-logger-e-5cb2ec","errorCode":null,"errorMessage":"LoggingUtils.warn(LOGGER, e)","messagePattern":"LoggingUtils\\.warn\\(LOGGER, e\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/ResourceUtils.java","lineNumber":110,"sourceCode":"        val lowerCase = resource.toLowerCase(Locale.ENGLISH);\n        return lowerCase.startsWith(RESOURCE_URL_PREFIX);\n    }\n\n    /**\n     * Determines whether the resource exists.\n     *\n     * @param resource       the resource\n     * @param resourceLoader the resource loader\n     * @return true/false\n     */\n    public static boolean doesResourceExist(final String resource, final ResourceLoader resourceLoader) {\n        try {\n            if (StringUtils.isNotBlank(resource)) {\n                val res = resourceLoader.getResource(resource);\n                return doesResourceExist(res);\n            }\n        } catch (final Exception e) {\n            LoggingUtils.warn(LOGGER, e);\n        }\n        return false;\n    }\n\n    /**\n     * Determines whether the resource exists.\n     * <p>\n     * On Windows, reading one byte from a directory does not return length greater than zero so an explicit directory\n     * check is needed.\n     *\n     * @param res the res\n     * @return true/false\n     */\n    public static boolean doesResourceExist(final Resource res) {\n        if (res == null) {\n            return false;\n        }\n        try {","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/ResourceUtils.java#L92-L128","documentation":"ResourceUtils.doesResourceExist(String) probes whether a resource location exists via a ResourceLoader. Any exception during the probe (malformed URL, unsupported prefix, I/O error) is swallowed and logged at WARN via LoggingUtils.warn, and the method returns false. A warn here therefore means 'existence could not be determined', which is treated as 'does not exist'.","triggerScenarios":"Calling ResourceUtils.doesResourceExist(location) where resourceLoader.getResource(location) throws — e.g. malformed resource URLs, invalid classpath:/file:/http: prefixes, or unreachable network resources.","commonSituations":"Typo'd resource paths in configuration; checking resources on mounted/network volumes that are unavailable; placeholder resolution producing an invalid resource string; Spring resource-prefix misuse.","solutions":["Read the warn's derived exception message to see why the resource lookup failed (usually a malformed URL or bad prefix)","Correct the resource location string (verify prefix: classpath:, file:, http:, etc.)","Verify the resource actually exists at the given path and is readable by the CAS process user","Remember a false return may mean 'unknown' rather than 'missing' — do not build critical logic on this probe alone"],"exampleFix":"// before\nboolean ok = ResourceUtils.doesResourceExist(\"/etc/cas/config/services.json\"); // no scheme -> probe throws\n// after\nboolean ok = ResourceUtils.doesResourceExist(\"file:/etc/cas/config/services.json\");","handlingStrategy":"fallback","validationCode":"if (location == null || location.isBlank() || !location.matches(\"^(classpath|file|https?)://.*\")) {\n    log.warn(\"Suspicious resource location: {}\", location);\n}","typeGuard":null,"tryCatchPattern":"try {\n    boolean exists = ResourceUtils.doesResourceExist(location);\n} catch (Exception e) {\n    LoggingUtils.warn(LOGGER, e);\n    exists = false; // probe already returns false on exception\n}","preventionTips":["Always use a fully qualified Spring resource URL (classpath:, file:, http:) when probing resources","Treat a false result as 'missing or inaccessible' and log the intended location for diagnosis","Verify filesystem permissions for the CAS process user on external resource paths","Do not rely on doesResourceExist for security-critical decisions since I/O errors collapse to false"],"tags":["resources","io","resource-loader","spring"],"backgroundTag":"resource-not-found","analyzedSha":"e7288fc434b4f4505b8452e1a57e8fb3111bb863","analyzedAt":"2026-09-08T15:39:16.015Z","contentChangedAt":"2026-09-08T15:39:16.015Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}