]> source.dussan.org Git - vaadin-framework.git/commitdiff
[merge from 6.7] #8407 Handle the case of a 503 response without a Retry-After header
authorAutomerge <automerge@vaadin.com>
Fri, 20 Apr 2012 13:07:11 +0000 (13:07 +0000)
committerAutomerge <automerge@vaadin.com>
Fri, 20 Apr 2012 13:07:11 +0000 (13:07 +0000)
svn changeset:23603/svn branch:6.8

src/com/vaadin/terminal/gwt/client/ApplicationConnection.java

index 0603e80c93ab47c6704b6c96e1882fe9e06ca3ea..82971860b5dd56053439d28e9a6b4716b5274d2d 100644 (file)
@@ -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");