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 16849 - Task API impovement
Summary: Task API impovement
Alias: None
Product: platform
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 3.x
Hardware: PC All
: P3 blocker (vote)
Assignee: Jaroslav Tulach
: 45562 (view as bug list)
Depends on:
Reported: 2001-10-23 11:26 UTC by _ pkuzel
Modified: 2008-12-22 20:08 UTC (History)
3 users (show)

See Also:
Exception Reporter:

The implementation and tests (14.12 KB, patch)
2004-07-29 18:08 UTC, Jaroslav Tulach
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description _ pkuzel 2001-10-23 11:26:30 UTC
I think a method:
   * Wait until task finishes or timeout expires.
   * @param timeout in milis
   * @return false if timeout expired
  public boolean waitFinished (int timeout) throws InterruptedException

could be useful.
Comment 1 Jan Chalupa 2001-11-27 13:03:56 UTC
Target milestone -> 3.3.1.
Comment 2 Marek Grummich 2002-07-22 11:28:18 UTC
Set target milestone to TBD
Comment 3 Marek Grummich 2002-07-22 11:30:17 UTC
Set target milestone to TBD
Comment 4 Jaroslav Tulach 2004-07-29 11:59:06 UTC
*** Issue 45562 has been marked as a duplicate of this issue. ***
Comment 5 Jaroslav Tulach 2004-07-29 18:07:29 UTC
Adding waitFinished(long timeout) or (int timeout) is possible, but is
not that simple how it might look. The problem is that Task is as well
API as well SPI and there are some clients that override waitFinished
(like FolderInstance) and relly on it being called. So introducing new
method has to count deal with cases when original waitFinished is
overriden and call it. This adds a lot of compliations to the

On the other hand, it seems logical to have the time out method,
Future has it too:

I've written a bunch of testcases and were able to satisfy all of
them. So if this passes review, I am ready to commit this for promoE.
Btw. should be probably related to issue 33467 which also works with
Comment 6 Jaroslav Tulach 2004-07-29 18:08:12 UTC
Created attachment 16561 [details]
The implementation and tests
Comment 7 Jesse Glick 2004-07-29 19:25:46 UTC
I think it would make more sense for the default impl to throw an
UnsupportedOperationException rather than delegate to the no-timeout
version. At least you would then notice right away that your timeout
was not being honored, rather than thinking everything was working but
then running into a random deadlock months later because there was
actually no effective timeout.
Comment 8 Jaroslav Tulach 2004-07-30 10:30:35 UTC
The timeout is effective even when delegating to waitFinished(). That
is the whole point of the complicated logic in Task. Just a bit
inefficient (replans to another thread). The problem with
UnsupportedOperationException is that it would force me to implement
the solution in each subclass of Task and forms really unusable API. 

The most important thing is that RequestProcessor.Task implements this
correctly and that FolderInstance works fine (due to the delegation).
But as I said I am ready to not integrate the code if there are no
real requirements for it.
Comment 9 Jaroslav Tulach 2004-10-06 15:17:01 UTC
This could greatly simplify call add to NbClipboard as part of fix for
issue 41098
Comment 10 Jaroslav Tulach 2004-11-01 15:56:01 UTC
As there is at least one case where this api could simplify the code a
lot and there were no objections, I am going to apply the fix
tomorrow. I'll increase the version of openide to 5.0.
Comment 11 _ pkuzel 2004-11-02 07:54:01 UTC
It's 3 years old RFE and I was too brief that time.

$ grep -r "16849" *

core/src/org/netbeans/core/                    // API
enhancement in issue 16849 - we would just use:

^C - one usage is enough
Comment 12 Jaroslav Tulach 2004-11-02 14:41:01 UTC
cvs ci -m "#16849: Adding Task.waitFinished(long) and thus simplifying
the code in NbClipboard a lot"

Checking in openide/;
/cvs/openide/,v  <--
new revision: 1.161; previous revision: 1.160
Processing log script arguments...
More commits to come...
Checking in openide/api/doc/changes/apichanges.xml;
/cvs/openide/api/doc/changes/apichanges.xml,v  <--  apichanges.xml
new revision: 1.227; previous revision: 1.226
Processing log script arguments...
More commits to come...
Checking in openide/src/org/openide/util/;
/cvs/openide/src/org/openide/util/,v  <--
new revision: 1.81; previous revision: 1.80
Checking in openide/src/org/openide/util/;
/cvs/openide/src/org/openide/util/,v  <--
new revision: 1.26; previous revision: 1.25
Processing log script arguments...
More commits to come...
Checking in
new revision: 1.18; previous revision: 1.17
Checking in openide/test/unit/src/org/openide/util/;
/cvs/openide/test/unit/src/org/openide/util/,v  <--
new revision: 1.3; previous revision: 1.2
Processing log script arguments...
More commits to come...
Checking in core/src/org/netbeans/core/;
/cvs/core/src/org/netbeans/core/,v  <--
new revision: 1.22; previous revision: 1.21