> We only force an EnumSet not be none when it is serialized.
Since EnumSetWritable is in org.apache.hadoop.io package, we have to make sure it works for all kind of EnumSet, including empty set.
> If it is not ok. how about this, we require the elementType when we serialize a non enumset? if the elementType is not provided, we throw an exception.
This is one possible solution. Then, we should enforce the status that either both elementType and value are null, or both are not null.
More comments on the patch:
- check null before accessing value in equals(..), hashCode(), toString(), etc. Otherwise, there are NPE.
- Similarly, check null for conf.
- need more tests for EnumSetWritable. The current test does not use EnumSetWritable at all.
- minimize the usage of @SuppressWarnings("unchecked"). We should fix the generic syntax but not suppressing the warnings.