Skip to content

Commit befab27

Browse files
author
Georgi Neykov
committed
fix(composer): Fix a NPE in DataApiResponse
- Fix a NPE when `close()` is called on non-successful DataApiResponse instances.
1 parent 2c900e7 commit befab27

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

composer/src/main/java/com/pcloud/networking/api/DataApiResponse.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import java.io.Closeable;
2222

23+
import static com.pcloud.utils.IOUtils.closeQuietly;
24+
2325
/**
2426
* An implementation to house the {@linkplain ResponseData} for the response of a network call
2527
*
@@ -53,7 +55,7 @@ public DataApiResponse(long resultCode, String message) {
5355
*/
5456
final void setResponseData(ResponseData data) {
5557
if (this.responseData != null) {
56-
throw new AssertionError("ResponseData already set to instance.");
58+
throw new IllegalStateException("ResponseData already set to instance.");
5759
}
5860
this.responseData = data;
5961
}
@@ -69,6 +71,6 @@ public ResponseData responseData() {
6971

7072
@Override
7173
public void close() {
72-
responseData.close();
74+
closeQuietly(responseData);
7375
}
7476
}

0 commit comments

Comments
 (0)