Skip to content

Conversation

Nadahar
Copy link
Contributor

@Nadahar Nadahar commented Oct 14, 2025

While looking for other problems, I studied some of these classes and did some minor adjustments along the way. I actually don't remember what my goal was when I did it, but it was abandoned. I'm left with these minor fixes that I either have to throw away or submit. So, I'm submitting them, since I've made them anyway.

There is no goal here, this is just minor issues that appeared "problematic" and in need of some attention. Since there is no goal, and the changes are so few, I'll describe the details.

ScriptFileReference

  • Logging in compareTo(), equals() or hashCode() is bad. These methods will be called a lot, "behind the scenes", from various Collections or other components. They must perform. The logging also seems more like some debugging that has been left behind. Thus, logging in compareTo() has been removed.
  • Once the logging was removed, the Logger wasn't in use, and was removed.
  • equals() didn't have parity with hashCode(). equals() only considered one field, while hashCode() considered three. I modified equals() to match hashCode().

AbstractScriptFileWatcher

  • scheduler wasn't final, but could be (making the field thread-safe, since ScheduledExecutorService implementations must be thread-safe).
  • Address a couple of computeIfAbsent()s that gave null warnings.
  • Removed synchronized from getLockForScript() because it served no purpose (scriptLockMap is a ConcurrentHashMap).
  • onReadyMarkerAdded(): Slight redesign to improve performance and consistency. currentStartLevel is volatile and can change at any time, so one can't assume that the value will remain the same during execution of the method. Also, it has some "penalties" associated with it as a volatile field (memory barrier, CPU cache flush), so using it like it were a local variable isn't ideal. I changed the method to use a local variable internally, and only access currentStartLevel the two times that were required: once to read and once to write.

@Nadahar Nadahar requested a review from a team as a code owner October 14, 2025 03:35
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
@Nadahar Nadahar force-pushed the rulesupport-tweaks branch from 83bbb7c to a8f6a24 Compare October 14, 2025 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant