Skip to content

Commit df8d342

Browse files
authored
Move serialization logic to Core (#2258)
1 parent fe8fc81 commit df8d342

File tree

2 files changed

+3
-73
lines changed

2 files changed

+3
-73
lines changed

schemacrawler-scripting/src/main/java/schemacrawler/tools/formatter/serialize/CatalogModelInputStream.java

Lines changed: 0 additions & 59 deletions
This file was deleted.

schemacrawler-scripting/src/main/java/schemacrawler/tools/formatter/serialize/JavaSerializedCatalog.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,18 @@
1010

1111
import static java.util.Objects.requireNonNull;
1212

13-
import java.io.IOException;
1413
import java.io.InputStream;
15-
import java.io.ObjectOutputStream;
1614
import java.io.OutputStream;
1715
import java.io.Writer;
1816
import 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. */
2320
public 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

Comments
 (0)