Skip to content

Commit b344aa6

Browse files
committed
Resolving some issues identified during code review.
1 parent fbbccb2 commit b344aa6

File tree

7 files changed

+13
-26
lines changed

7 files changed

+13
-26
lines changed

src/main/java/com/spectralogic/ds3client/NetworkClientImpl.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,7 @@ private class RequestExecutor implements Closeable {
8585
public RequestExecutor(final Ds3Request ds3Request) throws IOException {
8686
this.ds3Request = ds3Request;
8787
this.host = this.buildHost();
88-
try {
89-
this.content = ds3Request.getStream();
90-
}
91-
catch(final XmlProcessingException e) {
92-
throw new RuntimeException(e);
93-
}
88+
this.content = ds3Request.getStream();
9489
if (this.content != null && !this.content.markSupported()) {
9590
throw new RequiresMarkSupportedException();
9691
}

src/main/java/com/spectralogic/ds3client/commands/AbstractRequest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package com.spectralogic.ds3client.commands;
1717

1818
import com.spectralogic.ds3client.models.Checksum;
19-
import com.spectralogic.ds3client.serializer.XmlProcessingException;
2019
import org.apache.http.entity.ContentType;
2120

2221
import java.io.InputStream;
@@ -40,7 +39,7 @@ public ContentType getContentType() {
4039
}
4140

4241
@Override
43-
public InputStream getStream() throws XmlProcessingException {
42+
public InputStream getStream() {
4443
return null;
4544
}
4645

src/main/java/com/spectralogic/ds3client/commands/BulkRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public BulkRequest withWriteOptimization(final WriteOptimization writeOptimizati
5252
return this;
5353
}
5454

55-
private InputStream generateStream() throws XmlProcessingException {
55+
private InputStream generateStream() {
5656
final Ds3ObjectList objects =
5757
new Ds3ObjectList();
5858
objects.setObjects(this.ds3Objects);
@@ -91,7 +91,7 @@ public HttpVerb getVerb() {
9191
public abstract BulkCommand getCommand ();
9292

9393
@Override
94-
public InputStream getStream() throws XmlProcessingException {
94+
public InputStream getStream() {
9595
if (this.stream == null) {
9696
this.stream = generateStream();
9797
}

src/main/java/com/spectralogic/ds3client/commands/Ds3Request.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import com.spectralogic.ds3client.HttpVerb;
1919
import com.spectralogic.ds3client.models.Checksum;
20-
import com.spectralogic.ds3client.serializer.XmlProcessingException;
2120
import org.apache.http.entity.ContentType;
2221

2322
import java.io.InputStream;
@@ -30,7 +29,7 @@ public interface Ds3Request {
3029

3130
public ContentType getContentType();
3231

33-
public InputStream getStream() throws XmlProcessingException;
32+
public InputStream getStream();
3433

3534
public long getSize();
3635

src/main/java/com/spectralogic/ds3client/networking/NetworkClient.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package com.spectralogic.ds3client.networking;
1717

1818
import com.spectralogic.ds3client.commands.Ds3Request;
19-
import com.spectralogic.ds3client.serializer.XmlProcessingException;
2019

2120
import java.io.IOException;
2221
import java.security.SignatureException;

src/main/java/com/spectralogic/ds3client/serializer/XmlOutput.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ public class XmlOutput {
3838
mapper.setFilters(filterProvider);
3939
}
4040

41-
public static String toXml(final Object object) throws XmlProcessingException {
41+
public static String toXml(final Object object) {
4242
return toXml(object, null);
4343
}
4444

45-
private static String toXml(final Object object, final FilterProvider filterProvider) throws XmlProcessingException {
45+
private static String toXml(final Object object, final FilterProvider filterProvider) {
4646
try {
4747
if (filterProvider == null) {
4848
return mapper.writeValueAsString(object);
@@ -51,12 +51,12 @@ private static String toXml(final Object object, final FilterProvider filterProv
5151
return mapper.writer(filterProvider).writeValueAsString(object);
5252
}
5353
}
54-
catch(JsonProcessingException e) {
55-
throw new XmlProcessingException(e);
54+
catch(final JsonProcessingException e) {
55+
throw new RuntimeException(new XmlProcessingException(e));
5656
}
5757
}
5858

59-
public static String toXml(final Ds3ObjectList objects, final BulkCommand command) throws XmlProcessingException {
59+
public static String toXml(final Ds3ObjectList objects, final BulkCommand command) {
6060
if (command == BulkCommand.GET) {
6161
final FilterProvider filters = new SimpleFilterProvider().addFilter("sizeFilter",
6262
SimpleBeanPropertyFilter.serializeAllExcept("Size"));

src/test/java/com/spectralogic/ds3client/MockNetwork.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,9 @@ public WebResponse getResponse(final Ds3Request request)
7979
this.assertMapsEqual(this.queryParams, request.getQueryParams());
8080
}
8181
if (this.requestContent != null) {
82-
try {
83-
final InputStream stream = request.getStream();
84-
assertThat(stream, is(notNullValue()));
85-
assertThat(IOUtils.toString(stream), is(this.requestContent));
86-
}
87-
catch(final XmlProcessingException e) {
88-
fail("Received an xml processing exception.");
89-
}
82+
final InputStream stream = request.getStream();
83+
assertThat(stream, is(notNullValue()));
84+
assertThat(IOUtils.toString(stream), is(this.requestContent));
9085
}
9186
return new MockedWebResponse(this.responseContent, this.statusCode);
9287
}

0 commit comments

Comments
 (0)