Z pass has inf values in mix of glossy and transparent

I have stumbled on a problem that seems like a but, but I haven’t found a solution so I’d appreciate any help.

I have a very simple shader that mixes Glossy and Transparent shaders for thin glass. When looking through this object (one-sided object, no depth), I get a “noise” in Z values with different pixels having either the value of object behind the glass or infinity, which makes the pass unusable for Z defocus in comp. Given the nature of sampling I’d at worst expect noise between glass depth and object behind the glass, but definitely not inf values where the path of ray intersects other geometry.

Any ideas (besides doing a separate render with some other material) how to solve this issue?

Example of issues in z channel (it is the front windscreen of a truck):

Check the alpha threshold in render layer properties.

Thanks, this did the trick! But still, I wonder why it produces inf values when each ray intersects either the glass or object behind it…