David recognized the dangers of being too prideful and trusted that God would make good come out of his abuse. We too are called to bear our crosses with humility and be examples to others of not letting anger or vengeance steal our joy.
Source: Time of Grace – Transformed! From Pride to Humility