cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rohit Yadav <rohit.ya...@citrix.com>
Subject Concern on GenericDaoBase findBy method
Date Sat, 12 Jan 2013 00:42:36 GMT
In GenericDaoBase's findById and findByUuid if I added a check to return null if passed value
is null to avoid potential exceptions, will this break any use case? No changes I found till
now.

@@ -905,6 +905,8 @@ public abstract class GenericDaoBase<T, ID extends Serializable>
implements Gene
     public T findById(final ID id) {
+        if (id == null)
+            return null;
         if (_cache != null) {
             final Element element = _cache.get(id);
             return element == null ? lockRow(id, null) : (T)element.getObjectValue();
@@ -916,6 +918,8 @@ public abstract class GenericDaoBase<T, ID extends Serializable>
implements Gene
     public T findByUuid(final String uuid) {
+        if (uuid == null)
+            return null;
         SearchCriteria<T> sc = createSearchCriteria();
         sc.addAnd("uuid", SearchCriteria.Op.EQ, uuid);

Regards.


Mime
View raw message