Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Minor cleanup and class renaming.

  • Loading branch information...
commit bf8ed64ef2ef30fdbf448f044522b90ddaa98e53 1 parent bf6e630
@thomas-kielbus thomas-kielbus authored
View
4 megadesk-curator/src/main/java/com/liveramp/megadesk/curator/state/CuratorPersistence.java
@@ -21,9 +21,9 @@
import com.liveramp.megadesk.core.state.Persistence;
import com.liveramp.megadesk.core.state.PersistenceTransaction;
import com.liveramp.megadesk.recipes.state.persistence.SerializationHandler;
-import com.liveramp.megadesk.recipes.state.persistence.SerializedPersistence;
+import com.liveramp.megadesk.recipes.state.persistence.SerializationPersistence;
-public class CuratorPersistence<VALUE> extends SerializedPersistence<VALUE> implements Persistence<VALUE> {
+public class CuratorPersistence<VALUE> extends SerializationPersistence<VALUE> implements Persistence<VALUE> {
private CuratorFramework curator;
private final String path;
View
10 .../persistence/JavaObjectSerialization.java → ...tence/JavaObjectSerializationHandler.java
@@ -22,7 +22,7 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-public class JavaObjectSerialization<T> implements SerializationHandler<T> {
+public class JavaObjectSerializationHandler<T> implements SerializationHandler<T> {
@Override
public byte[] serialize(T value) throws IOException {
@@ -34,13 +34,17 @@
}
@Override
- public T deserialize(byte[] bytes) throws IOException, ClassNotFoundException {
+ public T deserialize(byte[] bytes) throws IOException {
if (bytes.length > 0) {
ByteArrayInputStream bytesInputStream = new ByteArrayInputStream(bytes);
ObjectInputStream objectInputStream = new ObjectInputStream(bytesInputStream);
Object object;
try {
- object = objectInputStream.readObject();
+ try {
+ object = objectInputStream.readObject();
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e);
+ }
} finally {
objectInputStream.close();
}
View
2  ...s/src/main/java/com/liveramp/megadesk/recipes/state/persistence/SerializationHandler.java
@@ -22,5 +22,5 @@
public byte[] serialize(T value) throws IOException;
- public T deserialize(byte[] bytes) throws IOException, ClassNotFoundException;
+ public T deserialize(byte[] bytes) throws IOException;
}
View
8 ...te/persistence/SerializedPersistence.java → ...persistence/SerializationPersistence.java
@@ -22,11 +22,11 @@
import com.liveramp.megadesk.core.state.Persistence;
import com.liveramp.megadesk.core.state.PersistenceTransaction;
-public abstract class SerializedPersistence<VALUE> extends BasePersistence<VALUE> implements Persistence<VALUE> {
+public abstract class SerializationPersistence<VALUE> extends BasePersistence<VALUE> implements Persistence<VALUE> {
private final SerializationHandler<VALUE> serializationHandler;
- protected SerializedPersistence(SerializationHandler<VALUE> serializationHandler) {
+ protected SerializationPersistence(SerializationHandler<VALUE> serializationHandler) {
this.serializationHandler = serializationHandler;
}
@@ -38,8 +38,6 @@ public VALUE read() {
value = serializationHandler.deserialize(data);
} catch (IOException e) {
throw new RuntimeException(e);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
}
return value;
}
@@ -48,7 +46,7 @@ public VALUE read() {
public void write(VALUE value) {
try {
writeBytes(serializationHandler.serialize(value));
- } catch (Exception e) {
+ } catch (IOException e) {
throw new RuntimeException(e);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.