Bug 506459 - NPE in CoreAttributeGroup toStringItems when items attribute is null
- Fix resolves the issue in CoreAttributeGroup.toStringItems() by adding a missing null check for the items attribute on the CoreAttributeGroup before accessing this attribute, preventing a NPE when toString() is invoked.

Signed-off-by: David Minsky <david.minsky@oracle.com>
Reviewed-by: Petros Splinakis <petros.splinakis@oracle.com>
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/core/queries/CoreAttributeGroup.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/core/queries/CoreAttributeGroup.java
index 0ea2b26..636518b 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/core/queries/CoreAttributeGroup.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/core/queries/CoreAttributeGroup.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016 Oracle and/or its affiliates. All rights reserved.
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
  * which accompanies this distribution.
@@ -789,12 +789,15 @@ protected String toStringItems() {
         } else {
             superClassGroupItems = null;
         }
-        Collection<ATTRIBUTE_ITEM> values = this.items.values();
-        length += (values != null && values.size() > 0
-                ?  (values.size() - 1) * FIELD_SEP.length() : 0);
-        if (values != null) {
-            for (Iterator<ATTRIBUTE_ITEM> it = values.iterator(); it.hasNext();) {
-                length += it.next().toStringNoClassName().length();
+        Collection<ATTRIBUTE_ITEM> values = null;
+        if (this.items != null) {
+            values = this.items.values();
+            length += (values != null && values.size() > 0
+                    ?  (values.size() - 1) * FIELD_SEP.length() : 0);
+            if (values != null) {
+                for (Iterator<ATTRIBUTE_ITEM> it = values.iterator(); it.hasNext();) {
+                    length += it.next().toStringNoClassName().length();
+                }
             }
         }
         // Build string to be returned