diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php
index db194b5485262e06b78670c6e112cb8843ffc8e2..b0b94b8dbb938c1c15853da6aa38bd8278d20a28 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php
@@ -167,7 +167,7 @@ public function applyDefaultValue($notify = TRUE) {
    * {@inheritdoc}
    */
   public function getIterator() {
-    return isset($this->entity) ? $this->entity->getIterator() : new \ArrayIterator([]);
+    return $this->entity instanceof \IteratorAggregate ? $this->entity->getIterator() : new \ArrayIterator([]);
   }
 
 }
diff --git a/core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php
index 8d0f25291b03601f6a4f7afa4f90a1f2518bbf0d..8e909d24bd4fee4200db019bbeb860e35faa6fe6 100644
--- a/core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php
@@ -29,19 +29,33 @@ class EntityAdapterUnitTest extends UnitTestCase {
   protected $bundle;
 
   /**
-   * The entity used for testing.
+   * The content entity used for testing.
    *
    * @var \Drupal\Core\Entity\ContentEntityBase|\PHPUnit_Framework_MockObject_MockObject
    */
   protected $entity;
 
   /**
-   * The entity adapter under test.
+   * The config entity used for testing.
+   *
+   * @var \Drupal\Core\Entity\ConfigtEntityBase|\PHPUnit_Framework_MockObject_MockObject
+   */
+  protected $configEntity;
+
+  /**
+   * The content entity adapter under test.
    *
    * @var \Drupal\Core\Entity\Plugin\DataType\EntityAdapter
    */
   protected $entityAdapter;
 
+  /**
+   * The config entity adapter under test.
+   *
+   * @var \Drupal\Core\Entity\Plugin\DataType\EntityAdapter
+   */
+  protected $configEntityAdapter;
+
   /**
    * The entity type used for testing.
    *
@@ -228,6 +242,10 @@ protected function setUp() {
     $this->entity = $this->getMockForAbstractClass('\Drupal\Core\Entity\ContentEntityBase', [$values, $this->entityTypeId, $this->bundle]);
 
     $this->entityAdapter = EntityAdapter::createFromEntity($this->entity);
+
+    $this->configEntity = $this->getMockForAbstractClass('\Drupal\Core\Config\Entity\ConfigEntityBase', [$values, $this->entityTypeId, $this->bundle]);
+
+    $this->configEntityAdapter = EntityAdapter::createFromEntity($this->configEntity);
   }
 
   /**
@@ -428,6 +446,7 @@ public function testApplyDefaultValue() {
    * @covers ::getIterator
    */
   public function testGetIterator() {
+    // Content entity test.
     $iterator = $this->entityAdapter->getIterator();
     $fields = iterator_to_array($iterator);
     $this->assertArrayHasKey('id', $fields);
@@ -436,6 +455,11 @@ public function testGetIterator() {
 
     $this->entityAdapter->setValue(NULL);
     $this->assertEquals(new \ArrayIterator([]), $this->entityAdapter->getIterator());
+
+    // Config entity test.
+    $iterator = $this->configEntityAdapter->getIterator();
+    $this->configEntityAdapter->setValue(NULL);
+    $this->assertEquals(new \ArrayIterator([]), $this->entityAdapter->getIterator());
   }
 
 }