Skip to content

Commit 9969629

Browse files
committed
avoid parser exception on 204 no content
1 parent bd1adf4 commit 9969629

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/com/amadeus/Response.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected void parse(HTTPClient client) {
6464
parseData(client);
6565
}
6666

67-
// Detects of any exceptions have occured and throws the appropriate exceptions.
67+
// Detects of any exceptions have occurred and throws the appropriate exceptions.
6868
protected void detectError(HTTPClient client) throws ResponseException {
6969
ResponseException exception = null;
7070
if (statusCode >= 500) {
@@ -121,6 +121,11 @@ private void parseData(HTTPClient client) {
121121

122122
// Tries to read the body.
123123
private String readBody() {
124+
// Workaround to avoid ParserException when status code is 204
125+
if (statusCode == 204) {
126+
body = "{ \"data\": { } } ";
127+
return body;
128+
}
124129
// Get the connection
125130
HttpURLConnection connection = getRequest().getConnection();
126131

0 commit comments

Comments
 (0)