--- old/test/java/sql/util/BaseTest.java 2014-05-15 18:10:26.000000000 -0400 +++ new/test/java/sql/util/BaseTest.java 2014-05-15 18:10:26.000000000 -0400 @@ -61,29 +61,31 @@ public void tearDownMethod() throws Exception { } - /** + /* * Take some form of SQLException, serialize and deserialize it - * - * @param SQLException - * @param ex SQLException - * @return deserialized SQLException - * @throws IOException - * @throws ClassNotFoundException */ @SuppressWarnings("unchecked") protected T createSerializedException(T ex) throws IOException, ClassNotFoundException { - T ex1; + return (T) serializeDeserializeObject(ex); + } + + /* + * Utility method to serialize and deserialize an object + */ + @SuppressWarnings("unchecked") + protected T serializeDeserializeObject(T o) + throws IOException, ClassNotFoundException { + T o1; ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try (ObjectOutputStream oos = new ObjectOutputStream(baos) ) { - oos.writeObject(ex); + try (ObjectOutputStream oos = new ObjectOutputStream(baos)) { + oos.writeObject(o); } - try (ObjectInputStream ois = - new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) { - ex1 = (T) ois.readObject(); + try (ObjectInputStream ois + = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) { + o1 = (T) ois.readObject(); } - return ex1; + return o1; } - }