It is definitely unusual, but I don't think it would actually be cruel unless the dude lives long enough that it actually is carried out. If the sentence isn't carried out, is simply being given it cruel? 🤔
The judge is compelled by the law to have that as part of the sentence, but the stipulations of that same law have provided a loophole whereby the judge condemns the person to a lengthy prison sentence that would give a greater chance of having the castration part never happen. If that was the judge's intent all along, it's kind of brilliant malicious compliance.
The law itself that makes that a legit sentence is pretty fucked up, though.