From ee0538b412d4f9fce6f3a9bb04744edee936955b Mon Sep 17 00:00:00 2001 From: ravinperera00 Date: Thu, 3 Oct 2024 23:03:49 +0530 Subject: [PATCH 1/4] Migrate to Java 21 --- .../workflows/build-timestamped-master.yml | 2 +- .../workflows/build-with-bal-test-graalvm.yml | 2 +- .github/workflows/central-publish.yml | 2 +- .github/workflows/publish-release.yml | 2 +- .github/workflows/pull-request.yml | 2 +- .github/workflows/trivy-scan.yml | 2 +- README.md | 2 +- ballerina/CompilerPlugin.toml | 2 +- build-config/resources/Ballerina.toml | 4 +- compiler-plugin-test/build.gradle | 7 +- compiler-plugin/build.gradle | 7 +- gradle.properties | 10 +- native/build.gradle | 7 +- .../io/ballerina/lib/data/yaml/Native.java | 23 ++-- .../io/BallerinaByteBlockInputStream.java | 97 +++++----------- .../lib/data/yaml/io/DataReaderTask.java | 107 ------------------ .../lib/data/yaml/utils/DataReader.java | 58 ++++++++++ 17 files changed, 130 insertions(+), 206 deletions(-) delete mode 100644 native/src/main/java/io/ballerina/lib/data/yaml/io/DataReaderTask.java create mode 100644 native/src/main/java/io/ballerina/lib/data/yaml/utils/DataReader.java diff --git a/.github/workflows/build-timestamped-master.yml b/.github/workflows/build-timestamped-master.yml index 72d594a..6411caf 100644 --- a/.github/workflows/build-timestamped-master.yml +++ b/.github/workflows/build-timestamped-master.yml @@ -14,5 +14,5 @@ jobs: call_workflow: name: Run Build Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/build-timestamp-master-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/build-timestamp-master-template.yml@java21 secrets: inherit diff --git a/.github/workflows/build-with-bal-test-graalvm.yml b/.github/workflows/build-with-bal-test-graalvm.yml index 291054d..a66ffb5 100644 --- a/.github/workflows/build-with-bal-test-graalvm.yml +++ b/.github/workflows/build-with-bal-test-graalvm.yml @@ -30,7 +30,7 @@ jobs: call_stdlib_workflow: name: Run StdLib Workflow if: ${{ github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository_owner == 'ballerina-platform') }} - uses: ballerina-platform/ballerina-library/.github/workflows/build-with-bal-test-graalvm-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/build-with-bal-test-graalvm-template.yml@java21 with: lang_tag: ${{ inputs.lang_tag }} lang_version: ${{ inputs.lang_version }} diff --git a/.github/workflows/central-publish.yml b/.github/workflows/central-publish.yml index 11922b5..ebe213e 100644 --- a/.github/workflows/central-publish.yml +++ b/.github/workflows/central-publish.yml @@ -15,7 +15,7 @@ jobs: call_workflow: name: Run Central Publish Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/central-publish-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/central-publish-template.yml@java21 secrets: inherit with: environment: ${{ github.event.inputs.environment }} diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 0729811..6305cef 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -9,7 +9,7 @@ jobs: call_workflow: name: Run Release Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/release-package-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/release-package-template.yml@java21 secrets: inherit with: package-name: data.yaml diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 06f4f56..f45c742 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -10,5 +10,5 @@ jobs: call_workflow: name: Run PR Build Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/pull-request-build-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/pull-request-build-template.yml@java21 secrets: inherit diff --git a/.github/workflows/trivy-scan.yml b/.github/workflows/trivy-scan.yml index 2f7999d..684db29 100644 --- a/.github/workflows/trivy-scan.yml +++ b/.github/workflows/trivy-scan.yml @@ -9,5 +9,5 @@ jobs: call_workflow: name: Run Trivy Scan Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/trivy-scan-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/trivy-scan-template.yml@java21 secrets: inherit diff --git a/README.md b/README.md index 8cea993..6022a2d 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ This repository only contains the source code for the package. ### Set up the prerequisites -1. Download and install Java SE Development Kit (JDK) version 17 (from one of the following locations). +1. Download and install Java SE Development Kit (JDK) version 21 (from one of the following locations). * [Oracle](https://www.oracle.com/java/technologies/downloads/) * [OpenJDK](https://adoptium.net/) diff --git a/ballerina/CompilerPlugin.toml b/ballerina/CompilerPlugin.toml index 4779f00..0cdf04a 100644 --- a/ballerina/CompilerPlugin.toml +++ b/ballerina/CompilerPlugin.toml @@ -3,4 +3,4 @@ id = "constraint-compiler-plugin" class = "io.ballerina.lib.data.yaml.compiler.YamlDataCompilerPlugin" [[dependency]] -path = "../compiler-plugin/build/libs/data.yaml-compiler-plugin-0.1.0.jar" +path = "../compiler-plugin/build/libs/data.yaml-compiler-plugin-0.1.1-SNAPSHOT.jar" diff --git a/build-config/resources/Ballerina.toml b/build-config/resources/Ballerina.toml index 997fd8c..620afec 100644 --- a/build-config/resources/Ballerina.toml +++ b/build-config/resources/Ballerina.toml @@ -11,14 +11,14 @@ distribution = "2201.10.0" [platform.java17] graalvmCompatible = true -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.ballerina.lib" artifactId = "yaml-native" version = "@toml.version@" path = "../native/build/libs/data.yaml-native-@project.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.ballerina.stdlib" artifactId = "constraint-native" version = "@constraint.version@" diff --git a/compiler-plugin-test/build.gradle b/compiler-plugin-test/build.gradle index 4cf6c41..b828e9f 100644 --- a/compiler-plugin-test/build.gradle +++ b/compiler-plugin-test/build.gradle @@ -49,8 +49,11 @@ checkstyle { checkstyleTest.dependsOn(":checkstyle:downloadCheckstyleRuleFiles") spotbugsTest { - effort "max" - reportLevel "low" + def classLoader = plugins["com.github.spotbugs"].class.classLoader + def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence") + def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort") + effort = SpotBugsEffort.MAX + reportLevel = SpotBugsConfidence.LOW reportsDir = file("$project.buildDir/reports/spotbugs") reports { html.enabled true diff --git a/compiler-plugin/build.gradle b/compiler-plugin/build.gradle index cc15f5f..c59ed38 100644 --- a/compiler-plugin/build.gradle +++ b/compiler-plugin/build.gradle @@ -47,8 +47,11 @@ checkstyle { checkstyleMain.dependsOn(":checkstyle:downloadCheckstyleRuleFiles") spotbugsMain { - effort "max" - reportLevel "low" + def classLoader = plugins["com.github.spotbugs"].class.classLoader + def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence") + def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort") + effort = SpotBugsEffort.MAX + reportLevel = SpotBugsConfidence.LOW reportsDir = file("$project.buildDir/reports/spotbugs") reports { html.enabled true diff --git a/gradle.properties b/gradle.properties index e9c80d7..be42035 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,13 +1,13 @@ org.gradle.caching=true group=io.ballerina.lib version=0.1.1-SNAPSHOT -ballerinaLangVersion=2201.10.0 +ballerinaLangVersion=2201.10.0-20241002-115300-57eee14c checkstyleToolVersion=10.12.0 puppycrawlCheckstyleVersion=10.12.0 testngVersion=7.6.1 slf4jVersion=2.0.7 -githubSpotbugsVersion=5.0.14 +githubSpotbugsVersion=6.0.18 githubJohnrengelmanShadowVersion=8.1.1 underCouchDownloadVersion=4.0.4 researchgateReleaseVersion=2.8.0 @@ -17,6 +17,6 @@ downloadPluginVersion=4.0.4 releasePluginVersion=2.8.0 ballerinaGradlePluginVersion=2.0.1 -stdlibIoVersion=1.6.1 -stdlibConstraintVersion=1.5.0 -stdlibTimeVersion=2.4.0 +stdlibIoVersion=1.6.2-20240928-084100-656404f +stdlibConstraintVersion=1.5.1-20240930-123400-5ecd396 +stdlibTimeVersion=2.5.1-20240930-120200-e59222b diff --git a/native/build.gradle b/native/build.gradle index 1460e11..4cacfc7 100644 --- a/native/build.gradle +++ b/native/build.gradle @@ -51,9 +51,12 @@ tasks.withType(Checkstyle) { } spotbugsMain { + def classLoader = plugins["com.github.spotbugs"].class.classLoader + def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence") + def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort") enabled=false - effort "max" - reportLevel "low" + effort = SpotBugsEffort.MAX + reportLevel = SpotBugsConfidence.LOW reportsDir = file("$project.buildDir/reports/spotbugs") reports { html.enabled true diff --git a/native/src/main/java/io/ballerina/lib/data/yaml/Native.java b/native/src/main/java/io/ballerina/lib/data/yaml/Native.java index b827115..66e5374 100644 --- a/native/src/main/java/io/ballerina/lib/data/yaml/Native.java +++ b/native/src/main/java/io/ballerina/lib/data/yaml/Native.java @@ -19,13 +19,12 @@ package io.ballerina.lib.data.yaml; import io.ballerina.lib.data.yaml.emitter.Emitter; -import io.ballerina.lib.data.yaml.io.DataReaderTask; -import io.ballerina.lib.data.yaml.io.DataReaderThreadPool; +import io.ballerina.lib.data.yaml.io.BallerinaByteBlockInputStream; import io.ballerina.lib.data.yaml.parser.YamlParser; import io.ballerina.lib.data.yaml.serializer.Serializer; +import io.ballerina.lib.data.yaml.utils.DiagnosticLog; import io.ballerina.lib.data.yaml.utils.OptionsUtils; import io.ballerina.runtime.api.Environment; -import io.ballerina.runtime.api.Future; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BError; @@ -40,6 +39,9 @@ import java.io.StringReader; import java.util.List; +import static io.ballerina.lib.data.yaml.utils.DataReader.resolveCloseMethod; +import static io.ballerina.lib.data.yaml.utils.DataReader.resolveNextMethod; + /** * This class is used to convert json inform of string, byte[], byte-stream to record or json type. * @@ -69,10 +71,17 @@ public static Object parseBytes(BArray yaml, BMap options, BTyp public static Object parseStream(Environment env, BStream yaml, BMap options, BTypedesc typed) { final BObject iteratorObj = yaml.getIteratorObj(); - final Future future = env.markAsync(); - DataReaderTask task = new DataReaderTask(env, iteratorObj, future, typed, options); - DataReaderThreadPool.EXECUTOR_SERVICE.submit(task); - return null; + try { + BallerinaByteBlockInputStream byteBlockSteam = new BallerinaByteBlockInputStream(env, + iteratorObj, resolveNextMethod(iteratorObj), resolveCloseMethod(iteratorObj)); + Object result = YamlParser.compose(new InputStreamReader(byteBlockSteam), options, typed); + if (byteBlockSteam.getError() != null) { + return byteBlockSteam.getError(); + } + return result; + } catch (Exception e) { + return DiagnosticLog.getYamlError("Error occurred while reading the stream: " + e.getMessage()); + } } public static Object toYamlStringArray(Object yamlValue, BMap config) { diff --git a/native/src/main/java/io/ballerina/lib/data/yaml/io/BallerinaByteBlockInputStream.java b/native/src/main/java/io/ballerina/lib/data/yaml/io/BallerinaByteBlockInputStream.java index 9c1100a..6b6e917 100644 --- a/native/src/main/java/io/ballerina/lib/data/yaml/io/BallerinaByteBlockInputStream.java +++ b/native/src/main/java/io/ballerina/lib/data/yaml/io/BallerinaByteBlockInputStream.java @@ -20,10 +20,7 @@ import io.ballerina.lib.data.yaml.utils.DiagnosticLog; import io.ballerina.runtime.api.Environment; -import io.ballerina.runtime.api.async.Callback; -import io.ballerina.runtime.api.async.StrandMetadata; import io.ballerina.runtime.api.types.MethodType; -import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BMap; @@ -33,38 +30,26 @@ import java.io.IOException; import java.io.InputStream; import java.util.Arrays; -import java.util.Map; -import java.util.concurrent.Semaphore; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Consumer; public class BallerinaByteBlockInputStream extends InputStream { private final BObject iterator; private final Environment env; private final String nextMethodName; - private final Type returnType; - private final String strandName; - private final StrandMetadata metadata; - private final Map properties; private final AtomicBoolean done = new AtomicBoolean(false); private final MethodType closeMethod; - private final Consumer futureResultConsumer; + private BError error = null; private byte[] currentChunk = new byte[0]; private int nextChunkIndex = 0; public BallerinaByteBlockInputStream(Environment env, BObject iterator, MethodType nextMethod, - MethodType closeMethod, Consumer futureResultConsumer) { + MethodType closeMethod) { this.env = env; this.iterator = iterator; this.nextMethodName = nextMethod.getName(); - this.returnType = nextMethod.getReturnType(); this.closeMethod = closeMethod; - this.strandName = env.getStrandName().orElse(""); - this.metadata = env.getStrandMetadata(); - this.properties = Map.of(); - this.futureResultConsumer = futureResultConsumer; } @Override @@ -82,8 +67,7 @@ public int read() { return read(); } } catch (InterruptedException e) { - BError error = DiagnosticLog.getYamlError("Cannot read the stream, interrupted error"); - futureResultConsumer.accept(error); + this.error = DiagnosticLog.getYamlError("Cannot read the stream, interrupted error"); return -1; } return -1; @@ -92,25 +76,8 @@ public int read() { @Override public void close() throws IOException { super.close(); - Semaphore semaphore = new Semaphore(0); if (closeMethod != null) { - env.getRuntime().invokeMethodAsyncSequentially(iterator, closeMethod.getName(), strandName, metadata, - new Callback() { - @Override - public void notifyFailure(BError bError) { - semaphore.release(); - } - - @Override - public void notifySuccess(Object result) { - semaphore.release(); - } - }, properties, returnType); - } - try { - semaphore.acquire(); - } catch (InterruptedException e) { - throw new IOException("Error while closing the stream", e); + env.getRuntime().call(iterator, closeMethod.getName()); } } @@ -119,44 +86,32 @@ private boolean hasBytesInCurrentChunk() { } private boolean readNextChunk() throws InterruptedException { - Semaphore semaphore = new Semaphore(0); - Callback callback = new Callback() { - - @Override - public void notifyFailure(BError bError) { - // Panic with an error + try { + Object result = env.getRuntime().call(iterator, nextMethodName); + if (result == null) { done.set(true); - futureResultConsumer.accept(bError); - currentChunk = new byte[0]; - semaphore.release(); - // TODO : Should we panic here? + return true; } - - @Override - public void notifySuccess(Object result) { - if (result == null) { - done.set(true); - currentChunk = new byte[0]; - semaphore.release(); - return; - } - if (result instanceof BMap) { - BMap valueRecord = (BMap) result; - final BString value = Arrays.stream(valueRecord.getKeys()).findFirst().get(); - final BArray arrayValue = valueRecord.getArrayValue(value); - currentChunk = arrayValue.getByteArray(); - semaphore.release(); - } else { - // Case where Completes with an error - done.set(true); - semaphore.release(); - } + if (result instanceof BMap) { + BMap valueRecord = (BMap) result; + final BString value = Arrays.stream(valueRecord.getKeys()).findFirst().get(); + final BArray arrayValue = valueRecord.getArrayValue(value); + currentChunk = arrayValue.getByteArray(); + } else { + // Case where Completes with an error + done.set(true); } + } catch (BError bError) { + // Panic with an error + done.set(true); + currentChunk = new byte[0]; + // TODO : Should we panic here? + } - }; - env.getRuntime().invokeMethodAsyncSequentially(iterator, nextMethodName, strandName, metadata, callback, - properties, returnType); - semaphore.acquire(); return !done.get(); } + + public BError getError() { + return this.error; + } } diff --git a/native/src/main/java/io/ballerina/lib/data/yaml/io/DataReaderTask.java b/native/src/main/java/io/ballerina/lib/data/yaml/io/DataReaderTask.java deleted file mode 100644 index ebafb13..0000000 --- a/native/src/main/java/io/ballerina/lib/data/yaml/io/DataReaderTask.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.lib.data.yaml.io; - -import io.ballerina.lib.data.yaml.parser.YamlParser; -import io.ballerina.lib.data.yaml.utils.DiagnosticLog; -import io.ballerina.runtime.api.Environment; -import io.ballerina.runtime.api.Future; -import io.ballerina.runtime.api.types.MethodType; -import io.ballerina.runtime.api.types.ObjectType; -import io.ballerina.runtime.api.utils.TypeUtils; -import io.ballerina.runtime.api.values.BMap; -import io.ballerina.runtime.api.values.BObject; -import io.ballerina.runtime.api.values.BString; -import io.ballerina.runtime.api.values.BTypedesc; - -import java.io.InputStreamReader; -import java.util.function.Consumer; - -public class DataReaderTask implements Runnable { - - private static final String METHOD_NAME_NEXT = "next"; - private static final String METHOD_NAME_CLOSE = "close"; - - private final Environment env; - private final BObject iteratorObj; - private final Future future; - private final BTypedesc typed; - private final BMap options; - - public DataReaderTask(Environment env, BObject iteratorObj, Future future, BTypedesc typed, - BMap options) { - this.env = env; - this.iteratorObj = iteratorObj; - this.future = future; - this.typed = typed; - this.options = options; - } - - static MethodType resolveNextMethod(BObject iterator) { - MethodType method = getMethodType(iterator, METHOD_NAME_NEXT); - if (method != null) { - return method; - } - throw new IllegalStateException("next method not found in the iterator object"); - } - - static MethodType resolveCloseMethod(BObject iterator) { - return getMethodType(iterator, METHOD_NAME_CLOSE); - } - - private static MethodType getMethodType(BObject iterator, String methodNameClose) { - ObjectType objectType = (ObjectType) TypeUtils.getReferredType(iterator.getOriginalType()); - MethodType[] methods = objectType.getMethods(); - // Assumes compile-time validation of the iterator object - for (MethodType method : methods) { - if (method.getName().equals(methodNameClose)) { - return method; - } - } - return null; - } - - @Override - public void run() { - ResultConsumer resultConsumer = new ResultConsumer<>(future); - try (var byteBlockSteam = new BallerinaByteBlockInputStream(env, iteratorObj, resolveNextMethod(iteratorObj), - resolveCloseMethod(iteratorObj), resultConsumer)) { - Object result = YamlParser.compose(new InputStreamReader(byteBlockSteam), - options, typed); - future.complete(result); - } catch (Exception e) { - future.complete(DiagnosticLog.getYamlError("Error occurred while reading the stream: " + e.getMessage())); - } - } - - /** - * This class will hold module related utility functions. - * - * @param The type of the result - * @param future The future to complete - * @since 0.1.0 - */ - public record ResultConsumer(Future future) implements Consumer { - - @Override - public void accept(T t) { - future.complete(t); - } - } -} diff --git a/native/src/main/java/io/ballerina/lib/data/yaml/utils/DataReader.java b/native/src/main/java/io/ballerina/lib/data/yaml/utils/DataReader.java new file mode 100644 index 0000000..dac9163 --- /dev/null +++ b/native/src/main/java/io/ballerina/lib/data/yaml/utils/DataReader.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.ballerina.lib.data.yaml.utils; + +import io.ballerina.runtime.api.types.MethodType; +import io.ballerina.runtime.api.types.ObjectType; +import io.ballerina.runtime.api.utils.TypeUtils; +import io.ballerina.runtime.api.values.BObject; + +/** + * A class that holds util methods needed for BallerinaByteBlockInputStream class. + * + * @since 11.0.0 + */ +public class DataReader { + private static final String METHOD_NAME_NEXT = "next"; + private static final String METHOD_NAME_CLOSE = "close"; + + public static MethodType resolveNextMethod(BObject iterator) { + MethodType method = getMethodType(iterator, METHOD_NAME_NEXT); + if (method != null) { + return method; + } + throw new IllegalStateException("next method not found in the iterator object"); + } + + public static MethodType resolveCloseMethod(BObject iterator) { + return getMethodType(iterator, METHOD_NAME_CLOSE); + } + + private static MethodType getMethodType(BObject iterator, String methodNameClose) { + ObjectType objectType = (ObjectType) TypeUtils.getReferredType(iterator.getOriginalType()); + MethodType[] methods = objectType.getMethods(); + // Assumes compile-time validation of the iterator object + for (MethodType method : methods) { + if (method.getName().equals(methodNameClose)) { + return method; + } + } + return null; + } +} From 9cfb2dc5402453576d75c5a15c694abc10f99e92 Mon Sep 17 00:00:00 2001 From: ravinperera00 Date: Thu, 3 Oct 2024 23:07:00 +0530 Subject: [PATCH 2/4] Downgrade the stdlibTime version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index be42035..daeadcb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,4 +19,4 @@ ballerinaGradlePluginVersion=2.0.1 stdlibIoVersion=1.6.2-20240928-084100-656404f stdlibConstraintVersion=1.5.1-20240930-123400-5ecd396 -stdlibTimeVersion=2.5.1-20240930-120200-e59222b +stdlibTimeVersion=2.4.0 From bebc55abcaa0fbba82e910eea7d27c1470062462 Mon Sep 17 00:00:00 2001 From: ravinperera00 Date: Fri, 4 Oct 2024 00:03:39 +0530 Subject: [PATCH 3/4] Update stdlibTime version --- ballerina/Dependencies.toml | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index 56102a3..cd9d8f1 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -116,7 +116,7 @@ modules = [ [[package]] org = "ballerina" name = "time" -version = "2.4.0" +version = "2.5.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"} diff --git a/gradle.properties b/gradle.properties index daeadcb..f81e3d3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,4 +19,4 @@ ballerinaGradlePluginVersion=2.0.1 stdlibIoVersion=1.6.2-20240928-084100-656404f stdlibConstraintVersion=1.5.1-20240930-123400-5ecd396 -stdlibTimeVersion=2.4.0 +stdlibTimeVersion=2.5.1-20241003-232800-e59222b From bfaff3e0422ca675bfba04f52a9695a5c5b6bd4c Mon Sep 17 00:00:00 2001 From: ravinperera00 Date: Tue, 8 Oct 2024 16:33:54 +0530 Subject: [PATCH 4/4] Change data type of done attribute --- .../data/yaml/io/BallerinaByteBlockInputStream.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/native/src/main/java/io/ballerina/lib/data/yaml/io/BallerinaByteBlockInputStream.java b/native/src/main/java/io/ballerina/lib/data/yaml/io/BallerinaByteBlockInputStream.java index 6b6e917..88327be 100644 --- a/native/src/main/java/io/ballerina/lib/data/yaml/io/BallerinaByteBlockInputStream.java +++ b/native/src/main/java/io/ballerina/lib/data/yaml/io/BallerinaByteBlockInputStream.java @@ -30,14 +30,13 @@ import java.io.IOException; import java.io.InputStream; import java.util.Arrays; -import java.util.concurrent.atomic.AtomicBoolean; public class BallerinaByteBlockInputStream extends InputStream { private final BObject iterator; private final Environment env; private final String nextMethodName; - private final AtomicBoolean done = new AtomicBoolean(false); + private boolean done = false; private final MethodType closeMethod; private BError error = null; @@ -54,7 +53,7 @@ public BallerinaByteBlockInputStream(Environment env, BObject iterator, MethodTy @Override public int read() { - if (done.get()) { + if (this.done) { return -1; } if (hasBytesInCurrentChunk()) { @@ -89,7 +88,7 @@ private boolean readNextChunk() throws InterruptedException { try { Object result = env.getRuntime().call(iterator, nextMethodName); if (result == null) { - done.set(true); + this.done = true; return true; } if (result instanceof BMap) { @@ -99,16 +98,16 @@ private boolean readNextChunk() throws InterruptedException { currentChunk = arrayValue.getByteArray(); } else { // Case where Completes with an error - done.set(true); + this.done = true; } } catch (BError bError) { // Panic with an error - done.set(true); + this.done = true; currentChunk = new byte[0]; // TODO : Should we panic here? } - return !done.get(); + return !this.done; } public BError getError() {