Skip to content

Commit

Permalink
Merge branch 'main' into update-u11-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
RDPerera authored Nov 25, 2024
2 parents 02348c8 + 6b3cf27 commit 6b7005b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.ballerina.lib.data.jsondata.utils.DiagnosticErrorCode;
import io.ballerina.lib.data.jsondata.utils.DiagnosticLog;
import io.ballerina.runtime.api.Environment;
import io.ballerina.runtime.api.concurrent.StrandMetadata;
import io.ballerina.runtime.api.types.MethodType;
import io.ballerina.runtime.api.values.BArray;
import io.ballerina.runtime.api.values.BError;
Expand Down Expand Up @@ -83,7 +82,7 @@ public int read() {
public void close() throws IOException {
super.close();
if (closeMethod != null) {
env.getRuntime().callMethod(iterator, closeMethod.getName(), new StrandMetadata(false, null));
env.getRuntime().callMethod(iterator, closeMethod.getName(), null);
}
}

Expand All @@ -93,7 +92,7 @@ private boolean hasBytesInCurrentChunk() {

private boolean readNextChunk() throws InterruptedException {
try {
Object result = env.getRuntime().callMethod(iterator, nextMethodName, new StrandMetadata(false, null));
Object result = env.getRuntime().callMethod(iterator, nextMethodName, null);
if (result == null) {
done = true;
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ public static Object parseBytes(BArray json, BMap<BString, Object> options, BTyp

public static Object parseStream(Environment env, BStream json, BMap<BString, Object> options, BTypedesc typed) {
final BObject iteratorObj = json.getIteratorObj();
BallerinaByteBlockInputStream byteBlockSteam = new BallerinaByteBlockInputStream(env,
iteratorObj, resolveNextMethod(iteratorObj), resolveCloseMethod(iteratorObj));
Object result = JsonParser.parse(new InputStreamReader(byteBlockSteam), options, typed);
if (byteBlockSteam.getError() != null) {
return byteBlockSteam.getError();
}
return result;
return env.yieldAndRun(() -> {
BallerinaByteBlockInputStream byteBlockSteam = new BallerinaByteBlockInputStream(env, iteratorObj,
resolveNextMethod(iteratorObj), resolveCloseMethod(iteratorObj));
Object result = JsonParser.parse(new InputStreamReader(byteBlockSteam), options, typed);
if (byteBlockSteam.getError() != null) {
return byteBlockSteam.getError();
}
return result;
});
}

public static Object toJson(Object value) {
Expand Down

0 comments on commit 6b7005b

Please sign in to comment.