Contour Integral of $\frac{z^2+1}{z(z+2)}$

complex integrationcomplex-analysiscontour-integration

I've calculated the following contour integral with two different methods, which lead to different results, and I can't for the life of me figure out in which one I messed up. If anyone happens to know which one fails and why, I'd be very grateful:
$$
\int_{\gamma}\frac{z^2+1}{z(z+2)}dz, \quad \text{where} \quad \gamma:[0,2\pi]\to\mathbb{C}, t \mapsto 2i+e^{it}
$$

Since the integrand is holomorphic in $\mathbb{C}\setminus\{0,-2\}$, thus also in the closed unit ball around $2i$, which happens to also be simply connected, shouldn't the integral be equal to $0$, since $\gamma$ is a closed path contained in said simply connected space?

However, when calulating with Cauchy-Integral-Formula, I get $\pi i$ as result. I have a hunch that the result via Cauchy-Integral-Formula is false, however, as I said, I can't figure out why.

Any help is appreciated and thanks in advance!

Edit for clarification on how I tried to calculate via Cauchy-Integral-Formula, which is very wrong as many pointed out:

Define $f(x):=\frac{x^2+1}{x+2}$, which is holomorphic in $U_{3}(2i)$. Since both $0$ and $\gamma$ are contained in $U_{5/2}(2i)$, we can use Cauchy-Integral-Formula to calculate:
$$
f(0)=\frac{1}{2}=\frac{1}{2\pi i}\int_{\gamma}\frac{f(z)}{z-0}dz=\frac{1}{2\pi i} \int_{\gamma}\frac{z^2+1}{z(z+2)}dz \\ \Leftrightarrow \int_{\gamma}\frac{z^2+1}{z(z+2)}dz = \pi i
$$

The big mistake here is that I simply forgot that in my case $0$ needs to be contained in the contour, and that I can't just choose the radius of my ball freely.
Thanks for the help, guys! Much appreciated!

Best Answer

Yes, the answer is $0$. I suppose that what you did was to define $f(z)=\frac{z^2+1}{z+2}$ and then to do\begin{align}\int_\gamma\frac{z^2+1}{z(z+2)}\,\mathrm dz&=\int_\gamma\frac{f(z)}z\,\mathrm dz\\&=2\pi if(0)\\&=\pi i.\end{align}That is wrong, since the loop $\gamma$ does not go around $0$.

Related Question