hekailiang / squirrel

squirrel-foundation is a State Machine library, which provided a lightweight, easy use, type safe and programmable state machine implementation for Java.
http://hekailiang.github.io/squirrel/
Other
2.19k stars 540 forks source link

Logging an error causes a NullPointerException #67

Open jorgelamb opened 7 years ago

jorgelamb commented 7 years ago

Hi,

We are having some issue in our project using squirrel framework. For some unknown reason we are still trying to find and after working fine for several hours the mvel condition fails, but then in the catch block it tries to log the exceptions .getCause().getMessage() and that causes a NullPointerException.

Some exceptions might have the getCause() as null, so it would be safer to check for null before logging it.

The affected line:

logger.error("Evaluate \""+mvelExpression+"\" failed, which caused by "+e.getCause().getMessage());

Thanks

hekailiang commented 7 years ago

accepted, thx!