Skip to content

Commit cc8a7cd

Browse files
graycreateclaude
andauthored
fix: handle null ResponseBody source in network interceptor (#107)
- Replace custom ResponseBody anonymous class with ResponseBody.create() - Ensures valid BufferedSource is returned instead of null - Prevents NullPointerException when OkHttp attempts to close response - Fixes crash reported in Google Play Console 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent d503305 commit cc8a7cd

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

app/src/main/java/me/ghui/v2er/network/APIService.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,7 @@ public Response intercept(Chain chain) throws IOException {
127127
.protocol(Protocol.HTTP_1_1)
128128
.code(404)
129129
.message("Exeception when execute chain.proceed request")
130-
.body(new ResponseBody() {
131-
@Nullable
132-
@Override
133-
public MediaType contentType() {
134-
return null;
135-
}
136-
137-
@Override
138-
public long contentLength() {
139-
return 0;
140-
}
141-
142-
@Override
143-
public BufferedSource source() {
144-
return null;
145-
}
146-
})
130+
.body(ResponseBody.create("Network error occurred", MediaType.parse("text/plain")))
147131
.request(request).build();
148132
}
149133
}

0 commit comments

Comments
 (0)