diff options
author | Manuel Carrasco <manolo@apache.org> | 2014-03-05 09:15:22 +0200 |
---|---|---|
committer | Manuel Carrasco <manolo@apache.org> | 2014-03-05 09:15:22 +0200 |
commit | 7f29ad0e6dea34aa21622b0dfad3fc77d0587c66 (patch) | |
tree | 8257b7c9bf613624228c5d8707f59fe6da31f86d | |
parent | fc152330bd09f8d88b2668a60932d176ca18e007 (diff) | |
parent | 8962ae699c49a17ba33e0defac2cf0c37def488c (diff) | |
download | gwtquery-7f29ad0e6dea34aa21622b0dfad3fc77d0587c66.tar.gz gwtquery-7f29ad0e6dea34aa21622b0dfad3fc77d0587c66.zip |
Merge pull request #272 from apanizo/master
Exception when parsing empty response.getText()
-rw-r--r-- | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java | 32 |
1 files changed, 17 insertions, 15 deletions
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}; |