From 7d7fd78d21078af875d14b2dc034bb21560eba16 Mon Sep 17 00:00:00 2001 From: dsplayerX Date: Tue, 18 Jun 2024 12:28:57 +0530 Subject: [PATCH 01/15] Add new transaction configuration values This commit introduces two new configurations values for transactions, `transactionAutoCommitTimeout` and `transactionCleanupTimeout` --- .../transactions/TransactionConstants.java | 2 + .../TransactionResourceManager.java | 58 +++++++++++++++++++ .../src/main/ballerina/transaction.bal | 4 ++ 3 files changed, 64 insertions(+) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionConstants.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionConstants.java index 345b8f82cac1..f7ee5d9e9d8a 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionConstants.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionConstants.java @@ -70,4 +70,6 @@ public class TransactionConstants { public static final String ANN_NAME_TRX_PARTICIPANT_CONFIG = "Participant"; public static final String TIMESTAMP_OBJECT_VALUE_FIELD = "timeValue"; + public static final int DEFAULT_TRX_AUTO_COMMIT_TIMEOUT = 120; + public static final int DEFAULT_TRX_CLEANUP_TIMEOUT = 600; } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java index 739c34fdf6aa..c378bb7c7a8b 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java @@ -59,6 +59,8 @@ import javax.transaction.xa.Xid; import static io.ballerina.runtime.api.constants.RuntimeConstants.BALLERINA_BUILTIN_PKG_PREFIX; +import static io.ballerina.runtime.transactions.TransactionConstants.DEFAULT_TRX_AUTO_COMMIT_TIMEOUT; +import static io.ballerina.runtime.transactions.TransactionConstants.DEFAULT_TRX_CLEANUP_TIMEOUT; import static io.ballerina.runtime.transactions.TransactionConstants.TRANSACTION_PACKAGE_ID; import static io.ballerina.runtime.transactions.TransactionConstants.TRANSACTION_PACKAGE_NAME; import static io.ballerina.runtime.transactions.TransactionConstants.TRANSACTION_PACKAGE_VERSION; @@ -186,6 +188,62 @@ private String getTransactionLogDirectory() { } } + /** + * This method gets the user specified config for the transaction auto commit timeout. Default is 120. + * + * @return int transaction auto commit timeout value + */ + public int getTransactionAutoCommitTimeout() { + VariableKey transactionAutoCommitTimeoutKey = new VariableKey(TRANSACTION_PACKAGE_ID, + "transactionAutoCommitTimeout", PredefinedTypes.TYPE_INT, false); + if (!ConfigMap.containsKey(transactionAutoCommitTimeoutKey)) { + return DEFAULT_TRX_AUTO_COMMIT_TIMEOUT; + } else { + int transactionAutoCommitTimeout; + Object value = ConfigMap.get(transactionAutoCommitTimeoutKey); + if (value instanceof Long) { + transactionAutoCommitTimeout = ((Long) value).intValue(); + } else if (value instanceof Integer) { + transactionAutoCommitTimeout = (Integer) value; + } else { + return DEFAULT_TRX_AUTO_COMMIT_TIMEOUT; + } + if (transactionAutoCommitTimeout < DEFAULT_TRX_AUTO_COMMIT_TIMEOUT) { + return DEFAULT_TRX_AUTO_COMMIT_TIMEOUT; + } else { + return transactionAutoCommitTimeout; + } + } + } + + /** + * This method gets the user specified config for cleaning up dead transactions. Default is 600. + * + * @return int transaction cleanup after value + */ + public int getTransactionCleanupTimeout() { + VariableKey transactionCleanupTimeoutKey = new VariableKey(TRANSACTION_PACKAGE_ID, "transactionCleanupTimeout", + PredefinedTypes.TYPE_INT, false); + if (!ConfigMap.containsKey(transactionCleanupTimeoutKey)) { + return DEFAULT_TRX_CLEANUP_TIMEOUT; + } else { + int transactionCleanupTimeout; + Object value = ConfigMap.get(transactionCleanupTimeoutKey); + if (value instanceof Long) { + transactionCleanupTimeout = ((Long) value).intValue(); + } else if (value instanceof Integer) { + transactionCleanupTimeout = (Integer) value; + } else { + return DEFAULT_TRX_CLEANUP_TIMEOUT; + } + if (transactionCleanupTimeout < DEFAULT_TRX_CLEANUP_TIMEOUT) { + return DEFAULT_TRX_CLEANUP_TIMEOUT; + } else { + return transactionCleanupTimeout; + } + } + } + /** * This method will register connection resources with a particular transaction. * diff --git a/langlib/lang.transaction/src/main/ballerina/transaction.bal b/langlib/lang.transaction/src/main/ballerina/transaction.bal index 0e8bd367b713..ab62be24e215 100644 --- a/langlib/lang.transaction/src/main/ballerina/transaction.bal +++ b/langlib/lang.transaction/src/main/ballerina/transaction.bal @@ -20,6 +20,10 @@ import ballerina/jballerina.java; configurable boolean managerEnabled = false; # Config to specify transaction log directory. configurable string logBase = "transaction_log_dir"; +# Config to specify the timeout for auto commit. +configurable int transactionAutoCommitTimeout = 120; +# Config to specify the timeout for cleaning up dead transactions. +configurable int transactionCleanupTimeout = 600; //TODO: remove this in Beta2 and use an anonymous record instead # Internally used record to hold information about a transaction. From 6c2aed5b75aa3dc09dc51038450a30adc4953795 Mon Sep 17 00:00:00 2001 From: dsplayerX Date: Tue, 18 Jun 2024 17:42:22 +0530 Subject: [PATCH 02/15] Rework config default value --- .../runtime/transactions/TransactionResourceManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java index c378bb7c7a8b..ead9f3fc32df 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java @@ -208,7 +208,7 @@ public int getTransactionAutoCommitTimeout() { } else { return DEFAULT_TRX_AUTO_COMMIT_TIMEOUT; } - if (transactionAutoCommitTimeout < DEFAULT_TRX_AUTO_COMMIT_TIMEOUT) { + if (transactionAutoCommitTimeout < 0) { return DEFAULT_TRX_AUTO_COMMIT_TIMEOUT; } else { return transactionAutoCommitTimeout; @@ -236,7 +236,7 @@ public int getTransactionCleanupTimeout() { } else { return DEFAULT_TRX_CLEANUP_TIMEOUT; } - if (transactionCleanupTimeout < DEFAULT_TRX_CLEANUP_TIMEOUT) { + if (transactionCleanupTimeout < 0) { return DEFAULT_TRX_CLEANUP_TIMEOUT; } else { return transactionCleanupTimeout; From a1002a140dc3be150a13683dcdb79d88c3757a54 Mon Sep 17 00:00:00 2001 From: dsplayerX Date: Tue, 18 Jun 2024 18:52:18 +0530 Subject: [PATCH 03/15] Add runtime warnings for invalid config values --- .../runtime/internal/errors/ErrorCodes.java | 4 ++- .../TransactionResourceManager.java | 35 +++++++++++++++---- .../main/resources/MessagesBundle.properties | 5 +++ 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/errors/ErrorCodes.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/errors/ErrorCodes.java index 5017e8004d70..b2a65f8282a9 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/errors/ErrorCodes.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/errors/ErrorCodes.java @@ -157,7 +157,9 @@ public enum ErrorCodes implements DiagnosticCode { CONFIG_ENV_VAR_NAME_AMBIGUITY("config.env.variable.name.ambiguity", "RUNTIME_0127"), NO_MESSAGE_ERROR("no.worker.message.received", "RUNTIME_0128"), INVALID_METHOD_CALL("invalid.method.call", "RUNTIME_0129"), - INVALID_FUNCTION_INVOCATION("invalid.function.invocation.call", "RUNTIME_0130"); + INVALID_FUNCTION_INVOCATION("invalid.function.invocation.call", "RUNTIME_0130"), + INVALID_TRANSACTION_AUTO_COMMIT_TIMEOUT("invalid.transaction.auto.commit.value", "RUNTIME_0131"), + INVALID_TRANSACTION_CLEANUP_TIMEOUT("invalid.transaction.cleanup.timeout", "RUNTIME_0132"); private final String errorMsgKey; private final String errorCode; diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java index ead9f3fc32df..e20e7455689b 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java @@ -27,6 +27,8 @@ import io.ballerina.runtime.api.values.BString; import io.ballerina.runtime.internal.configurable.ConfigMap; import io.ballerina.runtime.internal.configurable.VariableKey; +import io.ballerina.runtime.internal.diagnostics.RuntimeDiagnosticLog; +import io.ballerina.runtime.internal.errors.ErrorCodes; import io.ballerina.runtime.internal.scheduling.Scheduler; import io.ballerina.runtime.internal.scheduling.Strand; import io.ballerina.runtime.internal.util.RuntimeUtils; @@ -101,6 +103,7 @@ public class TransactionResourceManager { private boolean transactionManagerEnabled; private static final PrintStream stderr = System.err; + RuntimeDiagnosticLog diagnosticLog = new RuntimeDiagnosticLog(); Map transactionInfoMap; @@ -196,19 +199,29 @@ private String getTransactionLogDirectory() { public int getTransactionAutoCommitTimeout() { VariableKey transactionAutoCommitTimeoutKey = new VariableKey(TRANSACTION_PACKAGE_ID, "transactionAutoCommitTimeout", PredefinedTypes.TYPE_INT, false); - if (!ConfigMap.containsKey(transactionAutoCommitTimeoutKey)) { + Object value = ConfigMap.get(transactionAutoCommitTimeoutKey); + if (value == null) { return DEFAULT_TRX_AUTO_COMMIT_TIMEOUT; } else { int transactionAutoCommitTimeout; - Object value = ConfigMap.get(transactionAutoCommitTimeoutKey); if (value instanceof Long) { transactionAutoCommitTimeout = ((Long) value).intValue(); } else if (value instanceof Integer) { transactionAutoCommitTimeout = (Integer) value; } else { + diagnosticLog.warn(ErrorCodes.INVALID_TRANSACTION_AUTO_COMMIT_TIMEOUT, null, value, + DEFAULT_TRX_AUTO_COMMIT_TIMEOUT); + if (!diagnosticLog.getDiagnosticList().isEmpty()) { + RuntimeUtils.handleDiagnosticErrors(diagnosticLog); + } return DEFAULT_TRX_AUTO_COMMIT_TIMEOUT; } - if (transactionAutoCommitTimeout < 0) { + if (transactionAutoCommitTimeout <= 0) { + diagnosticLog.warn(ErrorCodes.INVALID_TRANSACTION_CLEANUP_TIMEOUT, null, + transactionAutoCommitTimeout, DEFAULT_TRX_AUTO_COMMIT_TIMEOUT); + if (!diagnosticLog.getDiagnosticList().isEmpty()) { + RuntimeUtils.handleDiagnosticErrors(diagnosticLog); + } return DEFAULT_TRX_AUTO_COMMIT_TIMEOUT; } else { return transactionAutoCommitTimeout; @@ -224,19 +237,29 @@ public int getTransactionAutoCommitTimeout() { public int getTransactionCleanupTimeout() { VariableKey transactionCleanupTimeoutKey = new VariableKey(TRANSACTION_PACKAGE_ID, "transactionCleanupTimeout", PredefinedTypes.TYPE_INT, false); - if (!ConfigMap.containsKey(transactionCleanupTimeoutKey)) { + Object value = ConfigMap.get(transactionCleanupTimeoutKey); + if (value == null) { return DEFAULT_TRX_CLEANUP_TIMEOUT; } else { int transactionCleanupTimeout; - Object value = ConfigMap.get(transactionCleanupTimeoutKey); if (value instanceof Long) { transactionCleanupTimeout = ((Long) value).intValue(); } else if (value instanceof Integer) { transactionCleanupTimeout = (Integer) value; } else { + diagnosticLog.warn(ErrorCodes.INVALID_TRANSACTION_CLEANUP_TIMEOUT, null, value, + DEFAULT_TRX_CLEANUP_TIMEOUT); + if (!diagnosticLog.getDiagnosticList().isEmpty()) { + RuntimeUtils.handleDiagnosticErrors(diagnosticLog); + } return DEFAULT_TRX_CLEANUP_TIMEOUT; } - if (transactionCleanupTimeout < 0) { + if (transactionCleanupTimeout <= 0) { + diagnosticLog.warn(ErrorCodes.INVALID_TRANSACTION_CLEANUP_TIMEOUT, null, + transactionCleanupTimeout, DEFAULT_TRX_CLEANUP_TIMEOUT); + if (!diagnosticLog.getDiagnosticList().isEmpty()) { + RuntimeUtils.handleDiagnosticErrors(diagnosticLog); + } return DEFAULT_TRX_CLEANUP_TIMEOUT; } else { return transactionCleanupTimeout; diff --git a/bvm/ballerina-runtime/src/main/resources/MessagesBundle.properties b/bvm/ballerina-runtime/src/main/resources/MessagesBundle.properties index 1c8cc62bfa1e..fee5df3e6c0e 100644 --- a/bvm/ballerina-runtime/src/main/resources/MessagesBundle.properties +++ b/bvm/ballerina-runtime/src/main/resources/MessagesBundle.properties @@ -196,6 +196,11 @@ merge.json.error = cannot merge JSON values of types ''{0}'' and ''{1}'' field.removal.not.allowed = failed to remove field: ''{0}'' is a required field in ''{1}'' operation.not.supported = {0} not supported on type ''{1}'' invalid.fraction.digits = fraction digits cannot be less than '0' +invalid.transaction.auto.commit.timeout = provided transaction auto commit timeout of ''{0}'' is invalid, default \ + value of ''{1}'' will be used instead. +invalid.transaction.cleanup.timeout = provided transaction cleanup timeout of ''{0}'' is invalid, default value of \ + ''{1}'' will be used instead. + #configurations config.type.not.supported = configurable variable ''{0}'' with type ''{1}'' is not supported config.invalid.byte.range = [{0}] value provided for byte variable ''{1}'' is out of range. Expected range is \ From 9cb866c5a9f30e8cec05e69580e0a0cab86da88f Mon Sep 17 00:00:00 2001 From: dsplayerX Date: Tue, 18 Jun 2024 18:58:20 +0530 Subject: [PATCH 04/15] Make config keys constants --- .../runtime/transactions/TransactionResourceManager.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java index e20e7455689b..3ffe5727f4e8 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java @@ -88,6 +88,8 @@ public class TransactionResourceManager { private static final String ATOMIKOS_LOG_BASE_PROPERTY = "com.atomikos.icatch.log_base_dir"; private static final String ATOMIKOS_LOG_NAME_PROPERTY = "com.atomikos.icatch.log_base_name"; private static final String ATOMIKOS_REGISTERED_PROPERTY = "com.atomikos.icatch.registered"; + public static final String TRANSACTION_AUTO_COMMIT_TIMEOUT_KEY = "transactionAutoCommitTimeout"; + public static final String TRANSACTION_CLEANUP_TIMEOUT_KEY = "transactionCleanupTimeout"; private static final Logger log = LoggerFactory.getLogger(TransactionResourceManager.class); private Map> resourceRegistry; @@ -198,7 +200,7 @@ private String getTransactionLogDirectory() { */ public int getTransactionAutoCommitTimeout() { VariableKey transactionAutoCommitTimeoutKey = new VariableKey(TRANSACTION_PACKAGE_ID, - "transactionAutoCommitTimeout", PredefinedTypes.TYPE_INT, false); + TRANSACTION_AUTO_COMMIT_TIMEOUT_KEY, PredefinedTypes.TYPE_INT, false); Object value = ConfigMap.get(transactionAutoCommitTimeoutKey); if (value == null) { return DEFAULT_TRX_AUTO_COMMIT_TIMEOUT; @@ -235,7 +237,8 @@ public int getTransactionAutoCommitTimeout() { * @return int transaction cleanup after value */ public int getTransactionCleanupTimeout() { - VariableKey transactionCleanupTimeoutKey = new VariableKey(TRANSACTION_PACKAGE_ID, "transactionCleanupTimeout", + VariableKey transactionCleanupTimeoutKey = new VariableKey(TRANSACTION_PACKAGE_ID, + TRANSACTION_CLEANUP_TIMEOUT_KEY, PredefinedTypes.TYPE_INT, false); Object value = ConfigMap.get(transactionCleanupTimeoutKey); if (value == null) { From 8ad8080e297833f6e923242865164c4d38fafa9d Mon Sep 17 00:00:00 2001 From: dsplayerX Date: Wed, 19 Jun 2024 11:01:11 +0530 Subject: [PATCH 05/15] Address review suggestions --- .../runtime/internal/errors/ErrorCodes.java | 3 +- .../TransactionResourceManager.java | 67 ++++++------------- .../main/resources/MessagesBundle.properties | 6 +- 3 files changed, 23 insertions(+), 53 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/errors/ErrorCodes.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/errors/ErrorCodes.java index b2a65f8282a9..e06dcd55948d 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/errors/ErrorCodes.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/errors/ErrorCodes.java @@ -158,8 +158,7 @@ public enum ErrorCodes implements DiagnosticCode { NO_MESSAGE_ERROR("no.worker.message.received", "RUNTIME_0128"), INVALID_METHOD_CALL("invalid.method.call", "RUNTIME_0129"), INVALID_FUNCTION_INVOCATION("invalid.function.invocation.call", "RUNTIME_0130"), - INVALID_TRANSACTION_AUTO_COMMIT_TIMEOUT("invalid.transaction.auto.commit.value", "RUNTIME_0131"), - INVALID_TRANSACTION_CLEANUP_TIMEOUT("invalid.transaction.cleanup.timeout", "RUNTIME_0132"); + INVALID_TRANSACTION_TIMEOUT("invalid.transaction.value", "RUNTIME_0131"); private final String errorMsgKey; private final String errorCode; diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java index 3ffe5727f4e8..90822011e4b8 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java @@ -204,31 +204,8 @@ public int getTransactionAutoCommitTimeout() { Object value = ConfigMap.get(transactionAutoCommitTimeoutKey); if (value == null) { return DEFAULT_TRX_AUTO_COMMIT_TIMEOUT; - } else { - int transactionAutoCommitTimeout; - if (value instanceof Long) { - transactionAutoCommitTimeout = ((Long) value).intValue(); - } else if (value instanceof Integer) { - transactionAutoCommitTimeout = (Integer) value; - } else { - diagnosticLog.warn(ErrorCodes.INVALID_TRANSACTION_AUTO_COMMIT_TIMEOUT, null, value, - DEFAULT_TRX_AUTO_COMMIT_TIMEOUT); - if (!diagnosticLog.getDiagnosticList().isEmpty()) { - RuntimeUtils.handleDiagnosticErrors(diagnosticLog); - } - return DEFAULT_TRX_AUTO_COMMIT_TIMEOUT; - } - if (transactionAutoCommitTimeout <= 0) { - diagnosticLog.warn(ErrorCodes.INVALID_TRANSACTION_CLEANUP_TIMEOUT, null, - transactionAutoCommitTimeout, DEFAULT_TRX_AUTO_COMMIT_TIMEOUT); - if (!diagnosticLog.getDiagnosticList().isEmpty()) { - RuntimeUtils.handleDiagnosticErrors(diagnosticLog); - } - return DEFAULT_TRX_AUTO_COMMIT_TIMEOUT; - } else { - return transactionAutoCommitTimeout; - } } + return parseTimeoutValue(value, TRANSACTION_AUTO_COMMIT_TIMEOUT_KEY, DEFAULT_TRX_AUTO_COMMIT_TIMEOUT); } /** @@ -243,31 +220,27 @@ public int getTransactionCleanupTimeout() { Object value = ConfigMap.get(transactionCleanupTimeoutKey); if (value == null) { return DEFAULT_TRX_CLEANUP_TIMEOUT; + } + return parseTimeoutValue(value, TRANSACTION_CLEANUP_TIMEOUT_KEY, DEFAULT_TRX_CLEANUP_TIMEOUT); + } + + private int parseTimeoutValue(Object value, String key, int defaultValue) { + int timeoutValue; + if (value instanceof Long longVal) { + timeoutValue = longVal.intValue(); + } else if (value instanceof Integer intVal) { + timeoutValue = intVal; } else { - int transactionCleanupTimeout; - if (value instanceof Long) { - transactionCleanupTimeout = ((Long) value).intValue(); - } else if (value instanceof Integer) { - transactionCleanupTimeout = (Integer) value; - } else { - diagnosticLog.warn(ErrorCodes.INVALID_TRANSACTION_CLEANUP_TIMEOUT, null, value, - DEFAULT_TRX_CLEANUP_TIMEOUT); - if (!diagnosticLog.getDiagnosticList().isEmpty()) { - RuntimeUtils.handleDiagnosticErrors(diagnosticLog); - } - return DEFAULT_TRX_CLEANUP_TIMEOUT; - } - if (transactionCleanupTimeout <= 0) { - diagnosticLog.warn(ErrorCodes.INVALID_TRANSACTION_CLEANUP_TIMEOUT, null, - transactionCleanupTimeout, DEFAULT_TRX_CLEANUP_TIMEOUT); - if (!diagnosticLog.getDiagnosticList().isEmpty()) { - RuntimeUtils.handleDiagnosticErrors(diagnosticLog); - } - return DEFAULT_TRX_CLEANUP_TIMEOUT; - } else { - return transactionCleanupTimeout; - } + diagnosticLog.warn(ErrorCodes.INVALID_TRANSACTION_TIMEOUT, null, key, value, defaultValue); + RuntimeUtils.handleDiagnosticErrors(diagnosticLog); + return defaultValue; + } + if (timeoutValue <= 0) { + diagnosticLog.warn(ErrorCodes.INVALID_TRANSACTION_TIMEOUT, null, key, value, defaultValue); + RuntimeUtils.handleDiagnosticErrors(diagnosticLog); + return defaultValue; } + return timeoutValue; } /** diff --git a/bvm/ballerina-runtime/src/main/resources/MessagesBundle.properties b/bvm/ballerina-runtime/src/main/resources/MessagesBundle.properties index fee5df3e6c0e..91760ce14b93 100644 --- a/bvm/ballerina-runtime/src/main/resources/MessagesBundle.properties +++ b/bvm/ballerina-runtime/src/main/resources/MessagesBundle.properties @@ -196,10 +196,8 @@ merge.json.error = cannot merge JSON values of types ''{0}'' and ''{1}'' field.removal.not.allowed = failed to remove field: ''{0}'' is a required field in ''{1}'' operation.not.supported = {0} not supported on type ''{1}'' invalid.fraction.digits = fraction digits cannot be less than '0' -invalid.transaction.auto.commit.timeout = provided transaction auto commit timeout of ''{0}'' is invalid, default \ - value of ''{1}'' will be used instead. -invalid.transaction.cleanup.timeout = provided transaction cleanup timeout of ''{0}'' is invalid, default value of \ - ''{1}'' will be used instead. +invalid.transaction.timeout = provided ''{0}'' of ''{1}'' is invalid, default \ + value of ''{2}'' will be used instead. #configurations config.type.not.supported = configurable variable ''{0}'' with type ''{1}'' is not supported From bb6e3a2881273cce63f16ad807a15d6cdee4b13c Mon Sep 17 00:00:00 2001 From: dsplayerX Date: Wed, 19 Jun 2024 11:50:01 +0530 Subject: [PATCH 06/15] Fix typo --- .../java/io/ballerina/runtime/internal/errors/ErrorCodes.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/errors/ErrorCodes.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/errors/ErrorCodes.java index e06dcd55948d..d1f14b2665b5 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/errors/ErrorCodes.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/errors/ErrorCodes.java @@ -158,7 +158,7 @@ public enum ErrorCodes implements DiagnosticCode { NO_MESSAGE_ERROR("no.worker.message.received", "RUNTIME_0128"), INVALID_METHOD_CALL("invalid.method.call", "RUNTIME_0129"), INVALID_FUNCTION_INVOCATION("invalid.function.invocation.call", "RUNTIME_0130"), - INVALID_TRANSACTION_TIMEOUT("invalid.transaction.value", "RUNTIME_0131"); + INVALID_TRANSACTION_TIMEOUT("invalid.transaction.timeout", "RUNTIME_0131"); private final String errorMsgKey; private final String errorCode; From 14805cfcedd2afc05caf348b778f18354b9f3a02 Mon Sep 17 00:00:00 2001 From: dsplayerX Date: Wed, 19 Jun 2024 14:33:51 +0530 Subject: [PATCH 07/15] Remove unnecessary warning messages --- .../io/ballerina/runtime/internal/errors/ErrorCodes.java | 3 +-- .../runtime/transactions/TransactionResourceManager.java | 7 ------- .../src/main/resources/MessagesBundle.properties | 3 --- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/errors/ErrorCodes.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/errors/ErrorCodes.java index d1f14b2665b5..5017e8004d70 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/errors/ErrorCodes.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/errors/ErrorCodes.java @@ -157,8 +157,7 @@ public enum ErrorCodes implements DiagnosticCode { CONFIG_ENV_VAR_NAME_AMBIGUITY("config.env.variable.name.ambiguity", "RUNTIME_0127"), NO_MESSAGE_ERROR("no.worker.message.received", "RUNTIME_0128"), INVALID_METHOD_CALL("invalid.method.call", "RUNTIME_0129"), - INVALID_FUNCTION_INVOCATION("invalid.function.invocation.call", "RUNTIME_0130"), - INVALID_TRANSACTION_TIMEOUT("invalid.transaction.timeout", "RUNTIME_0131"); + INVALID_FUNCTION_INVOCATION("invalid.function.invocation.call", "RUNTIME_0130"); private final String errorMsgKey; private final String errorCode; diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java index 90822011e4b8..ea0d9889d327 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java @@ -27,8 +27,6 @@ import io.ballerina.runtime.api.values.BString; import io.ballerina.runtime.internal.configurable.ConfigMap; import io.ballerina.runtime.internal.configurable.VariableKey; -import io.ballerina.runtime.internal.diagnostics.RuntimeDiagnosticLog; -import io.ballerina.runtime.internal.errors.ErrorCodes; import io.ballerina.runtime.internal.scheduling.Scheduler; import io.ballerina.runtime.internal.scheduling.Strand; import io.ballerina.runtime.internal.util.RuntimeUtils; @@ -105,7 +103,6 @@ public class TransactionResourceManager { private boolean transactionManagerEnabled; private static final PrintStream stderr = System.err; - RuntimeDiagnosticLog diagnosticLog = new RuntimeDiagnosticLog(); Map transactionInfoMap; @@ -231,13 +228,9 @@ private int parseTimeoutValue(Object value, String key, int defaultValue) { } else if (value instanceof Integer intVal) { timeoutValue = intVal; } else { - diagnosticLog.warn(ErrorCodes.INVALID_TRANSACTION_TIMEOUT, null, key, value, defaultValue); - RuntimeUtils.handleDiagnosticErrors(diagnosticLog); return defaultValue; } if (timeoutValue <= 0) { - diagnosticLog.warn(ErrorCodes.INVALID_TRANSACTION_TIMEOUT, null, key, value, defaultValue); - RuntimeUtils.handleDiagnosticErrors(diagnosticLog); return defaultValue; } return timeoutValue; diff --git a/bvm/ballerina-runtime/src/main/resources/MessagesBundle.properties b/bvm/ballerina-runtime/src/main/resources/MessagesBundle.properties index 91760ce14b93..1c8cc62bfa1e 100644 --- a/bvm/ballerina-runtime/src/main/resources/MessagesBundle.properties +++ b/bvm/ballerina-runtime/src/main/resources/MessagesBundle.properties @@ -196,9 +196,6 @@ merge.json.error = cannot merge JSON values of types ''{0}'' and ''{1}'' field.removal.not.allowed = failed to remove field: ''{0}'' is a required field in ''{1}'' operation.not.supported = {0} not supported on type ''{1}'' invalid.fraction.digits = fraction digits cannot be less than '0' -invalid.transaction.timeout = provided ''{0}'' of ''{1}'' is invalid, default \ - value of ''{2}'' will be used instead. - #configurations config.type.not.supported = configurable variable ''{0}'' with type ''{1}'' is not supported config.invalid.byte.range = [{0}] value provided for byte variable ''{1}'' is out of range. Expected range is \ From a6332d86f306d70c754437e785d5e59cd89b51de Mon Sep 17 00:00:00 2001 From: dsplayerX Date: Wed, 19 Jun 2024 16:42:34 +0530 Subject: [PATCH 08/15] Refactor parseTimeoutValue --- .../TransactionResourceManager.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java index ea0d9889d327..ad5f391b9577 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java @@ -195,14 +195,14 @@ private String getTransactionLogDirectory() { * * @return int transaction auto commit timeout value */ - public int getTransactionAutoCommitTimeout() { + public static int getTransactionAutoCommitTimeout() { VariableKey transactionAutoCommitTimeoutKey = new VariableKey(TRANSACTION_PACKAGE_ID, TRANSACTION_AUTO_COMMIT_TIMEOUT_KEY, PredefinedTypes.TYPE_INT, false); Object value = ConfigMap.get(transactionAutoCommitTimeoutKey); if (value == null) { return DEFAULT_TRX_AUTO_COMMIT_TIMEOUT; } - return parseTimeoutValue(value, TRANSACTION_AUTO_COMMIT_TIMEOUT_KEY, DEFAULT_TRX_AUTO_COMMIT_TIMEOUT); + return parseTimeoutValue(value, DEFAULT_TRX_AUTO_COMMIT_TIMEOUT); } /** @@ -210,7 +210,7 @@ public int getTransactionAutoCommitTimeout() { * * @return int transaction cleanup after value */ - public int getTransactionCleanupTimeout() { + public static int getTransactionCleanupTimeout() { VariableKey transactionCleanupTimeoutKey = new VariableKey(TRANSACTION_PACKAGE_ID, TRANSACTION_CLEANUP_TIMEOUT_KEY, PredefinedTypes.TYPE_INT, false); @@ -218,18 +218,14 @@ public int getTransactionCleanupTimeout() { if (value == null) { return DEFAULT_TRX_CLEANUP_TIMEOUT; } - return parseTimeoutValue(value, TRANSACTION_CLEANUP_TIMEOUT_KEY, DEFAULT_TRX_CLEANUP_TIMEOUT); + return parseTimeoutValue(value, DEFAULT_TRX_CLEANUP_TIMEOUT); } - private int parseTimeoutValue(Object value, String key, int defaultValue) { - int timeoutValue; - if (value instanceof Long longVal) { - timeoutValue = longVal.intValue(); - } else if (value instanceof Integer intVal) { - timeoutValue = intVal; - } else { + private static int parseTimeoutValue(Object value, int defaultValue) { + if (!(value instanceof Number number)) { return defaultValue; } + int timeoutValue = number.intValue(); if (timeoutValue <= 0) { return defaultValue; } From dba23db76b24d0c1f4730d46eecf9caffbc4786b Mon Sep 17 00:00:00 2001 From: dsplayerX Date: Fri, 21 Jun 2024 20:03:03 +0530 Subject: [PATCH 09/15] Address review suggestions --- .../TransactionResourceManager.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java index ad5f391b9577..bdec6396502a 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/transactions/TransactionResourceManager.java @@ -198,11 +198,15 @@ private String getTransactionLogDirectory() { public static int getTransactionAutoCommitTimeout() { VariableKey transactionAutoCommitTimeoutKey = new VariableKey(TRANSACTION_PACKAGE_ID, TRANSACTION_AUTO_COMMIT_TIMEOUT_KEY, PredefinedTypes.TYPE_INT, false); - Object value = ConfigMap.get(transactionAutoCommitTimeoutKey); - if (value == null) { + if (!ConfigMap.containsKey(transactionAutoCommitTimeoutKey)) { return DEFAULT_TRX_AUTO_COMMIT_TIMEOUT; + } else { + Object configValue = ConfigMap.get(transactionAutoCommitTimeoutKey); + if (configValue == null) { + return DEFAULT_TRX_AUTO_COMMIT_TIMEOUT; + } + return parseTimeoutValue(configValue, DEFAULT_TRX_AUTO_COMMIT_TIMEOUT); } - return parseTimeoutValue(value, DEFAULT_TRX_AUTO_COMMIT_TIMEOUT); } /** @@ -214,15 +218,19 @@ public static int getTransactionCleanupTimeout() { VariableKey transactionCleanupTimeoutKey = new VariableKey(TRANSACTION_PACKAGE_ID, TRANSACTION_CLEANUP_TIMEOUT_KEY, PredefinedTypes.TYPE_INT, false); - Object value = ConfigMap.get(transactionCleanupTimeoutKey); - if (value == null) { + if (!ConfigMap.containsKey(transactionCleanupTimeoutKey)) { return DEFAULT_TRX_CLEANUP_TIMEOUT; + } else { + Object configValue = ConfigMap.get(transactionCleanupTimeoutKey); + if (configValue == null) { + return DEFAULT_TRX_CLEANUP_TIMEOUT; + } + return parseTimeoutValue(configValue, DEFAULT_TRX_CLEANUP_TIMEOUT); } - return parseTimeoutValue(value, DEFAULT_TRX_CLEANUP_TIMEOUT); } - private static int parseTimeoutValue(Object value, int defaultValue) { - if (!(value instanceof Number number)) { + private static int parseTimeoutValue(Object configValue, int defaultValue) { + if (!(configValue instanceof Number number)) { return defaultValue; } int timeoutValue = number.intValue(); From 16d8aca05e9cef326b7349a1d3ef26da4d726d68 Mon Sep 17 00:00:00 2001 From: TharmiganK Date: Wed, 7 Aug 2024 08:48:57 +0530 Subject: [PATCH 10/15] Update ballerina openapi help text --- .../resources/cli-help/ballerina-openapi.help | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cli/ballerina-cli/src/main/resources/cli-help/ballerina-openapi.help b/cli/ballerina-cli/src/main/resources/cli-help/ballerina-openapi.help index 736df2e1061f..e86a7da12c70 100755 --- a/cli/ballerina-cli/src/main/resources/cli-help/ballerina-openapi.help +++ b/cli/ballerina-cli/src/main/resources/cli-help/ballerina-openapi.help @@ -13,7 +13,8 @@ SYNOPSIS [--operations ] [-n | --nullable] [--license] [--with-tests] [--client-methods] [--without-data-binding] - [--status-code-binding] + [--status-code-binding] [--mock] [--with-service-contract] + [--single-file] bal openapi [-i | --input] [--json] [-s | --service] @@ -93,6 +94,18 @@ OPTIONS This option can be used in the client generation to generate the client methods with status code response binding. + --mock + This option can be used in the client generation to generate a mock + client for the given OpenAPI contract. + + --with-service-contract + This option can be used to generate the service contract type for the + given OpenAPI contract. + + --single-file + This option can be used to generate the Ballerina service or client + with related types and utility functions in a single file. + EXAMPLES Generate a Ballerina mock service using a `hello.yaml` OpenAPI contract. $ bal openapi -i hello.yaml --mode service From 8513863edd2fef64f1a741a91f443f0c84570b73 Mon Sep 17 00:00:00 2001 From: Krishnananthalingam Tharmigan <63336800+TharmiganK@users.noreply.github.com> Date: Wed, 7 Aug 2024 09:59:58 +0530 Subject: [PATCH 11/15] Apply suggestions from code review Co-authored-by: Sumudu Nissanka --- .../src/main/resources/cli-help/ballerina-openapi.help | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cli/ballerina-cli/src/main/resources/cli-help/ballerina-openapi.help b/cli/ballerina-cli/src/main/resources/cli-help/ballerina-openapi.help index e86a7da12c70..de61e7e7cf49 100755 --- a/cli/ballerina-cli/src/main/resources/cli-help/ballerina-openapi.help +++ b/cli/ballerina-cli/src/main/resources/cli-help/ballerina-openapi.help @@ -14,7 +14,7 @@ SYNOPSIS [--license] [--with-tests] [--client-methods] [--without-data-binding] [--status-code-binding] [--mock] [--with-service-contract] - [--single-file] + [--single-file] [--use-sanitized-oas] bal openapi [-i | --input] [--json] [-s | --service] @@ -105,7 +105,11 @@ OPTIONS --single-file This option can be used to generate the Ballerina service or client with related types and utility functions in a single file. - + + --use-sanitized-oas + This is an experimental feature. This option enables service/client code + generation by modifying the given OAS to follow the Ballerina language + best practices. EXAMPLES Generate a Ballerina mock service using a `hello.yaml` OpenAPI contract. $ bal openapi -i hello.yaml --mode service From 8ae88d3884a2f606fa1ae91edd49c1b18c4d789a Mon Sep 17 00:00:00 2001 From: TharmiganK Date: Wed, 7 Aug 2024 12:51:10 +0530 Subject: [PATCH 12/15] Update swagger versions --- gradle.properties | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 970f7c0b032d..e09886d825dd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,7 +19,7 @@ apacheCommonsAxiomImplVersion=1.4.0 apacheCommonsAxiomDomVersion=1.4.0 apacheCommonsAxiomC14nVersion=1.2.22 apacheCommonsCompressVersion=1.26.2 -apacheCommonsLang3Version=3.12.0 +apacheCommonsLang3Version=3.14.0 apacheCommonsTextVersion=1.10.0 apacheGeronimoStaxVersion=1.0.1 apacheMavenPluginAnnotationsVersion=3.6.0 @@ -53,7 +53,7 @@ fasterxmlWoodstoxCoreVersion=6.5.0 codehausWoodstoxStax2ApiVersion=4.2.1 commonsBeanutilsVersion=1.9.4 commonsCodecVersion=1.14 -commonsIoVersion=2.12.0 +commonsIoVersion=2.15.1 commonsLoggingVersion=1.1.1 commonsCollectionsVersion=3.2.2 drongoldTaskTreeVersion=1.3.1 @@ -135,9 +135,9 @@ sonarqubeGradlePluginVersion=4.0.0.2929 sonarcloudVersion=3.4.0.2513 spullaraMustacheCompilerVersion=0.8.9 squareupOkioVersion=3.4.0 -swaggerModelsVersion=2.1.13 -swaggerParserVersion=2.0.30 -swaggerParserV2Version=2.0.30 +swaggerModelsVersion=2.2.22 +swaggerParserVersion=2.1.22 +swaggerParserV2Version=2.1.22 testngVersion=7.7.0 tongfeiProgressbarVersion=0.7.4 underCouchDownloadVersion=4.0.4 From 8eed9d6cc5a9e52e1f17b80c500d028e082edba0 Mon Sep 17 00:00:00 2001 From: hindujaB Date: Mon, 12 Aug 2024 10:51:46 +0530 Subject: [PATCH 13/15] Improve isRemoteManagementEnabled API name --- .../java/io/ballerina/runtime/api/Repository.java | 2 +- .../ballerina/runtime/internal/RepositoryImpl.java | 13 +++++++------ .../nativeimpl/jvm/runtime/api/tests/Values.java | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Repository.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Repository.java index 25c72f21fd69..af4f803c91c6 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Repository.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Repository.java @@ -41,5 +41,5 @@ public interface Repository { * Get whether remote management is enabled. * @return True if remote management is enabled, false otherwise. */ - boolean isRemoteEnabled(); + boolean isRemoteManagementEnabled(); } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/RepositoryImpl.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/RepositoryImpl.java index 5c82bc7606a2..002c04780501 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/RepositoryImpl.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/RepositoryImpl.java @@ -43,7 +43,7 @@ public class RepositoryImpl implements Repository { private static final String nodeId = generateNodeId(); private static String balHome; private static String balVersion; - private static boolean isRemoteEnabled = false; + private static boolean isRemoteManagementEnabled = false; @Override public List getArtifacts() { @@ -73,8 +73,8 @@ public Node getNode() { } @Override - public boolean isRemoteEnabled() { - return isRemoteEnabled; + public boolean isRemoteManagementEnabled() { + return isRemoteManagementEnabled; } private Artifact createArtifact(ObjectValue service, ObjectValue listener) { @@ -92,7 +92,7 @@ private Artifact createArtifact(ObjectValue service, ObjectValue listener) { } public static void addServiceListener(BObject listener, BObject service, Object attachPoint) { - if (!isRemoteEnabled) { + if (!isRemoteManagementEnabled) { return; } BServiceType serviceType = (BServiceType) service.getType(); @@ -101,10 +101,11 @@ public static void addServiceListener(BObject listener, BObject service, Object listenerServiceMap.put((ObjectValue) listener, (ObjectValue) service); } - public static void addBallerinaRuntimeInformation(String balHome, String balVersion, boolean isRemoteEnabled) { + public static void addBallerinaRuntimeInformation(String balHome, String balVersion, + boolean isRemoteManagementEnabled) { RepositoryImpl.balHome = balHome; RepositoryImpl.balVersion = balVersion; - RepositoryImpl.isRemoteEnabled = isRemoteEnabled; + RepositoryImpl.isRemoteManagementEnabled = isRemoteManagementEnabled; } private static String generateNodeId() { diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Values.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Values.java index 594f83f0a4fe..4f22b6b5dd2e 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Values.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Values.java @@ -552,6 +552,6 @@ public static BString getBallerinaNode(Environment env) { public static void validateIsRemoteEnabled(Environment env) { Repository repository = env.getRepository(); - Assert.assertTrue(repository.isRemoteEnabled()); + Assert.assertTrue(repository.isRemoteManagementEnabled()); } } From 940b5f54705f37cea8a44b871e2b3f72233204bf Mon Sep 17 00:00:00 2001 From: hindujaB Date: Mon, 12 Aug 2024 10:55:43 +0530 Subject: [PATCH 14/15] Fix test names --- .../nativeimpl/jvm/runtime/api/tests/Values.java | 2 +- .../test/resources/test-src/runtime/api/runtime_mgt/main.bal | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Values.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Values.java index 4f22b6b5dd2e..fd2725a3f154 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Values.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Values.java @@ -550,7 +550,7 @@ public static BString getBallerinaNode(Environment env) { return StringUtils.fromString("balNode-" + node.nodeId); } - public static void validateIsRemoteEnabled(Environment env) { + public static void validateIsRemoteManagementEnabled(Environment env) { Repository repository = env.getRepository(); Assert.assertTrue(repository.isRemoteManagementEnabled()); } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/runtime_mgt/main.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/runtime_mgt/main.bal index 0f560aa48778..5ecce5f20149 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/runtime_mgt/main.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/runtime_mgt/main.bal @@ -38,7 +38,7 @@ function testListenerFunctionality() { test:assertTrue(result == ()); test:assertEquals(counter, 3); validateArtifactCount(); - validateIsRemoteEnabled(); + validateIsRemoteManagementEnabled(); } public service class Service { @@ -80,6 +80,6 @@ function validateArtifactCount() = @java:Method { 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.Values" } external; -function validateIsRemoteEnabled() = @java:Method { +function validateIsRemoteManagementEnabled() = @java:Method { 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.Values" } external; From b06c27aaa1b6f9fa1f908aa71ff8f09e2b9e501b Mon Sep 17 00:00:00 2001 From: dilhasha Date: Mon, 12 Aug 2024 13:59:49 +0530 Subject: [PATCH 15/15] Update resource config --- .../org.ballerinalang/ballerina-runtime/resource-config.json | 3 +++ .../java/io/ballerina/cli/task/RunNativeImageTestTask.java | 4 ---- .../main/java/io/ballerina/projects/JBallerinaBackend.java | 2 -- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/resources/META-INF/native-image/org.ballerinalang/ballerina-runtime/resource-config.json b/bvm/ballerina-runtime/src/main/resources/META-INF/native-image/org.ballerinalang/ballerina-runtime/resource-config.json index f6ce63367bfd..4b5e81b83ac8 100644 --- a/bvm/ballerina-runtime/src/main/resources/META-INF/native-image/org.ballerinalang/ballerina-runtime/resource-config.json +++ b/bvm/ballerina-runtime/src/main/resources/META-INF/native-image/org.ballerinalang/ballerina-runtime/resource-config.json @@ -3,6 +3,9 @@ "includes": [ { "pattern": "\\QMETA-INF/axiom.xml\\E" + }, + { + "pattern": "resources/.*" } ] }, diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index c0498ec6ece5..1562eadd0659 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -65,7 +65,6 @@ import static io.ballerina.cli.utils.TestUtils.generateTesterinaReports; import static io.ballerina.projects.util.ProjectConstants.BIN_DIR_NAME; import static io.ballerina.projects.util.ProjectConstants.TESTS_CACHE_DIR_NAME; -import static io.ballerina.projects.util.ProjectUtils.getResourcesPath; import static org.ballerinalang.test.runtime.util.TesterinaConstants.CACHE_DIR; import static org.ballerinalang.test.runtime.util.TesterinaConstants.DOT; import static org.ballerinalang.test.runtime.util.TesterinaConstants.TESTERINA_TEST_SUITE; @@ -370,9 +369,6 @@ private int runTestSuiteWithNativeImage(Package currentPackage, Target target, nativeArgs.add("-H:Path=" + NativeUtils.convertWinPathToUnixFormat(NativeUtils .addQuotationMarkToString(nativeTargetPath.toString()))); - // Add resources - nativeArgs.add("-H:IncludeResources=" + getResourcesPath()); - // native-image configs nativeArgs.add("-H:ReflectionConfigurationFiles=" + NativeUtils .convertWinPathToUnixFormat(NativeUtils.addQuotationMarkToString( diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java index 0e2298176b45..852de179bbe7 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java @@ -79,7 +79,6 @@ import static io.ballerina.projects.util.ProjectConstants.DOT; import static io.ballerina.projects.util.ProjectConstants.RESOURCE_DIR_NAME; import static io.ballerina.projects.util.ProjectUtils.getConflictingResourcesMsg; -import static io.ballerina.projects.util.ProjectUtils.getResourcesPath; import static io.ballerina.projects.util.ProjectUtils.getThinJarFileName; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.CLASS_FILE_SUFFIX; @@ -724,7 +723,6 @@ private Path emitGraalExecutable(Path executableFilePath, List emitR executableFilePath.toString(), "-H:Name=" + nativeImageName, "-H:Path=" + executableFilePath.getParent(), - "-H:IncludeResources=" + getResourcesPath(), "--no-fallback")); }