Fix integer to long classcast exceptions.

Change-Id: Ie9a11587ec1b3f1b97ee5d48a354955c5cbc7b41
Reviewed-on: http://review.couchbase.org/40525
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>