Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
ubuntu 11.10, sun-jdk-6, eclipse galileo
Description
If we override getWrappedGenerator method in TransformedGenerator to return null, it may result in a NullPointerException if hashCode is called.
Attached the patch for it, and below a snippet of code to reproduce this issue.
TransformedGenerator<Integer, Integer> t = new TransformedGenerator<Integer, Integer>(
new IntegerRange(1, 10), new UnaryFunction<Integer, Integer>() {
public Integer evaluate(Integer obj)
}) {
@Override
protected Generator<? extends Integer> getWrappedGenerator()
};
TransformedGenerator<Integer, Integer> t2 = new TransformedGenerator<Integer, Integer>(
new IntegerRange(1, 10), new UnaryFunction<Integer, Integer>() {
public Integer evaluate(Integer obj)
});
System.out.println(t.equals(t2));
System.out.println(t.hashCode() == t2.hashCode()); // NPE
Cheers,
Bruno P. Kinoshita