]> source.dussan.org Git - gwtquery.git/commitdiff
Exception when parsing empty response.getText(), and the dataType is
authorAdolfo Panizo <adolfo.panizo@gmail.com>
Tue, 4 Mar 2014 12:38:26 +0000 (13:38 +0100)
committerAdolfo Panizo <adolfo.panizo@gmail.com>
Wed, 5 Mar 2014 06:40:59 +0000 (07:40 +0100)
necessary for the request.

gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java

index e11e592379a25f4a2d3bde8ed42c57c27d099972..b0ee21ad2f29157d14eb7d1b0dea7f83700e5bc0 100644 (file)
@@ -145,22 +145,24 @@ public class Ajax extends GQuery {
             Response response = arguments(0);
             Request request = arguments(1);
             Object retData = response.getText();
-            try {
-              if ("xml".equalsIgnoreCase(dataType)) {
-                retData = JsUtils.parseXML(response.getText());
-              } else if ("json".equalsIgnoreCase(dataType)) {
-                retData = GQ.create(response.getText());
-              } else {
-                retData = response.getText();
-                if ("script".equalsIgnoreCase(dataType)) {
-                  ScriptInjector.fromString((String)retData).setWindow(window).inject();
+            if (retData != null && !"".equals(retData)) {
+              try {
+                if ("xml".equalsIgnoreCase(dataType)) {
+                  retData = JsUtils.parseXML(response.getText());
+                } else if ("json".equalsIgnoreCase(dataType)) {
+                  retData = GQ.create(response.getText());
+                } else {
+                  retData = response.getText();
+                  if ("script".equalsIgnoreCase(dataType)) {
+                    ScriptInjector.fromString((String)retData).setWindow(window).inject();
+                  }
+                }
+              } catch (Exception e) {
+                if (GWT.isClient() && GWT.getUncaughtExceptionHandler() != null) {
+                  GWT.getUncaughtExceptionHandler().onUncaughtException(e);
+                } else {
+                  e.printStackTrace();
                 }
-              }
-            } catch (Exception e) {
-              if (GWT.isClient() && GWT.getUncaughtExceptionHandler() != null) {
-                GWT.getUncaughtExceptionHandler().onUncaughtException(e);
-              } else {
-                e.printStackTrace();
               }
             }
             return new Object[]{retData, "success", request, response};