Skip to content

Commit 2c6e5b8

Browse files
authored
Fix rename user ConfigNode physical plan serialize/deserialize NPE (apache#16582)
1 parent d289944 commit 2c6e5b8

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlan.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ public static ConfigPhysicalPlan create(final ByteBuffer buffer) throws IOExcept
301301
case UpdateUser:
302302
case UpdateUserV2:
303303
case CreateUserWithRawPassword:
304+
case RenameUser:
304305
plan = new AuthorTreePlan(configPhysicalPlanType);
305306
break;
306307
case RCreateUser:
@@ -332,6 +333,7 @@ public static ConfigPhysicalPlan create(final ByteBuffer buffer) throws IOExcept
332333
case RGrantRoleSysPri:
333334
case RRevokeUserSysPri:
334335
case RRevokeRoleSysPri:
336+
case RRenameUser:
335337
plan = new AuthorRelationalPlan(configPhysicalPlanType);
336338
break;
337339
case ApplyConfigNode:

iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanSerDeTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import org.apache.iotdb.commons.udf.UDFType;
6666
import org.apache.iotdb.commons.utils.TimePartitionUtils;
6767
import org.apache.iotdb.confignode.consensus.request.write.auth.AuthorPlan;
68+
import org.apache.iotdb.confignode.consensus.request.write.auth.AuthorRelationalPlan;
6869
import org.apache.iotdb.confignode.consensus.request.write.auth.AuthorTreePlan;
6970
import org.apache.iotdb.confignode.consensus.request.write.confignode.ApplyConfigNodePlan;
7071
import org.apache.iotdb.confignode.consensus.request.write.confignode.RemoveConfigNodePlan;
@@ -644,6 +645,36 @@ public void AuthorPlanTest() throws IOException, IllegalPathException {
644645
new ArrayList<>());
645646
req1 = (AuthorTreePlan) ConfigPhysicalPlan.Factory.create(req0.serializeToByteBuffer());
646647
Assert.assertEquals(req0, req1);
648+
649+
// rename user
650+
req0 =
651+
new AuthorTreePlan(
652+
ConfigPhysicalPlanType.RenameUser,
653+
"oldUserName",
654+
"",
655+
"",
656+
"",
657+
new HashSet<>(),
658+
false,
659+
new ArrayList<>(),
660+
233,
661+
"newUserName");
662+
req1 = (AuthorTreePlan) ConfigPhysicalPlan.Factory.create(req0.serializeToByteBuffer());
663+
Assert.assertEquals(req0, req1);
664+
req0 =
665+
new AuthorRelationalPlan(
666+
ConfigPhysicalPlanType.RRenameUser,
667+
"oldUserName",
668+
"",
669+
"",
670+
"",
671+
new HashSet<>(),
672+
false,
673+
"",
674+
666,
675+
"newUserName");
676+
req1 = (AuthorRelationalPlan) ConfigPhysicalPlan.Factory.create(req0.serializeToByteBuffer());
677+
Assert.assertEquals(req0, req1);
647678
}
648679

649680
@Test

0 commit comments

Comments
 (0)