added MAX_TRIES to SetContents of NbClipboard as well#8024
added MAX_TRIES to SetContents of NbClipboard as well#8024wumpz wants to merge 1 commit intoapache:masterfrom
Conversation
|
Thanks for the suggested patch! Are you on a Windows machine yourself? If you are trying to solve #7051, I'd recommend the following:
This seems to be the only way to troubleshoot this particular bug. |
|
@eirikbakke Yes, I am using Windows and indeed I try to solve or improve on #7051. So how can I follow your recommended steps. Is it enough to simply replace the I think bootstrap.nbm in my Netbeans installation or do I have to do more? |
|
Here's what I usually do when I want to have multiple custom NetBeans builds available to test and switch between:
|
|
So I am now on a patched version of Apache Netbeans 23. I used this little program and got to 50 tries multiple times without a glitch: #3962 (comment). I had this problem before. |
| if (i == (MAX_TRIES - 1) || (System.currentTimeMillis() + delay - start) > 1000L) { | ||
| throw ex; | ||
| } else { | ||
| log.log(Level.INFO, "systemClipboard#getContents ISE, attempt {0}", i + 1); // NOI18N |
There was a problem hiding this comment.
Log message should say setContents instead of getContents here.
|
Thanks for testing! Seeing whether the change makes a difference or not over time is very useful here.
That's a good thing to test, in addition to regular IDE usage over some time. If you can, please try to switch to the NetBeans version that does not have the patch, and see if the test then starts producing the bug. I remember trying that particular test myself at some point without exhibiting the bug. Another good thing to check for is to see that and IllegalStateException is actually thrown for setContents every now and then. This is to make sure the patch actually has some effect. To see this you'd need to change the log message in the patch that currently reads "systemClipboard#getContents ISE, attempt {0}" to "systemClipboard#setContents ISE, attempt {0}", to distinguish it from the getContents case. setContents is a mutating operation unlike getContents, so I'd be a little more cautious about doing unconditional retries, unless we know that it fixes the bug. Probably we'd want to decrease the retry count a bit; though for testing purposes it can be useful to leave it as it is in the current version of the patch. |
|
maybe I am overlooking something. But was there any evidence that |
|
@mbien on the other hand, the description is right about the potential race conditions between rescheduled tasks - that's the same issue I mentioned on Slack. This PR is certainly worth reviewing if we decide to keep the async aspects of NbClipboard. |
|
to reschedule there must be a failure first. I am just curious if there is any evidence for failures on Keep in mind the async mechanism was originally a workaround for a different problem: very slow response time in some cases. The loop happened later as patch on the patch. IMO: the loop is more questionable than the async mechanism given that if it doesn't work -> throw. If |
|
closing. Further changes to NbClipboard would have to be evaluated using JDK 25+, which contains clipboard fixes for windows JDK bugs which were one of the reasons for the many hacks in NB's clipboard code. |
|
Yes, the Windows clipboard bug was finally fixed at the root cause (see https://bugs.openjdk.org/browse/JDK-8353950 ), making workarounds unnecessary. It's great! |
Since in some previous commit the retry logic for getContents was rewritten, I was wondering, why this was not done with setContent. This PR does this.
However, the old version startet a setContents with a delay of 100 ms. So a setContents could possibly interfere, even another setContents, since a new task was created. Using this new retry logic this interference cannot happen.