diff --git a/src/main/java/de/mrbesen/telegram/TelegramAPI.java b/src/main/java/de/mrbesen/telegram/TelegramAPI.java index 63370a1..5df95fc 100644 --- a/src/main/java/de/mrbesen/telegram/TelegramAPI.java +++ b/src/main/java/de/mrbesen/telegram/TelegramAPI.java @@ -167,8 +167,7 @@ public class TelegramAPI implements Runnable { //catch 429 too many error if (response == 429) { - toomany = true; - if(trycount > 10) break; + if(trycount < 10) toomany = true; //try to read timeout //too Many Requests: retry after 19 @@ -182,13 +181,16 @@ public class TelegramAPI implements Runnable { System.out.println("Got 429 -> sleep for " + timeout + " seconds"); Thread.sleep(timeout * 1000); } catch(InterruptedException e) {} - continue; + + if(trycount < 10) continue; } throw new APIError(parameter, request, con.getResponseCode(), null, errdesc); //throw new IOException("API request returned HTTP " + con.getResponseCode() + " (" + con.getResponseMessage() + ") for action " + request + "\nurl: " + url.toString() + "\nparams: " + parameter + "\nerror description: " + errdesc); } } + //unreachable code? + throw new IllegalStateException(); } protected String readfromIS(InputStream is) {