Commits

Anonymous committed 153ae38

Patch from USER-80

  • Participants
  • Parent commits 5ab7ed0

Comments (0)

Files changed (1)

File src/java/com/opensymphony/user/provider/ofbiz/OFBizAbstractProvider.java

         }
 
         if (user == null) {
-            user = EntityUtil.getOnly(getDelegator().findByAnd(userEntity, UtilMisc.toMap("name", name)));
+            List userId = getDelegator().findByAnd(userEntity, UtilMisc.toMap("name", name));
+
+            if (userId.size() > 1) {
+                throw new RuntimeException("Found more than one user with name '" + name + "'; ids " + printList(userId));
+            }
+
+            user = EntityUtil.getOnly(userId);
 
             if (exclusiveAccess && (user != null)) {
                 // Store the really name instead of the one the user entered (USER-64)
 
         return user;
     }
+
+    /** Prints a comma-separated list of objects. */
+    private final String printList(final List list) {
+        StringBuffer buf = new StringBuffer();
+        Iterator iter = list.iterator();
+
+        while (iter.hasNext()) {
+            buf.append(iter.next());
+
+            if (iter.hasNext()) {
+                buf.append(", ");
+            }
+        }
+
+        return buf.toString();
+    }
 }