reef-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mariia Mykhailova <>
Subject RE: Is it a good idea for toString() to return null?
Date Tue, 05 Jan 2016 17:34:14 GMT
Any opinions?
Personally I feel we shouldn't return a special value for an otherwise good class which for
whatever reason failed to serialize, so we should either fall back to old conversion style
or throw an exception


-----Original Message-----
From: Mariia Mykhailova [] 
Sent: Thursday, December 31, 2015 9:51 AM
Subject: RE: Is it a good idea for toString() to return null?

I don't think we can change method signature for toString() methods.
Should we return some special value instead? Something like "Failed to serialize"? Or should
we fall back to old-fashioned field-by-field conversion to string?

 Some of these methods (probably all) were introduced in
, that's when using jackson instead of field-by-field was suggested.


-----Original Message-----
From: Markus Weimer []
Sent: Wednesday, December 30, 2015 10:27 PM
Subject: Re: Is it a good idea for toString() to return null?

> I've found a bunch of classes in
> org.apache.reef.runtime.hdinsight.client.yarnrest with toString() 
> methods which can return null. [...] Is it a good idea?

No, returning `null` is never a good idea. We generally use `Optional<T>` on the java
side to indicate when a method might return nothing.

I believe I wrote that code, and in great hurry when we prepared for the classes at the machine
learning summer school. Sorry about that!


View raw message