This is an automated email from the ASF dual-hosted git repository.
ibessonov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new e5a199fd64a IGNITE-22952 Fix lambda classname parsing in deployment
for Java 21+ (#11466)
e5a199fd64a is described below
commit e5a199fd64add0ae8e7d27574e8cf418fa9177f1
Author: Ivan Bessonov <[email protected]>
AuthorDate: Thu Aug 8 11:29:23 2024 +0300
IGNITE-22952 Fix lambda classname parsing in deployment for Java 21+
(#11466)
---
.../managers/deployment/GridDeploymentCommunication.java | 15 +++++++++++++--
.../java/org/apache/ignite/internal/util/IgniteUtils.java | 8 ++++++--
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
index 44a3661f7d2..4960dfe08c4 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java
@@ -209,8 +209,7 @@ class GridDeploymentCommunication {
// In case the class loader is ours - skip the check
// since it was already performed before (and was successful).
if (!(ldr instanceof GridDeploymentClassLoader)) {
- // First check for @GridNotPeerDeployable annotation.
- String clsName = req.resourceName().replace('/', '.');
+ String clsName = clsNameFromResourceName(req.resourceName());
try {
if (clsName.endsWith(CLASS_FILE_EXTENSION))
@@ -218,6 +217,7 @@ class GridDeploymentCommunication {
Class<?> cls = Class.forName(clsName, true, ldr);
+ // First check for @GridNotPeerDeployable annotation.
if (U.getAnnotation(cls, IgniteNotPeerDeployable.class) !=
null) {
String errMsg = "Attempt to peer deploy class that has
@IgniteNotPeerDeployable " +
"annotation: " + clsName;
@@ -294,6 +294,17 @@ class GridDeploymentCommunication {
sendResponse(nodeId, req.responseTopic(), res);
}
+ /** */
+ private static String clsNameFromResourceName(String reqResourceName) {
+ String clsName = reqResourceName.replace('/', '.');
+
+ // Java 21+ uses '/' in lambda class names, we must account for that.
+ if (!reqResourceName.contains("$$Lambda/"))
+ return clsName;
+
+ return clsName.replace("$$Lambda.", "$$Lambda/");
+ }
+
/** */
private String resourceRequestDetails(UUID nodeId, GridDeploymentRequest
req) {
return new SB()
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index a344ee3d500..8f2fedeb1ef 100755
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -10088,9 +10088,13 @@ public abstract class IgniteUtils {
* {@code null} if passed in name is not related to lambda.
*/
@Nullable public static String lambdaEnclosingClassName(String clsName) {
- int idx = clsName.indexOf("$$Lambda$");
+ int idx0 = clsName.indexOf("$$Lambda$"); // Java 8+
+ int idx1 = clsName.indexOf("$$Lambda/"); // Java 21+
- return idx != -1 ? clsName.substring(0, idx) : null;
+ if (idx0 == idx1)
+ return null;
+
+ return clsName.substring(0, idx0 >= 0 ? idx0 : idx1);
}
/**