File tree Expand file tree Collapse file tree
gcloud-java-datastore/src
main/java/com/google/gcloud/datastore
test/java/com/google/gcloud/datastore
main/java/com/google/gcloud/storage
test/java/com/google/gcloud/storage Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717package com .google .gcloud .datastore ;
1818
1919import com .google .gcloud .ServiceFactory ;
20+ import java .io .ObjectStreamException ;
2021
2122/**
2223 * A base class for Datastore factories.
2324 */
2425public abstract class DatastoreFactory implements ServiceFactory <Datastore , DatastoreOptions > {
2526
27+ private static final long serialVersionUID = 5037190305022535983L ;
28+
2629 private static final DatastoreFactory INSTANCE = new DatastoreFactory () {
27- @ Override
28- public Datastore get (DatastoreOptions options ) {
29- return new DatastoreImpl (options , this );
30- }
31- };
30+
31+ private static final long serialVersionUID = 5893914895344559491L ;
32+
33+ @ Override
34+ public Datastore get (DatastoreOptions options ) {
35+ return new DatastoreImpl (options , this );
36+ }
37+
38+ private Object readResolve () throws ObjectStreamException {
39+ return INSTANCE ;
40+ }
41+ };
3242
3343 /**
3444 * Returns the default factory instance.
Original file line number Diff line number Diff line change @@ -135,7 +135,8 @@ public class SerializationTest {
135135 @ Test
136136 public void testStorageFactory () throws Exception {
137137 DatastoreFactory serializedCopy = serializeAndDeserialize (DATASTORE_FACTORY );
138- assertNotSame (DATASTORE_FACTORY , serializedCopy );
138+ assertEquals (DATASTORE_FACTORY , serializedCopy );
139+ assertEquals (DATASTORE_FACTORY .hashCode (), serializedCopy .hashCode ());
139140 }
140141
141142 @ Test
Original file line number Diff line number Diff line change 1717package com .google .gcloud .storage ;
1818
1919import com .google .gcloud .ServiceFactory ;
20+ import java .io .ObjectStreamException ;
2021
2122/**
2223 * A base class for Storage factories.
2324 */
2425public abstract class StorageFactory implements ServiceFactory <Storage , StorageOptions > {
2526
27+ private static final long serialVersionUID = 1866883249985063753L ;
28+
2629 private static final StorageFactory INSTANCE = new StorageFactory () {
30+
31+ private static final long serialVersionUID = -7985210081064222485L ;
32+
2733 @ Override
2834 public Storage get (StorageOptions options ) {
2935 return new StorageImpl (options , this );
3036 }
37+
38+ private Object readResolve () throws ObjectStreamException {
39+ return INSTANCE ;
40+ }
3141 };
3242
3343 /**
Original file line number Diff line number Diff line change @@ -69,7 +69,8 @@ public class SerializationTest {
6969 @ Test
7070 public void testStorageFactory () throws Exception {
7171 StorageFactory serializedCopy = serializeAndDeserialize (STORAGE_FACTORY );
72- assertNotSame (STORAGE_FACTORY , serializedCopy );
72+ assertEquals (STORAGE_FACTORY , serializedCopy );
73+ assertEquals (STORAGE_FACTORY .hashCode (), serializedCopy .hashCode ());
7374 }
7475
7576 @ Test
You can’t perform that action at this time.
0 commit comments