failsafe-lib / failsafe

Fault tolerance and resilience patterns for the JVM
https://failsafe.dev
Apache License 2.0
4.2k stars 297 forks source link

Add toString() to all classes #335

Open numeralnathan opened 2 years ago

numeralnathan commented 2 years ago

Please implement toString() in all classes. This will help when debugging since the programmer can see what the state of the object is.

jhalterman commented 2 years ago

Did you have classes in particular packages in mind, or all of them?

numeralnathan commented 2 years ago

All of them.

I was stepping through code that was calling RetryPolicyBuilder. It would be nice to see the state in the debugger to make sure I got the code right. I know I can expand the object and see it's fields, but this interrupts my flow.

Note: RetryPolicyImpl does not have any state except RetryPolicyConfig. So, this would be the implementation of RetryPolicyImpl.toString().

@Override
public String toString() {
   return config.toString();
}

However, RetryPolicyConfig has a lot of state. So, perhaps toString() only returns the values that are set. For example, if jitter is not set, then toString() won't show it.

magicprinc commented 2 years ago

The easiest solution to make it done in five minutes :-)

https://projectlombok.org/features/ToString