Getting Java exceptions in REST API calls

When trying to update a Confluence content property, we sometimes get:

com.atlassian.confluence.core.persistence.confluence.StaleObjectStateException: javax.persistence.OptimisticLockException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) : [com.atlassian.confluence.content.CustomContentEntityObject#XXXXXXXXX]

How can learn more about this? Or know why this happens?