diff --git a/core/modules/comment/src/CommentForm.php b/core/modules/comment/src/CommentForm.php
index c96202b..72acfed 100644
--- a/core/modules/comment/src/CommentForm.php
+++ b/core/modules/comment/src/CommentForm.php
@@ -19,6 +19,7 @@
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\Core\Render\RendererInterface;
 use Drupal\Core\Session\AccountInterface;
+use Drupal\user\Entity\User;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
@@ -132,7 +133,7 @@ public function form(array $form, FormStateInterface $form_state) {
     }
     else {
       if ($this->currentUser->isAuthenticated()) {
-        $author = $this->currentUser->getUsername();
+        $author = User::load($this->currentUser->id())->name->value;
       }
       else {
         $author = ($comment->getAuthorName() ? $comment->getAuthorName() : '');
diff --git a/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraintValidator.php b/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraintValidator.php
index 915d184..79329b3 100644
--- a/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraintValidator.php
+++ b/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraintValidator.php
@@ -70,7 +70,7 @@ public function validate($entity, Constraint $constraint) {
     // If an author name and owner are given, make sure they match.
     elseif (isset($author_name) && $author_name !== '' && $owner_id) {
       $owner = $this->userStorage->load($owner_id);
-      if ($owner->getUsername() != $author_name) {
+      if ($owner->name->value != $author_name) {
         $this->context->buildViolation($constraint->messageMatch)
           ->atPath('name')
           ->addViolation();
