File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
main/java/org/springframework/beans/propertyeditors
test/java/org/springframework/beans/propertyeditors Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 27
27
*
28
28
* @author Nicholas Williams
29
29
* @author Sam Brannen
30
+ * @author Ngoc Nhan
30
31
* @since 4.0
31
32
* @see java.time.ZoneId
32
33
* @see TimeZoneEditor
@@ -38,7 +39,13 @@ public void setAsText(String text) throws IllegalArgumentException {
38
39
if (StringUtils .hasText (text )) {
39
40
text = text .trim ();
40
41
}
41
- setValue (ZoneId .of (text ));
42
+ try {
43
+
44
+ setValue (ZoneId .of (text ));
45
+ }
46
+ catch (Exception ex ) {
47
+ throw new IllegalArgumentException ("Failed to convert ZoneId for " + text , ex );
48
+ }
42
49
}
43
50
44
51
@ Override
Original file line number Diff line number Diff line change 23
23
import org .junit .jupiter .params .provider .ValueSource ;
24
24
25
25
import static org .assertj .core .api .Assertions .assertThat ;
26
+ import static org .assertj .core .api .Assertions .assertThatIllegalArgumentException ;
26
27
27
28
/**
28
29
* @author Nicholas Williams
29
30
* @author Sam Brannen
31
+ * @author Ngoc Nhan
30
32
*/
31
33
class ZoneIdEditorTests {
32
34
@@ -69,4 +71,9 @@ void getValueAsText() {
69
71
assertThat (editor .getAsText ()).as ("The text version is not correct." ).isEqualTo ("America/New_York" );
70
72
}
71
73
74
+ @ Test
75
+ void throwIllegalArgumentException () {
76
+ assertThatIllegalArgumentException ().isThrownBy (() -> editor .setAsText ("Hello, World!" ));
77
+ }
78
+
72
79
}
You can’t perform that action at this time.
0 commit comments