File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
main/java/org/springframework/core/convert
test/java/org/springframework/core/convert Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 1616
1717package org .springframework .core .convert ;
1818
19+ import java .io .Serializable ;
1920import java .lang .annotation .Annotation ;
2021import java .lang .reflect .Array ;
2122import java .lang .reflect .Field ;
3839 * @author Sam Brannen
3940 * @since 3.0
4041 */
41- public class TypeDescriptor {
42+ public class TypeDescriptor implements Serializable {
43+
44+ private static final long serialVersionUID = 1L ;
45+
4246
4347 static final Annotation [] EMPTY_ANNOTATION_ARRAY = new Annotation [0 ];
4448
Original file line number Diff line number Diff line change 1616
1717package org .springframework .core .convert ;
1818
19+ import java .io .ByteArrayInputStream ;
20+ import java .io .ByteArrayOutputStream ;
21+ import java .io .ObjectInputStream ;
22+ import java .io .ObjectOutputStream ;
1923import java .lang .annotation .ElementType ;
2024import java .lang .annotation .Retention ;
2125import java .lang .annotation .RetentionPolicy ;
3236import org .junit .Test ;
3337import org .springframework .core .MethodParameter ;
3438
39+ import static org .hamcrest .Matchers .*;
3540import static org .junit .Assert .*;
3641
3742/**
@@ -870,4 +875,16 @@ public void createStringArray() throws Exception {
870875 public void createNullArray () throws Exception {
871876 assertNull (TypeDescriptor .array (null ));
872877 }
878+
879+ @ Test
880+ public void serializable () throws Exception {
881+ TypeDescriptor typeDescriptor = TypeDescriptor .forObject ("" );
882+ ByteArrayOutputStream out = new ByteArrayOutputStream ();
883+ ObjectOutputStream outputStream = new ObjectOutputStream (out );
884+ outputStream .writeObject (typeDescriptor );
885+ ObjectInputStream inputStream = new ObjectInputStream (new ByteArrayInputStream (
886+ out .toByteArray ()));
887+ TypeDescriptor readObject = (TypeDescriptor ) inputStream .readObject ();
888+ assertThat (readObject , equalTo (typeDescriptor ));
889+ }
873890}
You can’t perform that action at this time.
0 commit comments