Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<name>DashScope Java SDK</name>
<groupId>com.alibaba</groupId>
<artifactId>dashscope-sdk-java</artifactId>
<version>2.22.26</version>
<version>2.22.27</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down
22 changes: 21 additions & 1 deletion src/main/java/com/alibaba/dashscope/common/DashScopeResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,27 @@ protected <T extends Result> T fromResponse(Protocol protocol, NetworkResponse r
this.output = response.getBinary();
}
} else {
JsonObject jsonObject = JsonUtils.parse(response.getMessage());
String message = response.getMessage();
if (message == null || message.isEmpty()) {
this.output = null;
this.setStatusCode(
response.getHttpStatusCode() != null ? response.getHttpStatusCode() : 500);
this.setCode("EmptyResponse");
Comment thread
lzsweb marked this conversation as resolved.
Outdated
this.setMessage("Response message is empty");
return (T) this;
}
JsonObject jsonObject;
try {
jsonObject = JsonUtils.parse(message);
} catch (Exception e) {
// Non-JSON response (e.g., plain text from cancel async task)
this.output = null;
this.setStatusCode(
Comment thread
lzsweb marked this conversation as resolved.
Outdated
response.getHttpStatusCode() != null ? response.getHttpStatusCode() : 200);
this.setCode("");
this.setMessage(message);
return (T) this;
}
// Set HTTP status code if available
if (response.getHttpStatusCode() != null) {
this.setStatusCode(response.getHttpStatusCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public void onError(String errorMsg) {

@Override
public void onUnknown(String msg) {
System.out.println(msg);
// Ignored
}

@Override
Expand Down
Loading