Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK-3328] Fix classCastException from while reading PE variable #497

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ <T> void defineVariable(final Object instance, String name, T value, String kind
// we first call var.define(..) with field name, value and kind
final Var<T> var = Var.define(name, value, kind, ctVariables);
if (var == null) {
log("Something went wrong, var is null, returning");
log("Something went wrong, variable '" + name + "' is null, returning");
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public static <T> Var<T> define(String name, T defaultValue, String kind, CTVari
log("Variable name starts or ends with a `.` which is not allowed: " + name);
return null;
}
if (defaultValue == null) {
Logger.d("Invalid Operation! Null values are not allowed as default values when defining the variable '"
+ name + "'.");
return null;
}

Var<T> existing = ctVariables.getVarCache().getVariable(name);
if (existing != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class VarCacheTest : BaseTestCase() {

parser.parseVariables(NullDefaultValue())

assertNull(varCache.getVariable<Int>("string_with_null").value())
assertNull(varCache.getVariable<Int>("string_with_null"))
}

@Test
Expand All @@ -58,7 +58,7 @@ class VarCacheTest : BaseTestCase() {

Var.define<String>("var_string", null, ctVariables)

assertNull(varCache.getVariable<Int>("var_string").value())
assertNull(varCache.getVariable<Int>("var_string"))
}

@Test
Expand Down
Loading