-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EO Objects can have the same hash in the new version #2157
Comments
@levBagryansky Looks like it is expected behaviour. The protected static final ThreadLocal<Vertices> VTX = ThreadLocal.withInitial(Vertices::new);
public PhDefault(final Phi sigma) {
//...
this.vertex = PhDefault.VTX.get().next();
//...
}
@Override
public int hashCode() {
return this.vertex;
} Why do you need to check this?
|
@volodya-lombrozo We need it to distinguish objects in |
@levBagryansky I'm afraid that it's dangerous, because:
https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html In other words, If two objects are unequal, their hash code are not required to be different. |
@volodya-lombrozo You are right. But In
That is why it is important to assign different |
@levBagryansky Maybe we have to fix |
@volodya-lombrozo I think it would help too |
@levBagryansky Could you help us here? |
@volodya-lombrozo sure |
@volodya-lombrozo I think we need to fix
Now it cannot be "the ID of the vertex" since the can be the same in different threads. |
@levBagryansky |
@yegor256 can we release these changes in order to fix eo-threads? |
@rultor release, tag is |
This test is slight modification from eo-threads:
The test guaranteed that objects created in parallel have different hashcodes. The test does not passes in new version anymore so eo-threads does not work correctly(objectionary/eo-threads#87).
There is similar test in this repo (https://github.com/objectionary/eo/blob/master/eo-runtime/src/test/java/org/eolang/VerticesTest.java#L70) and it passes. Also the test below:
passes too.
@volodya-lombrozo please take a look.
The text was updated successfully, but these errors were encountered: