Skip to content

Commit 8c073ff

Browse files
committed
Updated to the latest version of our xml processing dependencies. Changed the way most places parse the xml bodies. Instead of reading the xml body all into memory at once, the SDK will now stream the contents to the xml parsing library which should improve performance in most cases.
1 parent 59f02e4 commit 8c073ff

File tree

11 files changed

+24
-60
lines changed

11 files changed

+24
-60
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
allprojects {
1717
group = 'com.spectralogic.ds3'
18-
version = '1.1.0-RC5'
18+
version = '1.1.0-RC6'
1919
}
2020

2121
subprojects {

ds3-sdk/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ dependencies {
4343
compile 'org.apache.httpcomponents:httpclient:4.3.2'
4444
compile 'commons-codec:commons-codec:1.10'
4545
compile 'commons-io:commons-io:2.1'
46-
compile 'org.codehaus.woodstox:woodstox-core-asl:4.2.0'
47-
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.5.0'
46+
compile 'org.codehaus.woodstox:woodstox-core-asl:4.4.1'
47+
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.5.3'
4848
compile 'com.google.guava:guava:18.0'
4949
testCompile 'org.hamcrest:hamcrest-library:1.3'
5050
}

ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/AllocateJobChunkResponse.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@
1919
import com.spectralogic.ds3client.networking.WebResponse;
2020
import com.spectralogic.ds3client.serializer.XmlOutput;
2121

22-
import org.apache.commons.io.IOUtils;
23-
2422
import java.io.IOException;
2523
import java.io.InputStream;
26-
import java.io.StringWriter;
2724

2825
public class AllocateJobChunkResponse extends AbstractResponse {
2926
private Status status;
@@ -70,10 +67,8 @@ protected void processResponse() throws IOException {
7067
}
7168

7269
private static Objects parseChunk(final WebResponse webResponse) throws IOException {
73-
try (final InputStream content = webResponse.getResponseStream();
74-
final StringWriter writer = new StringWriter()) {
75-
IOUtils.copy(content, writer, UTF8);
76-
return XmlOutput.fromXml(writer.toString(), Objects.class);
70+
try (final InputStream content = webResponse.getResponseStream()) {
71+
return XmlOutput.fromXml(content, Objects.class);
7772
}
7873
}
7974

ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/DeleteMultipleObjectsResponse.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
import com.spectralogic.ds3client.models.delete.DeleteResult;
1919
import com.spectralogic.ds3client.networking.WebResponse;
2020
import com.spectralogic.ds3client.serializer.XmlOutput;
21-
import org.apache.commons.io.IOUtils;
2221

2322
import java.io.IOException;
2423
import java.io.InputStream;
25-
import java.io.StringWriter;
2624

2725
public class DeleteMultipleObjectsResponse extends AbstractResponse {
2826

@@ -40,10 +38,8 @@ public DeleteResult getResult() {
4038
protected void processResponse() throws IOException {
4139
try {
4240
this.checkStatusCode(200);
43-
try (final InputStream content = getResponse().getResponseStream();
44-
final StringWriter writer = new StringWriter()) {
45-
IOUtils.copy(content, writer, UTF8);
46-
this.result = XmlOutput.fromXml(writer.toString(), DeleteResult.class);
41+
try (final InputStream content = getResponse().getResponseStream()) {
42+
this.result = XmlOutput.fromXml(content, DeleteResult.class);
4743
}
4844
} finally {
4945
this.getResponse().close();

ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/GetAvailableJobChunksResponse.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@
1919
import com.spectralogic.ds3client.networking.WebResponse;
2020
import com.spectralogic.ds3client.serializer.XmlOutput;
2121

22-
import org.apache.commons.io.IOUtils;
23-
2422
import java.io.IOException;
2523
import java.io.InputStream;
26-
import java.io.StringWriter;
2724

2825
public class GetAvailableJobChunksResponse extends AbstractResponse {
2926
private Status status;
@@ -71,10 +68,8 @@ protected void processResponse() throws IOException {
7168
}
7269

7370
private static MasterObjectList parseMasterObjectList(final WebResponse webResponse) throws IOException {
74-
try (final InputStream content = webResponse.getResponseStream();
75-
final StringWriter writer = new StringWriter()) {
76-
IOUtils.copy(content, writer, UTF8);
77-
return XmlOutput.fromXml(writer.toString(), MasterObjectList.class);
71+
try (final InputStream content = webResponse.getResponseStream()) {
72+
return XmlOutput.fromXml(content, MasterObjectList.class);
7873
}
7974
}
8075

ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/GetBucketResponse.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@
1919
import com.spectralogic.ds3client.models.ListBucketResult;
2020
import com.spectralogic.ds3client.networking.WebResponse;
2121
import com.spectralogic.ds3client.serializer.XmlOutput;
22-
23-
import org.apache.commons.io.IOUtils;
22+
import org.slf4j.Logger;
23+
import org.slf4j.LoggerFactory;
2424

2525
import java.io.IOException;
2626
import java.io.InputStream;
27-
import java.io.StringWriter;
2827

2928
public class GetBucketResponse extends AbstractResponse {
30-
29+
private final static Logger LOG = LoggerFactory.getLogger(GetBucketResponse.class);
3130
private ListBucketResult result;
3231

3332
public GetBucketResponse(final WebResponse response) throws IOException {
@@ -44,9 +43,9 @@ protected void processResponse() throws IOException {
4443
try (final WebResponse response = this.getResponse();
4544
final InputStream contentStream = response.getResponseStream()) {
4645
this.checkStatusCode(200);
47-
final StringWriter writer = new StringWriter();
48-
IOUtils.copy(contentStream, writer, UTF8);
49-
this.result = XmlOutput.fromXml(writer.toString(), ListBucketResult.class);
46+
LOG.debug("Starting bucket xml parsing");
47+
this.result = XmlOutput.fromXml(contentStream, ListBucketResult.class);
48+
LOG.debug("Finished bucket xml parsing");
5049
}
5150
}
5251
}

ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/GetJobResponse.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@ public MasterObjectList getMasterObjectList() {
4545
}
4646

4747
private static MasterObjectList parseMasterObjectList(final WebResponse webResponse) throws IOException {
48-
try (final InputStream content = webResponse.getResponseStream();
49-
final StringWriter writer = new StringWriter()) {
50-
IOUtils.copy(content, writer, UTF8);
51-
return XmlOutput.fromXml(writer.toString(), MasterObjectList.class);
48+
try (final InputStream content = webResponse.getResponseStream()) {
49+
return XmlOutput.fromXml(content, MasterObjectList.class);
5250
}
5351
}
5452
}

ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/GetJobsResponse.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@
2020
import com.spectralogic.ds3client.networking.WebResponse;
2121
import com.spectralogic.ds3client.serializer.XmlOutput;
2222

23-
import org.apache.commons.io.IOUtils;
24-
2523
import java.io.IOException;
2624
import java.io.InputStream;
27-
import java.io.StringWriter;
2825
import java.util.List;
2926

3027
public class GetJobsResponse extends AbstractResponse {
@@ -47,10 +44,8 @@ public List<JobInfo> getJobs() {
4744
}
4845

4946
private static Jobs parseJobs(final WebResponse webResponse) throws IOException {
50-
try (final InputStream content = webResponse.getResponseStream();
51-
final StringWriter writer = new StringWriter()) {
52-
IOUtils.copy(content, writer, UTF8);
53-
return XmlOutput.fromXml(writer.toString(), Jobs.class);
47+
try (final InputStream content = webResponse.getResponseStream()) {
48+
return XmlOutput.fromXml(content, Jobs.class);
5449
}
5550
}
5651

ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/GetServiceResponse.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@
1919
import com.spectralogic.ds3client.networking.WebResponse;
2020
import com.spectralogic.ds3client.serializer.XmlOutput;
2121

22-
import org.apache.commons.io.IOUtils;
23-
2422
import java.io.IOException;
2523
import java.io.InputStream;
26-
import java.io.StringWriter;
2724

2825
public class GetServiceResponse extends AbstractResponse {
2926

@@ -41,10 +38,8 @@ public ListAllMyBucketsResult getResult() {
4138
protected void processResponse() throws IOException {
4239
try (final WebResponse response = this.getResponse()) {
4340
this.checkStatusCode(200);
44-
try (final InputStream content = response.getResponseStream();
45-
final StringWriter writer = new StringWriter()) {
46-
IOUtils.copy(content, writer, UTF8);
47-
this.result = XmlOutput.fromXml(writer.toString(), ListAllMyBucketsResult.class);
41+
try (final InputStream content = response.getResponseStream()) {
42+
this.result = XmlOutput.fromXml(content, ListAllMyBucketsResult.class);
4843
}
4944
}
5045
}

ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/ModifyJobResponse.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@
1919
import com.spectralogic.ds3client.networking.WebResponse;
2020
import com.spectralogic.ds3client.serializer.XmlOutput;
2121

22-
import org.apache.commons.io.IOUtils;
23-
2422
import java.io.IOException;
2523
import java.io.InputStream;
26-
import java.io.StringWriter;
2724

2825
public class ModifyJobResponse extends AbstractResponse {
2926
private MasterObjectList masterObjectList;
@@ -45,10 +42,8 @@ public MasterObjectList getMasterObjectList() {
4542
}
4643

4744
private static MasterObjectList parseMasterObjectList(final WebResponse webResponse) throws IOException {
48-
try (final InputStream content = webResponse.getResponseStream();
49-
final StringWriter writer = new StringWriter()) {
50-
IOUtils.copy(content, writer, UTF8);
51-
return XmlOutput.fromXml(writer.toString(), MasterObjectList.class);
45+
try (final InputStream content = webResponse.getResponseStream()) {
46+
return XmlOutput.fromXml(content, MasterObjectList.class);
5247
}
5348
}
5449
}

0 commit comments

Comments
 (0)