Alexey Kukushkin created IGNITE-16889:
-----------------------------------------

             Summary: Error-prone X#searchForCause() implementation
                 Key: IGNITE-16889
                 URL: https://issues.apache.org/jira/browse/IGNITE-16889
             Project: Ignite
          Issue Type: Bug
          Components: general
    Affects Versions: 2.12
            Reporter: Alexey Kukushkin


The {{X#seachForCause}} utility method fails with a {{NullPointerException}} if 
the analyzed {{Throwable}} has no {{suppressed}} exception due to the [missing 
null 
check|https://github.com/apache/ignite/blob/2.12.0/modules/core/src/main/java/org/apache/ignite/internal/util/typedef/X.java#L570].

I never encountered any issues with that with real usage of Ignite. However, 
writing a unit test that stabs the {{IgniteCache}} methods to throw an 
exception without initialized {{suppressed}} exceptions results in the stabbed 
method to return {{null}} instead of throwing an exception. The workaround is 
to properly initialize the {{suppressed}} list in the mocked exception.

I suggest to make the generic {{X#seachForCause}} utility method handle the 
case when the {{suppressed}} list is not initialized. That would simplify the 
unit tests code.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to