Community
Participate
Working Groups
This might not be a bug, maybe just incorrect usage on my part. I try to obtain a matcher using a custom selection policy: IContentTypeMatcher matcher = contentTypeManager.getMatcher(new MySelectionPolicy(), null); This selection policy only allows content types that inherit from a certain fixed base type. So I obtain the base type: IContentType baseType = contentTypeManager.getContentType("my.content.type"); In the seletion policy, I try to determine if the candidate "isKindOf" the base type: public IContentType[] select(IContentType[] candidates, boolean fileName, boolean content) { ... if (candidates[i].isKindOf(baseType)) ... The problem is, I always get "false", even for types that clearly inherit from the base type (even the base type itself). The problem seems to be in ContentType.isKindOf method: the candidate's dynamic type is "ContentType", but baseType is "ContentTypeHandler". ContentType.isKindOf uses reference equality for comparison (rather than comparing the ids, for example). ContentTypeHandler.isKindOf first unwraps the target (ContentType), so that should work. My question is, should they be symmetrical, or am I using it wrong?
It is a bug indeed. The idea was that client code would never be given instances of ContentType, only ContentTypeHandlers (to avoid leaks in the case a new content type catalog is built). ISelectionPolicy is clearly a case where this rule was broken. It was never noticed before because the only implementation we had in the platform (in the resources plug-in) didn't call isKindOf. I would say it would be ok if the content type manager kept passing in instances of ContentType because selection policies are unlikely to hold them (ISelectionPolicy is more of a SPI than a regular API). Then, changing ContentType.isKindOf to only check the id should be enough to fix this problem.
Clearing target milestone because it is milestone week and nobody has signed up to fix this.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.