Skip to content

Commit

Permalink
Fix following bugs:
Browse files Browse the repository at this point in the history
* Fix serializing not working for array objects
* Fix callback function not working
* Fix interpreter warning being displayed
  • Loading branch information
shanggeeth committed Jan 5, 2024
1 parent f16e12b commit ffab507
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void setSource(String source) {
@Override
public boolean isFunction() {

return isHostFunction;
return isPolyglotFunction;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,21 @@ public static Object toJsSerializableInternal(Object value) {
return valueObj.asDate();
} else if (valueObj.isBoolean()) {
return valueObj.asBoolean();
} else if (valueObj.isDuration()) {
return valueObj.asDuration();
} else if (valueObj.isTime()) {
return valueObj.asTime();
} else if (valueObj.isTimeZone()) {
return valueObj.asTimeZone();
} else if (valueObj.isNull()) {
return null;
} else if (valueObj.hasArrayElements()) {
int arraySize = (int) valueObj.getArraySize();
List<Serializable> arrayItems = new ArrayList<>(arraySize);
for (int key = 0; key < arraySize; key++) {
Object serializedObj = (valueObj.getArrayElement(key));
if (serializedObj instanceof Serializable) {
arrayItems.add((Serializable) serializedObj);
if (log.isDebugEnabled()) {
log.debug("Serialized the value of array item as : " + serializedObj);
}
} else {
log.warn(String.format("Non serializable array item: %s. and will not be persisted.",
serializedObj));
}
Object arrayObj = valueObj.getArrayElement(key);
Object serializedObj = toJsSerializableInternal(arrayObj);
arrayItems.add((Serializable) serializedObj);
}
return arrayItems;
} else if (valueObj.hasMembers()) {
Expand All @@ -105,20 +106,11 @@ public static Object toJsSerializableInternal(Object value) {
}
});
return serializedMap;
} else if (valueObj.isDuration()) {
return valueObj.asDuration();
} else if (valueObj.isTime()) {
return valueObj.asTime();
} else if (valueObj.isTimeZone()) {
return valueObj.asTimeZone();
} else if (valueObj.isNull()) {
return null;
} else {
return Collections.EMPTY_MAP;
}
}
return value;

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public Context createEngine(AuthenticationContext authenticationContext) {

Context context =
Context.newBuilder(FrameworkConstants.JSAttributes.POLYGLOT_LANGUAGE).allowHostAccess(HostAccess.ALL)
.option("engine.WarnInterpreterOnly", "false")
.build();

Value bindings = context.getBindings(FrameworkConstants.JSAttributes.POLYGLOT_LANGUAGE);
Expand Down

0 comments on commit ffab507

Please sign in to comment.