From: Automerge Date: Fri, 20 Apr 2012 13:07:11 +0000 (+0000) Subject: [merge from 6.7] #8407 Handle the case of a 503 response without a Retry-After header X-Git-Tag: 7.0.0.alpha3~260^2~6 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=14c4453d28cce7a61dae1bc118cdf5c4cf7e7ab4;p=vaadin-framework.git [merge from 6.7] #8407 Handle the case of a 503 response without a Retry-After header svn changeset:23603/svn branch:6.8 --- diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 0603e80c93..82971860b5 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -524,21 +524,26 @@ public class ApplicationConnection { return; case 503: - // We'll assume msec instead of the usual seconds - int delay = Integer.parseInt(response - .getHeader("Retry-After")); - VConsole.log("503, retrying in " + delay + "msec"); - (new Timer() { - @Override - public void run() { - // TODO why? Here used to be "activeRequests--;" - // but can't see why exactly - hasActiveRequest = false; - doUidlRequest(uri, payload, synchronous); - } - }).schedule(delay); - return; - + /* + * We'll assume msec instead of the usual seconds. If + * there's no Retry-After header, handle the error like + * a 500, as per RFC 2616 section 10.5.4. + */ + String delay = response.getHeader("Retry-After"); + if (delay != null) { + VConsole.log("503, retrying in " + delay + "msec"); + (new Timer() { + @Override + public void run() { + // TODO why? Here used to be + // "activeRequests--;" + // but can't see why exactly + hasActiveRequest = false; + doUidlRequest(uri, payload, synchronous); + } + }).schedule(Integer.parseInt(delay)); + return; + } } if ((statusCode / 100) == 4) { @@ -549,6 +554,13 @@ public class ApplicationConnection { + statusCode, statusCode); endRequest(); return; + } else if ((statusCode / 100) == 5) { + // Something's wrong on the server, there's nothing the + // client can do except maybe try again. + showCommunicationError("Server error. Error code: " + + statusCode, statusCode); + endRequest(); + return; } String contentType = response.getHeader("Content-Type");