[java-metadata-aggregator] branch master updated: MDA-166 - serializers may now throw IOException
Ian Young
ian at iay.org.uk
Wed Apr 26 12:45:49 EDT 2017
This is an automated email from the git hooks/post-receive script.
iay pushed a commit to branch master
in repository java-metadata-aggregator.
View the commit online:
http://git.shibboleth.net/view/?p=java-metadata-aggregator.git;a=commit;h=4b505fc93636c5d0bd732bab49678d8b1542a090
The following commit(s) were added to refs/heads/master by this push:
new 4b505fc MDA-166 - serializers may now throw IOException
4b505fc is described below
commit 4b505fc93636c5d0bd732bab49678d8b1542a090
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Wed Apr 26 17:45:40 2017 +0100
MDA-166 - serializers may now throw IOException
---
.../java/net/shibboleth/metadata/ItemCollectionSerializer.java | 6 +++++-
.../src/main/java/net/shibboleth/metadata/ItemSerializer.java | 8 ++++++--
.../net/shibboleth/metadata/SimpleItemCollectionSerializer.java | 4 +++-
.../java/net/shibboleth/metadata/dom/DOMElementSerializer.java | 9 +++++----
.../shibboleth/metadata/SimpleItemCollectionSerializerTest.java | 2 +-
.../net/shibboleth/metadata/dom/DOMElementSerializerTest.java | 2 +-
6 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/ItemCollectionSerializer.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/ItemCollectionSerializer.java
index 329d7ec..263ed89 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/ItemCollectionSerializer.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/ItemCollectionSerializer.java
@@ -17,6 +17,7 @@
package net.shibboleth.metadata;
+import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;
@@ -37,7 +38,10 @@ public interface ItemCollectionSerializer<T> {
* @param items {@link Collection} of {@link Item}s to be serialized
* @param output output stream to which the serialized form of the {@link Item}
* collection will be written
+ *
+ * @throws IOException if an I/O exception occurs during serialization
*/
- public void serializeCollection(@Nonnull Collection<Item<T>> items, @Nonnull OutputStream output);
+ public void serializeCollection(@Nonnull Collection<Item<T>> items, @Nonnull OutputStream output)
+ throws IOException;
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/ItemSerializer.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/ItemSerializer.java
index 536798f..1eb4b1f 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/ItemSerializer.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/ItemSerializer.java
@@ -17,6 +17,7 @@
package net.shibboleth.metadata;
+import java.io.IOException;
import java.io.OutputStream;
import javax.annotation.Nonnull;
@@ -36,6 +37,9 @@ public interface ItemSerializer<T> {
*
* @param item {@link Item} to be serialized
* @param output output stream to which the serialized {@link Item} will be written
+ *
+ * @throws IOException if an I/O exception occurs during serialization
*/
- public void serialize(@Nonnull Item<T> item, @Nonnull OutputStream output);
-}
\ No newline at end of file
+ public void serialize(@Nonnull Item<T> item, @Nonnull OutputStream output)
+ throws IOException;
+}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/SimpleItemCollectionSerializer.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/SimpleItemCollectionSerializer.java
index 4ad4cec..5715fec 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/SimpleItemCollectionSerializer.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/SimpleItemCollectionSerializer.java
@@ -17,6 +17,7 @@
package net.shibboleth.metadata;
+import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;
@@ -43,7 +44,8 @@ public class SimpleItemCollectionSerializer<T> implements ItemCollectionSerializ
}
@Override
- public void serializeCollection(@Nonnull final Collection<Item<T>> items, @Nonnull final OutputStream output) {
+ public void serializeCollection(@Nonnull final Collection<Item<T>> items, @Nonnull final OutputStream output)
+ throws IOException {
for (final Item<T> item : items) {
serializer.serialize(item, output);
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMElementSerializer.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMElementSerializer.java
index f102978..78aaf28 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMElementSerializer.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/DOMElementSerializer.java
@@ -17,6 +17,7 @@
package net.shibboleth.metadata.dom;
+import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;
import java.util.Iterator;
@@ -50,9 +51,9 @@ public class DOMElementSerializer implements ItemSerializer<Element>, ItemCollec
/** Class logger. */
private final Logger log = LoggerFactory.getLogger(DOMElementSerializer.class);
- /** {@inheritDoc} */
@Override
- public void serialize(@Nonnull final Item<Element> item, @Nonnull final OutputStream output) {
+ public void serialize(@Nonnull final Item<Element> item, @Nonnull final OutputStream output)
+ throws IOException {
if (item == null) {
return;
}
@@ -66,13 +67,13 @@ public class DOMElementSerializer implements ItemSerializer<Element>, ItemCollec
serializer.transform(new DOMSource(documentRoot.getOwnerDocument()), new StreamResult(output));
} catch (final TransformerException e) {
log.error("Unable to write out XML", e);
+ throw new IOException(e);
}
}
- /** {@inheritDoc} */
@Override
public void serializeCollection(@Nonnull final Collection<Item<Element>> items,
- @Nonnull final OutputStream output) {
+ @Nonnull final OutputStream output) throws IOException {
final Iterator<Item<Element>> iter = items.iterator();
if (iter.hasNext()) {
serialize(iter.next(), output);
diff --git a/aggregator-pipeline/src/test/java/net/shibboleth/metadata/SimpleItemCollectionSerializerTest.java b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/SimpleItemCollectionSerializerTest.java
index 6ef4056..ea757de 100644
--- a/aggregator-pipeline/src/test/java/net/shibboleth/metadata/SimpleItemCollectionSerializerTest.java
+++ b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/SimpleItemCollectionSerializerTest.java
@@ -29,7 +29,7 @@ import org.testng.annotations.Test;
public class SimpleItemCollectionSerializerTest {
@Test
- public void serializeCollection() {
+ public void serializeCollection() throws Exception {
final Item<String> i1 = new MockItem("one");
final Item<String> i2 = new MockItem("two");
final Item<String> i3 = new MockItem("three");
diff --git a/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/DOMElementSerializerTest.java b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/DOMElementSerializerTest.java
index 2bd31e5..333586a 100644
--- a/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/DOMElementSerializerTest.java
+++ b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/DOMElementSerializerTest.java
@@ -34,7 +34,7 @@ public class DOMElementSerializerTest extends BaseDOMTest {
}
@Test
- public void noItemsCollection() {
+ public void noItemsCollection() throws Exception {
final Collection<Item<Element>> items = new ArrayList<>();
final ByteArrayOutputStream output = new ByteArrayOutputStream();
final DOMElementSerializer ser = new DOMElementSerializer();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list