mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-16 11:30:44 +02:00
java: fix NPE in SeaweedWrite and Makefile env var scope
- Add null check for HttpEntity in SeaweedWrite.multipartUpload() to prevent NPE when response.getEntity() returns null - Fix Makefile test target to properly export SEAWEEDFS_TEST_ENABLED by setting it on the same command line as mvn test - Update docker-compose commands to use V2 syntax (docker compose) for consistency with GitHub Actions workflow
This commit is contained in:
@@ -2,6 +2,7 @@ package seaweedfs.client;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.protobuf.ByteString;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.mime.HttpMultipartMode;
|
||||
@@ -192,9 +193,10 @@ public class SeaweedWrite {
|
||||
|
||||
try {
|
||||
if (response.getStatusLine().getStatusCode() / 100 != 2) {
|
||||
if (response.getEntity().getContentType() != null
|
||||
&& response.getEntity().getContentType().getValue().equals("application/json")) {
|
||||
throw new IOException(EntityUtils.toString(response.getEntity(), "UTF-8"));
|
||||
HttpEntity entity = response.getEntity();
|
||||
if (entity != null && entity.getContentType() != null
|
||||
&& entity.getContentType().getValue().equals("application/json")) {
|
||||
throw new IOException(EntityUtils.toString(entity, "UTF-8"));
|
||||
} else {
|
||||
throw new IOException(response.getStatusLine().getReasonPhrase());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user