Fix NPE when targetType is null (#239)
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
diff --git a/impl/src/main/java/com/sun/el/parser/AstValue.java b/impl/src/main/java/com/sun/el/parser/AstValue.java
index dfe0f82..0b86e6e 100644
--- a/impl/src/main/java/com/sun/el/parser/AstValue.java
+++ b/impl/src/main/java/com/sun/el/parser/AstValue.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -217,7 +217,7 @@
if (ctx.isPropertyResolved()) {
value = targetValue;
} else {
- if (value != null || targetType.isPrimitive()) {
+ if (value != null || (targetType != null && targetType.isPrimitive())) {
value = ELSupport.coerceToType(value, targetType);
}
}