Closed wtekiela closed 3 years ago
Fix for getting ClassCastException while downloading subtitles for an user whose daily limit is reached. In this case, the response contains boolean in data field:
Response: {seconds=0.004, data=false, status=407 Download limit reached}
NOTE: Fix for this bug introduces API incompatibility, ListResponse will now return Optional<List<T>> instead of List<T>.
ListResponse
Optional<List<T>>
List<T>
diff --git a/src/main/java/com/github/wtekiela/opensub4j/response/ListResponse.java b/src/main/java/com/github/wtekiela/opensub4j/response/ListResponse.java index 7718982..4433e7f 100644 --- a/src/main/java/com/github/wtekiela/opensub4j/response/ListResponse.java +++ b/src/main/java/com/github/wtekiela/opensub4j/response/ListResponse.java @@ -14,13 +14,14 @@ package com.github.wtekiela.opensub4j.response; import java.util.List; import java.util.Objects; +import java.util.Optional; public class ListResponse<T> extends Response { @OpenSubtitlesApiSpec(fieldName = "data") - private List<T> data; + private Optional<List<T>> data; - public List<T> getData() { + public Optional<List<T>> getData() { return data; }
SonarCloud Quality Gate failed.
0 Bugs 0 Vulnerabilities 0 Security Hotspots 0 Code Smells
78.6% Coverage 0.0% Duplication
Fix for getting ClassCastException while downloading subtitles for an user whose daily limit is reached. In this case, the response contains boolean in data field:
NOTE: Fix for this bug introduces API incompatibility,
ListResponse
will now returnOptional<List<T>>
instead ofList<T>
.