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.

Bug 109234 - Hardly usable API for handling children in TreeModel
Summary: Hardly usable API for handling children in TreeModel
Status: CLOSED DUPLICATE of bug 105608
Alias: None
Product: debugger
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Martin Entlicher
URL:
Keywords: API
Depends on:
Blocks:
 
Reported: 2007-07-10 13:18 UTC by Martin Krauskopf
Modified: 2010-04-29 09:33 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Krauskopf 2007-07-10 13:18:05 UTC
Since there are not any rules (?) when TreeModel#getChildrenCount and TreeModel#getChildren are called it is hardly
achievable to ensure correct behavior and prevent exception.
Since, in the time between the TM#getChildrenCount and TM#getChildren are called, the debugging session might have
changed, one can either return old cached (during TM#getChildrenCount) values from TM#getChildren was called (but again
there is not any API contract that says when is what called) or I can return fresh values from TM#getChildren, which
might cause AIOOBE and similar.

We talked about it with Martin and he suggests to return Integer.MAX_VALUE as a temporary workaround until this is fixed.
Comment 1 Martin Entlicher 2007-07-11 10:40:55 UTC
The rule is - when the user expands the view and when you fire a model changed event.
I agree that this API is not easy to use, but the bounds can always be checked to return the correct data. Simple if
statements prevent from exceptions.

There are basically three solutions:
- cache the data berween TreeModel.getChildrenCount() and TreeModel.getChildren()
- always return fresh data, but check the bounds
- return Integer.MAX_VALUE from TreeModel.getChildrenCount()

We definitely want to consider issue #105608, this is the reason why there are two methods for retrieval of children.
This will definitely not be changed for 6.0.
I would rather make this a duplicate of issue #105608, which should finally give a meaning to this API. Do you agree?
Comment 2 Martin Krauskopf 2007-07-11 10:54:01 UTC
> I would rather make this a duplicate of issue #105608, which should finally give a meaning to this API. Do you agree?

If the rules

> - cache the data berween TreeModel.getChildrenCount() and TreeModel.getChildren()
> - always return fresh data, but check the bounds
> - return Integer.MAX_VALUE from TreeModel.getChildrenCount()

holds and would be written down into the Javadoc (at least some of them), then why not. Since there would be some
'official' way how to use API correctly. Otherwise, I think that almost everybody implementing a debugger for NetBeans
will run into the same problem - therefore without the Javadoc it is bug IMHO.

Comment 3 Martin Entlicher 2007-07-11 11:23:51 UTC
I consider these more like implementation hints than rules, since it's up to the implementor at the end. I'll add it
into the Javadoc...
Comment 4 Martin Entlicher 2007-07-11 14:38:54 UTC
So, the Javadoc is extended:

/shared/data/ccvs/repository/debuggercore/viewmodel/src/org/netbeans/spi/viewmodel/TreeModel.java,v  <--  TreeModel.java
new revision: 1.10; previous revision: 1.9

The rest will be solved in issue #105608.

*** This issue has been marked as a duplicate of 105608 ***
Comment 5 Quality Engineering 2010-04-29 09:33:56 UTC
Verified ... and Closing all issues resolved into NetBeans 6.7 and earlier.