[8.x] Backport WFLY-3682 fix to 8.x

Backport of https://github.com/wildfly/wildfly/pull/6541 to 8.x.

https://issues.jboss.org/browse/WFLY-3682