ASSIGNMENT 1 - ABDUL HANIF BIN ABDUL AZIZ U2101905#5
Open
Conversation
suhadaudd11
approved these changes
Jan 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. Addressed Issue
There is some issue that I have found during my exploration through the OpenHab bundles such as:
CPU and Disk I/O exhaustion caused by processing redundant events. (Resource Management Issues)
Unsafe access to shared memory resources (HashSet) which caused runtime crashes. (Resource Management Issues)
UI thread blocking caused by coarse-grained synchronization locks. (Synchronous, Blocking I/O)
Thread starvation caused by synchronous processing of high-frequency network packets. (Synchronous, Blocking I/O)
Sequential processing bottlenecks during "bursty" network traffic. (Synchronous, Blocking I/O)
Redundant thread locking (synchronized keyword) during slow hardware scanning. (Synchronous, Blocking I/O)
2. What I Have Reengineered
Implemented a Throttling Mechanism using a timestamp cache to drop duplicate events within a 2-second window.
Replaced blocking ArrayList with CopyOnWriteArrayList and removed synchronized blocks to allow non-blocking reads.
Implemented Asynchronous Batch Processing by decoupling event reception into a BlockingQueue.
Replaced non-thread-safe collections with ConcurrentHashMap.newKeySet() to ensure safe concurrent access.
Converted the remoteDeviceAdded callback to an Asynchronous Queue-based handler, moving logic to a background thread.
Removed the synchronized modifier from listener methods, relying on existing thread-safe collections.
3. Reengineering Strategy or Approach Used
For the approaches that I use, I have use rework strategy to overcome addressed issue and improvise the system performance. Strategy that I have use are:
Alteration. Altered the internal control flow to include conditional logic (throttling).
Concurrency Refactoring. Shifted the concurrency model from "Blocking" to "Non-Blocking".
Buffering. Introduced an intermediate buffer to manage data flow efficiency.
Thread Safety. Altered data structure implementation to support atomic operations.
Asynchronous Processing. Changed execution flow from synchronous to deferred/background execution.
Non-Blocking Concurrency. Removed redundant locking mechanisms to improve execution flow.
4. Impact of Changes
Reduced Resource Exhaustion. Prevented "Event Storms" from triggering excessive CPU processing and disk writes.
Improved UI Responsiveness. Allowed the Add-on Store to load instantly even while finders are updating in the background.
Prevented Thread Starvation. Ensured network bursts (device startups) are processed efficiently in chunks.
System Stability. Eliminated ConcurrentModificationException crashes during simultaneous read/write operations.
Decoupled Latency. Prevented network delays from freezing the main application logic.
Prevented Deadlocks. Ensured the OSGi service registry does not lock up during slow USB hardware scans.