This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | Missing WeakSet.putIfAbsent | ||
---|---|---|---|
Product: | platform | Reporter: | Jaroslav Tulach <jtulach> |
Component: | -- Other -- | Assignee: | Vladimir Voskresensky <vv159170> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | apireviews, jglick |
Priority: | P3 | Keywords: | API, API_REVIEW_FAST |
Version: | 7.0 | ||
Hardware: | Other | ||
OS: | Linux | ||
Issue Type: | DEFECT | Exception Reporter: | |
Attachments: |
hg diff after (hg rm, hg mv, fix of names)
patch |
Description
Jaroslav Tulach
2010-12-01 18:42:30 UTC
Can you advise how to better proceed from hg and patch point of view? I can move WeakSharedSet, but as I remember you wanted to replace WeakSet. So my class should be WeakSet as well. But if I just replace content of WeakSet.java => diff will be awful and not readable at all. May be it's better to have one commit which removes current WeakSet.java and next commit which add new WeakSet.java? note: we are talking about implementation of Set with weak keys and access to keys which is absent in usual Set classes. http://hg.netbeans.org/cnd-main/file/tip/cnd.utils/src/org/netbeans/modules/cnd/utils/cache/WeakSharedSet.java usual usecase of this class is like: WeakSharedSet set; Item shared = set.putIfAbsent(new Item()); putIfAbsent returns passed object if no equal element yet in set or return what is in set equal to passed object also our set uses smaller Entry impl comparing to current WeakSet (In reply to comment #1) > Can you advise how to better proceed from hg and patch point of view? > I can move WeakSharedSet, but as I remember you wanted to replace WeakSet. > So my class should be WeakSet as well. > But if I just replace content of WeakSet.java => diff will be awful and not > readable at all. > May be it's better to have one commit which removes current WeakSet.java and > next commit which add new WeakSet.java? I think it can be one commit/patch: hg rm openide.util/src/org/openide/util/WeakSet.java hg mv cnd.utils/src/org/netbeans/modules/cnd/utils/cache/WeakSharedSet.java openide.util/src/org/openide/util/WeakSet.java # fix up package decl, usages, ... which 'hg di' ought to show as a removal plus a rename with minor diffs, since Hg remembers the provenance of the new version of the file. Try it anyway. Created attachment 103969 [details]
hg diff after (hg rm, hg mv, fix of names)
Created attachment 103970 [details]
patch
I think patch is unreadable. It is result of #hg rm #hg mv modifications #hg ci -A -m #hg tip -p How do we prefer to proceed? WeakSetTest passes with new impl. I can add test for new putIfAbsent method and after increasing spec versions integrate. remark: the current WeakSet implementation doesn't have internal concurrency check. So, when I replace impl we should expect exceptions like issue #193312 thanks. remove old impl/add new impl http://hg.netbeans.org/cnd-main/rev/bc23d919ec47 http://hg.netbeans.org/cnd-main/rev/b6c1a3118a5e http://hg.netbeans.org/cnd-main/rev/921131807118 migrate cnd: http://hg.netbeans.org/cnd-main/rev/fb2ca77b1e6b serializable and cloneable http://hg.netbeans.org/cnd-main/rev/ba6077eca996 I am afraid the clone() method is not correctly implemented with respect to subclassing. If I look at HashSet.clone(), it will guarantee that this.getClass() == this.clone().getClass() I think people will expect the same from WeakSet too (unless there is something I am missing). Although implementation in old WeakSet has the same weak point, I agree with you and will improve the situation in new version. better clone with test http://hg.netbeans.org/cnd-main/rev/7620423b8d35 one more... to have same signatures (without thrown exception) for clone http://hg.netbeans.org/cnd-main/rev/58d02418997a Integrated into 'main-golden', will be available in build *201012290001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/bc23d919ec47 User: Vladimir Voskresensky <vv159170@netbeans.org> Log: remove old impl of WeakSet (#192759) Integrated into 'main-golden', will be available in build *201101090000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/82810428149a User: Jaroslav Tulach <jtulach@netbeans.org> Log: #192759: Additional tweaks for double add of the same object. Caused duplicated events in FileSystem Event delivery mechanism |