@@ -178,4 +178,46 @@ public void testNullElement() {
178
178
composite .getCause ();
179
179
composite .printStackTrace ();
180
180
}
181
+
182
+ @ Test (timeout = 1000 )
183
+ public void testCompositeExceptionWithUnsupportedInitCause () {
184
+ Throwable t = new Throwable () {
185
+ @ Override
186
+ public synchronized Throwable initCause (Throwable cause ) {
187
+ throw new UnsupportedOperationException ();
188
+ }
189
+ };
190
+ CompositeException cex = new CompositeException (Arrays .asList (t , ex1 ));
191
+
192
+ System .err .println ("----------------------------- print composite stacktrace" );
193
+ cex .printStackTrace ();
194
+ assertEquals (2 , cex .getExceptions ().size ());
195
+
196
+ assertNoCircularReferences (cex );
197
+ assertNotNull (getRootCause (cex ));
198
+
199
+ System .err .println ("----------------------------- print cause stacktrace" );
200
+ cex .getCause ().printStackTrace ();
201
+ }
202
+
203
+ @ Test (timeout = 1000 )
204
+ public void testCompositeExceptionWithNullInitCause () {
205
+ Throwable t = new Throwable ("ThrowableWithNullInitCause" ) {
206
+ @ Override
207
+ public synchronized Throwable initCause (Throwable cause ) {
208
+ return null ;
209
+ }
210
+ };
211
+ CompositeException cex = new CompositeException (Arrays .asList (t , ex1 ));
212
+
213
+ System .err .println ("----------------------------- print composite stacktrace" );
214
+ cex .printStackTrace ();
215
+ assertEquals (2 , cex .getExceptions ().size ());
216
+
217
+ assertNoCircularReferences (cex );
218
+ assertNotNull (getRootCause (cex ));
219
+
220
+ System .err .println ("----------------------------- print cause stacktrace" );
221
+ cex .getCause ().printStackTrace ();
222
+ }
181
223
}
0 commit comments