-
1. Re: Leaking or not
swd847 Sep 15, 2010 5:40 PM (in response to icarus1111)Thanks for reporting this, there is a leak.
The fix should be merged into trunk in the next few days. If you want it right now it is available at http://github.com/swd847/core/tree/WELD-681
-
2. Re: Leaking or not
icarus1111 Sep 16, 2010 2:59 AM (in response to icarus1111)That's great!
However, we are using Glassfish 3.0.1, which (AFAIK) doesn't support Weld 1.1 beta (yet).
Do you think it is safe that I patch Weld 1.0.1 by applying the Weld 1.1 beta fix modifications to the Weld 1.0.1 sources?Regards,
Ramon -
3. Re: Leaking or not
swd847 Sep 16, 2010 3:05 AM (in response to icarus1111)I think that should be fine, all that is required is to fix the equals and hashcode method on TypeSafeResolver.Key
-
4. Re: Leaking or not
icarus1111 Sep 16, 2010 4:02 AM (in response to icarus1111)It seems that it is bit too complex for me to fix it in 1.0.1. Stuart, maybe you can help me out? This is the TypeSafeResolver.equals implementation in 1.0.1:
@Override public boolean equals(Object obj) { if (obj instanceof Resolvable) { Resolvable that = (Resolvable) obj; return this.getResolvable().getTypes().equals(that.getTypes()) && this.getResolvable().getQualifiers().equals(that.getQualifiers()); } else { return false; } }
...and the TypeSafeResolver.hashcode implementation:
@Override public int hashCode() { int result = 17; result = 31 * result + this.getResolvable().getTypes().hashCode(); result = 31 * result + this.getResolvable().getQualifiers().hashCode(); return result; }
I cannot find a clear match with the current beta code. Maybe you can give me some pointers how to patch this code?
Regards,
Ramon -
5. Re: Leaking or not
swd847 Sep 16, 2010 4:15 AM (in response to icarus1111)I think it is probably this bit:
@Override public boolean equals(Object obj) { if (obj instanceof Resolvable) { Resolvable that = (Resolvable) obj; return this.getResolvable().getTypeClosure().equals(that.getTypeClosure()) && this.getResolvable().getQualifiers().equals(that.getQualifiers()); } else { return false; } }
should be something like:
@Override public boolean equals(Object obj) { if (obj instanceof Key) { Key that = (Key) obj; return this.getResolvable().getTypeClosure().equals(that.getResolvable().getTypeClosure()) && this.getResolvable().getQualifiers().equals(that.getResolvable().getQualifiers()); } else { return false; } }
-
6. Re: Leaking or not
icarus1111 Sep 16, 2010 4:27 AM (in response to icarus1111)Great!
So no hashcode modifications needed?
Resolvable.getTypeClosure() is not defined in 1.0.1, should I replace it with getTypes?Thanks a lot,
Ramon -
7. Re: Leaking or not
swd847 Sep 16, 2010 4:40 AM (in response to icarus1111)I think the hash code is fine in that version, and you should replace getTypeClosure() with getTypes().
-
8. Re: Leaking or not
icarus1111 Sep 16, 2010 5:22 AM (in response to icarus1111)It looks like the leak is gone, Stuart, thanks a lot!
So, for those interested in this fix for Weld 1.0.1: replace TypeSafeResolver.Key.equals(Object obj) with:
public boolean equals(Object obj) { if (obj instanceof Key) { Key that = (Key) obj; return this.getResolvable().getTypes().equals(that.getResolvable().getTypes()) && this.getResolvable().getQualifiers().equals(that.getResolvable().getQualifiers()); } else { return false; } }