From: Adolfo Panizo Date: Tue, 4 Mar 2014 12:38:26 +0000 (+0100) Subject: Exception when parsing empty response.getText(), and the dataType is X-Git-Tag: gwtquery-project-1.4.3~40^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=feb7f50a21f7f7b95ca067c6fcf4ec01524715f3;p=gwtquery.git Exception when parsing empty response.getText(), and the dataType is necessary for the request. --- diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java index e11e5923..b0ee21ad 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java @@ -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};