[2.x] fix: Add null check for resource URL in ResourceLoader.getPropertiesFor (#8641)

**Problem**
getPropertiesFor method calls getResource().openStream() without checking
if getResource returns null. When a resource doesn't exist, this causes
a NullPointerException with no context about which resource was missing.

**Solution**
Added null check before calling openStream() and throw a descriptive
FileNotFoundException with the resource name if the resource is not found.
This prevents NullPointerException and provides better error messages.

Generated-by: Auto
This commit is contained in:
bohdansolovie 2026-01-28 07:05:03 -08:00 committed by GitHub
parent cc0915fed9
commit aa4ac5b981
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -14,7 +14,11 @@ import java.util.Properties
private[inc] object ResourceLoader {
def getPropertiesFor(resource: String): Properties = {
val properties = new Properties
val propertiesStream = getClass.getResource(resource).openStream
val resourceUrl = getClass.getResource(resource)
if (resourceUrl eq null) {
throw new java.io.FileNotFoundException(s"Resource not found: $resource")
}
val propertiesStream = resourceUrl.openStream
try {
properties.load(propertiesStream)
} finally propertiesStream.close()