neilcsmith-net commented on code in PR #7668:
URL: https://github.com/apache/netbeans/pull/7668#discussion_r1715550681
##########
platform/o.n.bootstrap/src/org/netbeans/NbClipboard.java:
##########
@@ -435,20 +436,22 @@ public void run() {
// that is used because accessing the clipboard can block
// indefinitely. Running the access loop here is deemed similar
// in nature.
- final int MAX_TRIES = 50;
+ final int MAX_TRIES = 10;
final long start = System.currentTimeMillis();
+ int delay = 20;
for (int i = 0; i < MAX_TRIES; i++) {
try {
transferable = systemClipboard.getContents(this);
break;
} catch (IllegalStateException ex) {
// Throw exception if retries failed
- if (i == (MAX_TRIES - 1) ||
(System.currentTimeMillis() - start) > 980L) {
+ if (i == (MAX_TRIES - 1) ||
(System.currentTimeMillis() + delay - start) > 1000L) {
throw ex;
} else {
- log.log(Level.INFO, "systemClipboard#getContents
threw IllegalStateException (try: {0})", i + 1); // NOI18N
+ log.log(Level.INFO, "systemClipboard#getContents
ISE, attempt {0}", i + 1); // NOI18N
}
- Thread.sleep(20); // Give system time to settle
+ Thread.sleep(delay); // Give system time to settle
+ delay *= 2;
Review Comment:
Glad our maths matches! I would just make sure the values match up in logic
so it doesn't confuse the next person - eg. make it `MAX_RETRIES = 7`? Just in
case you hit that one moment the system clock changes and this keeps trying for
hours! :laughing:
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists