Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit 3b9ae17

Browse files
committed
Handle unknown action values.
1 parent 4505ea0 commit 3b9ae17

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

src/main/java/synapticloop/b2/response/B2FileInfoResponse.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class B2FileInfoResponse extends BaseB2Response {
3636
private final Long contentLength;
3737

3838
private final Map<String, String> fileInfo;
39-
private final Action action;
39+
private Action action;
4040
private final int size;
4141
private final long uploadTimestamp;
4242

@@ -70,7 +70,13 @@ public B2FileInfoResponse(final JSONObject response) throws B2ApiException {
7070

7171
String action = this.readString(B2ResponseProperties.KEY_ACTION);
7272
if(null != action) {
73-
this.action = Action.valueOf(action);
73+
try {
74+
this.action = Action.valueOf(action);
75+
}
76+
catch(IllegalArgumentException e) {
77+
LOGGER.warn("Unknown action value " + action);
78+
this.action = null;
79+
}
7480
} else {
7581
// Default
7682
this.action = Action.upload;

src/main/java/synapticloop/b2/response/B2HideFileResponse.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class B2HideFileResponse extends BaseB2Response {
4343

4444
private final String fileId;
4545
private final String fileName;
46-
private final Action action;
46+
private Action action;
4747
private final int size;
4848
private final long uploadTimestamp;
4949

@@ -61,9 +61,15 @@ public B2HideFileResponse(String json) throws B2ApiException {
6161
this.fileId = this.readString(B2ResponseProperties.KEY_FILE_ID);
6262
this.fileName = this.readString(B2ResponseProperties.KEY_FILE_NAME);
6363

64-
final String actionValue = this.readString(B2ResponseProperties.KEY_ACTION);
65-
if(null != actionValue) {
66-
this.action = Action.valueOf(actionValue);
64+
final String action = this.readString(B2ResponseProperties.KEY_ACTION);
65+
if(null != action) {
66+
try {
67+
this.action = Action.valueOf(action);
68+
}
69+
catch(IllegalArgumentException e) {
70+
LOGGER.warn("Unknown action value " + action);
71+
this.action = null;
72+
}
6773
} else {
6874
this.action = null;
6975
}

0 commit comments

Comments
 (0)