eirikbakke commented on code in PR #7668:
URL: https://github.com/apache/netbeans/pull/7668#discussion_r1715527667


##########
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:
   Correct, we can never reach MAX_RETRIES. There can be max 7 attempts if 
getContents fails immediately: 0+20+40+80+160+320+640 = 1260 milliseconds and 
then the  "> 1000" condition breaks out of the loop the next time it fails). I 
could get rid of MAX_RETRIES without changing the behavior here.



-- 
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

Reply via email to