@@ -64,9 +64,12 @@ protected void parse(HTTPClient client) {
6464 parseData (client );
6565 }
6666
67- // Detects of any exceptions have occurred and throws the appropriate exceptions.
67+ // Detects of any exceptions have occured and throws the appropriate exceptions.
6868 protected void detectError (HTTPClient client ) throws ResponseException {
6969 ResponseException exception = null ;
70+ if (statusCode == 204 ) {
71+ return ;
72+ }
7073 if (statusCode >= 500 ) {
7174 exception = new ServerException (this );
7275 } else if (statusCode == 404 ) {
@@ -97,6 +100,9 @@ private void parseStatusCode() {
97100
98101 // Tries to parse the data
99102 private void parseData (HTTPClient client ) {
103+ if (this .statusCode == 204 ) {
104+ return ;
105+ }
100106 this .parsed = false ;
101107 this .body = readBody ();
102108 this .result = parseJson (client );
@@ -121,11 +127,6 @@ private void parseData(HTTPClient client) {
121127
122128 // Tries to read the body.
123129 private String readBody () {
124- // Workaround to avoid ParserException when status code is 204
125- if (statusCode == 204 ) {
126- body = "{ \" data\" : { } } " ;
127- return body ;
128- }
129130 // Get the connection
130131 HttpURLConnection connection = getRequest ().getConnection ();
131132
@@ -172,7 +173,7 @@ private boolean isJson() {
172173 private boolean hasJsonHeader () {
173174 String contentType = getRequest ().getConnection ().getHeaderField (Constants .CONTENT_TYPE );
174175 String [] expectedContentTypes = new String [] {
175- "application/json" , "application/vnd.amadeus+json"
176+ "application/json" , "application/vnd.amadeus+json"
176177 };
177178 return Arrays .asList (expectedContentTypes ).contains (contentType );
178179 }
0 commit comments