- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38.8k
Closed as not planned
Description
Environment:
- Spring Framework: 6.2.10
- Java: 17
package org.springframework.core.io;
	/**
	 * Return a {@code Resource} handle for the specified resource location.
	 * <p>The handle should always be a reusable resource descriptor,
	 * allowing for multiple {@link Resource#getInputStream()} calls.
	 * <p><ul>
	 * <li>Must support fully qualified URLs, for example, "file:C:/test.dat".
	 * <li>Must support classpath pseudo-URLs, for example, "classpath:test.dat".
	 * <li>Should support relative file paths, for example, "WEB-INF/test.dat".
	 * (This will be implementation-specific, typically provided by an
	 * ApplicationContext implementation.)
	 * </ul>
	 * <p>Note that a {@code Resource} handle does not imply an existing resource;
	 * you need to invoke {@link Resource#exists} to check for existence.
	 * @param location the resource location
	 * @return a corresponding {@code Resource} handle (never {@code null})
	 * @see #CLASSPATH_URL_PREFIX
	 * @see Resource#exists()
	 * @see Resource#getInputStream()
	 */
	Resource getResource(String location);location = applicationContext.getEnvironment().resolvePlaceholders(location);
Resource resource = applicationContext.getResource(location);
if (resource != null && resource.exists()) {
	resources.add(resource);
}Even though getResource could not return null, the exception occur.
java.lang.NullPointerException: Cannot invoke "org.springframework.core.io.Resource.exists()" because "resource" is nullMetadata
Metadata
Assignees
Labels
No labels