The iteration through the inventory of a player will contain the offhand item, but you cannot remove it from the inventory.
Below is some code fragment to show the problem for a simple item smelter.
// Code-Platzhalter for (ItemStack itemStack : player.getInventory()) { player.getInventory().addItem(this.smelt(itemStack)) player.getInventory().remove(itemStack); }
In this case holding e.g. an iron ore in the offhand will supply an infinite supply of iron ingots as the offhand is contained in the Inventory iterator, but the removal will not remove the itemstack. This also throws no error causing me to think that this is not intentional behaviour.
Potential fixes:
Either remove the Offhand from the Inventory Iterator or allow removal of item stacks from the offhand.
Minimal reproduction plugin included, will clear the inventory on join, with the method mentioned above, thus causing the offhand not to be cleared.
As this bug can lead to infinite resource bugs with item smelters, etc. and requires additional code that is not really expected, I consider this bug as major.