Skip to content

Commit e541efe

Browse files
committed
Changed how the default content list gets created in the ListBucketResult so that it does not create a new list every time.
1 parent 1f79171 commit e541efe

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/main/java/com/spectralogic/ds3client/models/ListBucketResult.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class ListBucketResult {
4242

4343
@JsonProperty("Contents")
4444
@JacksonXmlElementWrapper(useWrapping = false)
45-
private List<Contents> contentsList;
45+
private List<Contents> contentsList = new ArrayList<>();
4646

4747
public String getName() {
4848
return name;
@@ -85,7 +85,7 @@ public void setTruncated(final boolean isTruncated) {
8585
}
8686

8787
public List<Contents> getContentsList() {
88-
return contentsList == null ? new ArrayList<Contents>() : contentsList;
88+
return contentsList;
8989
}
9090

9191
public void setContentsList(final List<Contents> contentsList) {

src/test/java/com/spectralogic/ds3client/serializer/XmlOutput_Test.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import com.spectralogic.ds3client.models.ListBucketResult;
2020
import com.spectralogic.ds3client.models.MasterObjectList;
2121
import com.spectralogic.ds3client.models.Objects;
22-
import com.spectralogic.ds3client.serializer.XmlOutput;
2322
import org.junit.Test;
2423

2524
import java.io.IOException;
@@ -55,4 +54,13 @@ public void bucketList() throws IOException {
5554
assertThat(result.getContentsList().size(), is(3));
5655
assertThat(result.getContentsList().get(0).getSize(), is(674570l));
5756
}
57+
58+
@Test
59+
public void bucketListWithEmptyContents() throws IOException {
60+
final String xmlResponse = "<ListBucketResult xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\"><Name>remoteTest16</Name><Prefix/><Marker/><MaxKeys>1000</MaxKeys><IsTruncated>false</IsTruncated></ListBucketResult>";
61+
62+
final ListBucketResult result = XmlOutput.fromXml(xmlResponse, ListBucketResult.class);
63+
assertThat(result, is(notNullValue()));
64+
assertThat(result.getContentsList(), is(notNullValue()));
65+
}
5866
}

0 commit comments

Comments
 (0)