File tree 3 files changed +34
-1
lines changed
main/java/software/amazon/awssdk/awscore/exception
test/java/software/amazon/awssdk/awscore/exception
3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "type" : " bugfix" ,
3
+ "category" : " AWS SDK for Java v2" ,
4
+ "contributor" : " " ,
5
+ "description" : " Fixed an issue in AwsServiceException#getMessage() where it returned an empty string instead of null when the message is null."
6
+ }
Original file line number Diff line number Diff line change @@ -79,7 +79,8 @@ public String getMessage() {
79
79
joiner .add (diagnostics .toString ());
80
80
}
81
81
82
- return joiner .toString ();
82
+ String result = joiner .toString ();
83
+ return result .isEmpty () ? super .getMessage () : result ;
83
84
}
84
85
85
86
private String serviceDiagnostics () {
Original file line number Diff line number Diff line change @@ -122,6 +122,32 @@ private static Stream<Arguments> exceptionMessageTestCases() {
122
122
);
123
123
}
124
124
125
+ @ ParameterizedTest
126
+ @ MethodSource ("messageNullabilityTestCases" )
127
+ void getMessage_respectsNullBehavior (String testDescription ,
128
+ AwsServiceException .Builder builder ,
129
+ String expectedMessage ) {
130
+ AwsServiceException e = builder .build ();
131
+ assertThat (e .getMessage ())
132
+ .as (testDescription )
133
+ .isEqualTo (expectedMessage );
134
+ }
135
+
136
+ private static Stream <Arguments > messageNullabilityTestCases () {
137
+ return Stream .of (
138
+ Arguments .of (
139
+ "No message or details set" ,
140
+ AwsServiceException .builder (),
141
+ null
142
+ ),
143
+ Arguments .of (
144
+ "Explicitly null message without details" ,
145
+ AwsServiceException .builder ().message (null ),
146
+ null
147
+ )
148
+ );
149
+ }
150
+
125
151
@ Test
126
152
public void exceptionMessage_withoutErrorMessage () {
127
153
AwsServiceException e = AwsServiceException .builder ()
You can’t perform that action at this time.
0 commit comments