Skip to content

Commit

Permalink
fix: check response code when response code is 200 (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhao900914 authored Feb 3, 2023
1 parent 174c985 commit 19f6f5d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/amplitude/api/AmplitudeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2271,7 +2271,7 @@ protected void makeEventUploadPostRequest(Call.Factory client, String events, fi
try {
Response response = client.newCall(request).execute();
String stringResponse = response.body().string();
if (stringResponse.equals("success")) {
if (response.code() == 200 || stringResponse.equals("success")) {
uploadSuccess = true;
logThread.post(new Runnable() {
@Override
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/amplitude/api/AmplitudeClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -906,8 +906,8 @@ public void testSaveEventLogic() {
// unsent events will be threshold (+1 for start session)
assertEquals(getUnsentEventCount(), Constants.EVENT_UPLOAD_THRESHOLD + 1);

server.enqueue(new MockResponse().setBody("invalid_api_key"));
server.enqueue(new MockResponse().setBody("bad_checksum"));
server.enqueue(new MockResponse().setResponseCode(400).setBody("invalid_api_key"));
server.enqueue(new MockResponse().setResponseCode(400).setBody("bad_checksum"));
ShadowLooper httpLooper = Shadows.shadowOf(amplitude.httpThread.getLooper());
httpLooper.runToEndOfTasks();

Expand Down

0 comments on commit 19f6f5d

Please sign in to comment.