I want to add debug message in Java code. I would like to change assert with modern approach
public void registerForRead(SSLChannel l) {
debug("Error");
boolean wasNotPresent = readListeners.add(l);
assert wasNotPresent : "Already registered";
}
If I change the code this way would I preserve the logic?
public void registerForRead(SSLChannel l) {
debug("Error");
boolean wasNotPresent = readListeners.add(l);
if (wasNotPresent) {
debug("Already registered");
}
}