int () { // Clipboard#setContents throws IllegalStateException if the clipboard is currently unavailable. // On Windows, it uses Win32 OpenClipboard which may fail according to its documentation: // "OpenClipboard fails if another window has the clipboard open." // Other applications implement retry logic when calling OpenClipboard. Let's do the same. // // According to my simple local stress testing, Clipboard#setContents hasn't failed more than 2 times in a row. // Probably, it needs to be adjusted in future. return 5; }