[DISCUSS]null pointer returned from daoimpl

2014-02-07 Thread Daan Hoogland
LS, in PrivateIpDaoImpl a null pointer is returned when no db object can be found: @Override public PrivateIpVO allocateIpAddress(long dcId, long networkId, String requestedIp) { ... PrivateIpVO vo = lockOneRandomRow(sc, true); if (vo == null) { txn.rollback()

Re: [DISCUSS]null pointer returned from daoimpl

2014-02-07 Thread Chiradeep Vittal
There is no good answer IMHO. The designer of the API chose this design. Throwing a checked exception or returning Null is equivalent. Throwing a runtime exception is probably wrong since there may be some recovery possible. We could annotate the method with @Nullable so that the compiler/IDE can

Re: [DISCUSS]null pointer returned from daoimpl

2014-02-09 Thread Daan Hoogland
Chiradeep, I think you mean throwing a runtime exception or returning null is equivalent. A checked exception would enforce handling of the empty return. I think @Nullable is a good idea. In this case or in cases where there is queried for lists I would think an empty list is the best thing to do.