4. As shown in Figure 1, in Rt $\triangle A B C$, $\angle A C B=90^{\circ}$, $C D$ is the angle bisector, $D E \perp$ $A C$ at point $E, D F \perp B C$ at point $F$. If $A E=6, B F=3$, then $C D=(\quad)$.
(A) 6
(B) $3 \sqrt{2}$
(C) $\frac{9}{2}$
(D) $2 \sqrt{5}$
4. A.
$$
\begin{array}{l}
\text { It is easy to know that } C D=\sqrt{2} D E=\sqrt{2} D F . \\
\text { By } \triangle A E D \backsim \triangle D F B \\
\Rightarrow \frac{A E}{D F}=\frac{D E}{B F} \\
\Rightarrow C D^{2}=2 D E \cdot D F=2 A E \cdot B F=36 \\
\Rightarrow C D=6 .
\end{array}
$$