The energy is reflected from the cavity.

In general, an optical cavity acts as a variable transmissivity mirror for a light source with very narrow linewidth (a laser).  As you change the length, the cavity can go between highly transmissive and highly reflective.  The specifics of how tranmissive and how reflective it can be depend on the reflectivity of the mirrors which make up the cavity.

In the particular case of a two mirror cavity with equal reflectivity mirrors, the transmissivity is shown below for two different values of finesse.  Finesse is a measure of how narrow the transmission line of the cavity is (as can be seen below).  For the case of a two mirror cavity with equal reflectivity mirrors, it is given simply by
$$F=\frac{4R}{(1-R)^2}=\frac{\delta\lambda}{\Delta\lambda},$$
where $\delta\lambda$ is the FWHM of the transmission peak and $\Delta\lambda$ is the free spectral range (as shown below).  Since laser line mirrors can have reflectivities as high as 0.999995, it is possible to have cavities with a Finesse in the range of 100,000.

$\hspace{120px}$[![enter image description here][1]][2]

[1]: http://i.stack.imgur.com/aIY3Z.png
[2]: http://en.wikipedia.org/wiki/File:Etalon-2.png