Prevent StructLikeWrapper#equals from throwing an exception#5157
Prevent StructLikeWrapper#equals from throwing an exception#5157alexjo2144 wants to merge 1 commit intoapache:mainfrom
Conversation
76ad98e to
f5b3441
Compare
|
|
||
| StructLikeWrapper that = (StructLikeWrapper) other; | ||
|
|
||
| if (!type.equals(that.type)) { |
There was a problem hiding this comment.
This will check nested field docs. Is that the intended behavior? I think you want something more like sameType, possibly also ignoring nullability.
I should also note that I'm not sure that this is a good idea. StructLikeWrapper is not intended for comparing two arbitrary structs.
There was a problem hiding this comment.
@alexjo2144, should we update this to check structure and types, but not nullability and docs?
|
|
||
| StructLikeWrapper that = (StructLikeWrapper) other; | ||
|
|
||
| if (!type.equals(that.type)) { |
There was a problem hiding this comment.
You can do this just before return comparator.compare(this.struct, that
if all you want is to "Prevent equals from throwing an exception"
however, making equals compare by type too looks like a good change as well.
this, however, should be called out in the commit message.
That's a good point, and probably the risky part of this change. Before, two
Based on the class description it sounded like the whole point of the Wrapper is to be able to compare StructLikes using equals. But we don't have to do this if you'd rather leave it alone |
The point was to compare structs that have the same type. Normally, we try to do type checking up front because a type describes a large group of rows. Rather than checking each row's type, we want to check types and then check rows. That said, this should be a fast check if the types are identical. |
Do you mean we should do |
No, I'm saying that is the first check done in |
Fixes: #5064