MCPcopy Create free account
hub / github.com/diffplug/goomph / retry

Method retry

src/main/java/com/diffplug/gradle/FileMisc.java:118–130  ·  view source on GitHub ↗

Retries an action every ms, for 250ms, until it finally works or fails. Makes FS operations more reliable.

(File input, Throwing.Function<File, T> function)

Source from the content-addressed store, hash-verified

116 * Makes FS operations more reliable.
117 */
118 private static <T> T retry(File input, Throwing.Function<File, T> function) {
119 long start = System.currentTimeMillis();
120 Throwable lastException;
121 do {
122 try {
123 return function.apply(input);
124 } catch (Throwable e) {
125 lastException = e;
126 Errors.suppress().run(() -> Thread.sleep(1));
127 }
128 } while (System.currentTimeMillis() - start < MS_RETRY);
129 throw Errors.asRuntime(lastException);
130 }
131
132 /** Returns true if the given directory exists, and waits up to 500ms for the directory to exist. */
133 public static boolean dirExists(File dir) {

Callers 4

listMethod · 0.95
mkdirsMethod · 0.95
forceDeleteMethod · 0.95
deleteEmptyFoldersMethod · 0.95

Calls 2

applyMethod · 0.80
runMethod · 0.65

Tested by

no test coverage detected