From 9b0c2c8fb7a34ff03848cb2704bfff2da32c3409 Mon Sep 17 00:00:00 2001 From: Maksim Timonin Date: Thu, 14 Nov 2024 19:04:18 +0300 Subject: [PATCH] WIP --- .../managers/communication/GridIoManager.java | 21 ++++--------------- .../GridIoSecurityAwareMessage.java | 4 ++-- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index 88331baf352b2..3c34a566898a1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -1877,13 +1877,7 @@ private void unwindMessageSet(GridCommunicationMessageSet msgSet, GridMessageLis * @param msg Message. * @param secSubjId Security subject that will be used to open a security session. */ - private void invokeListener( - Byte plc, - GridMessageListener lsnr, - UUID nodeId, - Object msg, - UUID secSubjId - ) { + private void invokeListener(Byte plc, GridMessageListener lsnr, UUID nodeId, Object msg, UUID secSubjId) { MTC.span().addLog(() -> "Invoke listener"); Byte oldPlc = CUR_PLC.get(); @@ -1895,14 +1889,9 @@ private void invokeListener( UUID newSecSubjId = secSubjId != null ? secSubjId : nodeId; - try ( - OperationSecurityContext ignored = ctx.security().withContext(newSecSubjId); - ) { + try (OperationSecurityContext ignored = ctx.security().withContext(newSecSubjId)) { lsnr.onMessage(nodeId, msg, plc); } - catch (Exception e) { - throw new IgniteException("Failed to close SessionContext", e); - } finally { if (change) CUR_PLC.set(oldPlc); @@ -2134,12 +2123,10 @@ private long getInverseConnectionWaitTimeout() { long timeout, boolean skipOnTimeout ) { - boolean secEnabled = ctx.security().enabled(); - - if (secEnabled) { + if (ctx.security().enabled()) { UUID secSubjId = null; - if (secEnabled && !ctx.security().isDefaultContext()) + if (!ctx.security().isDefaultContext()) secSubjId = ctx.security().securityContext().subject().id(); return new GridIoSecurityAwareMessage(secSubjId, plc, topic, topicOrd, msg, ordered, timeout, skipOnTimeout); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoSecurityAwareMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoSecurityAwareMessage.java index e1cb03a9c0200..8e0f0f3cadda6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoSecurityAwareMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoSecurityAwareMessage.java @@ -23,7 +23,6 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageWriter; -import org.jetbrains.annotations.Nullable; /** * @@ -74,7 +73,7 @@ public GridIoSecurityAwareMessage( /** * @return Security subject id. */ - @Nullable UUID secSubjId() { + UUID secSubjId() { return secSubjId; } @@ -132,6 +131,7 @@ public GridIoSecurityAwareMessage( return false; reader.incrementState(); + } return reader.afterMessageRead(GridIoSecurityAwareMessage.class);