diff --git a/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java b/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java index 7f5ddd6db..5d4375d0f 100644 --- a/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java +++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java @@ -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()); } diff --git a/test/java/spark/Makefile b/test/java/spark/Makefile index 9523f6496..462447c66 100644 --- a/test/java/spark/Makefile +++ b/test/java/spark/Makefile @@ -19,9 +19,8 @@ build: test: @if [ -z "$$SEAWEEDFS_TEST_ENABLED" ]; then \ echo "Setting SEAWEEDFS_TEST_ENABLED=true"; \ - export SEAWEEDFS_TEST_ENABLED=true; \ fi - mvn test + SEAWEEDFS_TEST_ENABLED=true mvn test test-local: @echo "Testing against local SeaweedFS (localhost:8888)..." @@ -29,12 +28,12 @@ test-local: test-docker: @echo "Running tests in Docker..." - docker-compose up --build --abort-on-container-exit spark-tests - docker-compose down + docker compose up --build --abort-on-container-exit spark-tests + docker compose down docker-up: @echo "Starting SeaweedFS in Docker..." - docker-compose up -d seaweedfs-master seaweedfs-volume seaweedfs-filer + docker compose up -d seaweedfs-master seaweedfs-volume seaweedfs-filer @echo "Waiting for services to be ready..." @sleep 5 @echo "SeaweedFS is ready!" @@ -43,7 +42,7 @@ docker-up: docker-down: @echo "Stopping SeaweedFS Docker containers..." - docker-compose down -v + docker compose down -v run-example: @echo "Running example application..."