Blogbody Rotating Header Image

Dumb comment of the day

From java.util.logging.LogRecord:

public LogRecord(Level level, String msg) {
// Make sure level isn't null, by calling random method.
level.getClass();
this.level = level;
message = msg;
// Assign a thread ID and a unique sequence number.
synchronized (LogRecord.class) {
sequenceNumber = globalSequenceNumber++;
Integer id = (Integer)threadIds.get();
if (id == null) {
id = new Integer(nextThreadId++);
threadIds.set(id);
}
threadID = id.intValue();
}
millis = System.currentTimeMillis();
needToInferCaller = true;
}

Make sure level isn’t null, by calling random method?! Why not use an assert? Or, if the concern is that asserts might be disabled, be explicit about the null check? Very odd.

0 Comments on “Dumb comment of the day”

Leave a Comment