1010
1111import static java .util .Objects .requireNonNull ;
1212
13- import java .io .IOException ;
1413import java .io .InputStream ;
15- import java .io .ObjectOutputStream ;
1614import java .io .OutputStream ;
1715import java .io .Writer ;
1816import schemacrawler .schema .Catalog ;
19- import schemacrawler .schemacrawler .exceptions .ExecutionRuntimeException ;
20- import schemacrawler .schemacrawler .exceptions .IORuntimeException ;
17+ import schemacrawler .utility .SerializedCatalogUtility ;
2118
2219/** Decorates a database to allow for serialization to and from plain Java serialization. */
2320public final class JavaSerializedCatalog implements CatalogSerializer {
2421
2522 private static Catalog readCatalog (final InputStream in ) {
2623 requireNonNull (in , "No input stream provided" );
27- try (final CatalogModelInputStream objIn = new CatalogModelInputStream (in )) {
28- return (Catalog ) objIn .readObject ();
29- } catch (ClassNotFoundException | IOException e ) {
30- throw new ExecutionRuntimeException ("Cannot deserialize catalog" , e );
31- }
24+ return SerializedCatalogUtility .readCatalog (in );
3225 }
3326
3427 private final Catalog catalog ;
@@ -50,11 +43,7 @@ public Catalog getCatalog() {
5043 @ Override
5144 public void save (final OutputStream out ) {
5245 requireNonNull (out , "No output stream provided" );
53- try (final ObjectOutputStream objOut = new ObjectOutputStream (out )) {
54- objOut .writeObject (catalog );
55- } catch (final IOException e ) {
56- throw new IORuntimeException ("Could not serialize catalog" , e );
57- }
46+ SerializedCatalogUtility .saveCatalog (catalog , out );
5847 }
5948
6049 /** {@inheritDoc} */
0 commit comments