DERBY-6137: Port 1466481 and 1466522 from trunk to 10.9 branch.

git-svn-id: https://svn.apache.org/repos/asf/db/derby/code/branches/10.9@1466630 13f79535-47bb-0310-9956-ffa450edef68