-
Notifications
You must be signed in to change notification settings - Fork 0
Feature implementation from commits 2e686b2..dae93ad #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature-base-1
Are you sure you want to change the base?
Conversation
…ar#3254) Bumps [com.diffplug.spotless:spotless-maven-plugin](https://github.com/diffplug/spotless) from 2.44.3 to 2.44.4. - [Release notes](https://github.com/diffplug/spotless/releases) - [Changelog](https://github.com/diffplug/spotless/blob/main/CHANGES.md) - [Commits](diffplug/spotless@maven/2.44.3...maven/2.44.4) --- updated-dependencies: - dependency-name: com.diffplug.spotless:spotless-maven-plugin dependency-version: 2.44.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* feat: Implement Actor Model pattern iluwatar#3232 * feat: Implement Actor Model pattern iluwatar#3232 * feat: update Actor Model implementation with multi-actor logic iluwatar#3251 * feat: update Actor Model implementation with multi-actor logic and loose coupling iluwatar#3251 * test: add unit test for actor model iluwatar#3251 * test: add test for App.java to increase coverage * docs: add complete README for Actor Model pattern also implemented changes iluwatar#3251
* docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] --------- Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
* docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] --------- Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Bumps [org.springframework:spring-web](https://github.com/spring-projects/spring-framework) from 7.0.0-M3 to 7.0.0-M4. - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](spring-projects/spring-framework@v7.0.0-M3...v7.0.0-M4) --- updated-dependencies: - dependency-name: org.springframework:spring-web dependency-version: 7.0.0-M4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…luwatar#3261) Bumps [org.sonarsource.scanner.maven:sonar-maven-plugin](https://github.com/SonarSource/sonar-scanner-maven) from 5.0.0.4389 to 5.1.0.4751. - [Release notes](https://github.com/SonarSource/sonar-scanner-maven/releases) - [Commits](SonarSource/sonar-scanner-maven@5.0.0.4389...5.1.0.4751) --- updated-dependencies: - dependency-name: org.sonarsource.scanner.maven:sonar-maven-plugin dependency-version: 5.1.0.4751 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Persian Translation: Add persian translation to abstract-document * Persian Translation: Add abstract-document.png to abstract-document folder * Persian Translation: Add codes to README.md of abstract-document * Persian Translation: some improvements in abstract-document * Persian Translation: Add refrence links in abstract-document * Persian Translation: add rtl tag in abstract-document * active-object : translate * active-object: improve when to use * active-object: improve when to use * active-object: improve bullets (test) * active-object: improve bullets (test) * active-object: improve bullets (test) * active-object: improve bullets (test) * active-object: improve bullets * active-object: Fix all bullets * -added persian translation of factory pattern * -renamed file * -changed wikipedia definition * -fixed table problem * -fixed problems in bullet alignments * Update README.md -fixed alignment in bullets * Update README.md -changed tags to English --------- Co-authored-by: Seyyed Keivan Shirkoubian <[email protected]>
| import java.util.concurrent.atomic.AtomicInteger; | ||
|
|
||
| public class ActorSystem { | ||
| private final ExecutorService executor = Executors.newCachedThreadPool(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚡ Performance Issue
Unbounded thread pool can cause resource exhaustion.
Using an unbounded cached thread pool can lead to resource exhaustion under high load as new threads are continuously created without limits.
Current Code (Diff):
- private final ExecutorService executor = Executors.newCachedThreadPool();
+ private final ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);📝 Committable suggestion
‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀
| private final ExecutorService executor = Executors.newCachedThreadPool(); | |
| private final ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); |
| String actorId = "actor-" + idCounter.incrementAndGet(); // Generate a new and unique ID | ||
| actor.setActorId(actorId); // assign the actor it's ID | ||
| actorRegister.put(actorId, actor); // Register and save the actor with it's ID | ||
| executor.submit(actor); // Run the actor in a thread |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 Correctness Issue
No exception handling for actor execution.
If an actor throws an uncaught exception, it will silently terminate without any notification, potentially causing system instability.
Current Code (Diff):
- executor.submit(actor); // Run the actor in a thread
+ executor.submit(() -> {
+ try {
+ actor.run();
+ } catch (Exception e) {
+ // Log the exception or implement a supervision strategy
+ System.err.println("Actor " + actor.getActorId() + " failed with exception: " + e.getMessage());
+ }
+ }); // Run the actor in a thread with exception handling📝 Committable suggestion
‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀
| executor.submit(actor); // Run the actor in a thread | |
| executor.submit(() -> { | |
| try { | |
| actor.run(); | |
| } catch (Exception e) { | |
| // Log the exception or implement a supervision strategy | |
| System.err.println("Actor " + actor.getActorId() + " failed with exception: " + e.getMessage()); | |
| } | |
| }); |
| } | ||
|
|
||
| public void shutdown() { | ||
| executor.shutdownNow(); // Stop all threads |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 Correctness Issue
Abrupt thread termination can cause resource leaks.
Using shutdownNow() immediately terminates all threads without allowing them to complete their work, potentially causing resource leaks or data corruption.
Current Code (Diff):
- executor.shutdownNow(); // Stop all threads
+ executor.shutdown();
+ try {
+ if (!executor.awaitTermination(30, TimeUnit.SECONDS)) {
+ executor.shutdownNow();
+ }
+ } catch (InterruptedException e) {
+ executor.shutdownNow();
+ Thread.currentThread().interrupt();
+ } // Graceful shutdown with timeout📝 Committable suggestion
‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀
| executor.shutdownNow(); // Stop all threads | |
| executor.shutdown(); | |
| try { | |
| if (!executor.awaitTermination(30, TimeUnit.SECONDS)) { | |
| executor.shutdownNow(); | |
| } | |
| } catch (InterruptedException e) { | |
| executor.shutdownNow(); | |
| Thread.currentThread().interrupt(); | |
| } |
🔄 Dependencies Affected
src/main/java/com/iluwatar/actormodel/ActorSystem.java
Function: ActorSystem
Issue: Missing import for TimeUnit
Suggestion: Add import java.util.concurrent.TimeUnit;
Current Code (Diff):
+ import java.util.concurrent.TimeUnit;| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| * THE SOFTWARE. | ||
| */ | ||
| package com.iluwatar.table.inheritance; /* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 Correctness Issue
Malformed package declaration.
The package declaration is incorrectly followed by a multi-line comment which will cause compilation errors.
Current Code (Diff):
- package com.iluwatar.table.inheritance; /*
+ package com.iluwatar.table.inheritance;
+ /*📝 Committable suggestion
‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀
| package com.iluwatar.table.inheritance; /* | |
| package com.iluwatar.table.inheritance; |
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| * THE SOFTWARE. | ||
| */ | ||
| package com.iluwatar.table.inheritance; /* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 Correctness Issue
Malformed package declaration with embedded comment.
The package declaration has an embedded multi-line comment which will cause compilation failure as Java requires package declarations to be standalone statements.
Current Code (Diff):
- package com.iluwatar.table.inheritance; /*
+ package com.iluwatar.table.inheritance;📝 Committable suggestion
‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀
| package com.iluwatar.table.inheritance; /* | |
| package com.iluwatar.table.inheritance; |
PR Summary
Code Modernization and Introduction of Actor Model Implementation
Overview
This PR introduces a new Actor Model implementation through the ActorSystem class while modernizing existing code through various refactoring techniques including Java language feature updates, test improvements, and code style enhancements.
Change Types
Affected Modules
src/main/java/com/iluwatar/actormodel/ActorSystem.javasrc/main/java/com/iluwatar/servicestub/RealSentimentAnalysisServer.javasrc/test/java/com/iluwatar/monolithic/MonolithicAppTest.javasrc/test/java/com/iluwatar/publish/subscribe/LoggerExtension.javasrc/test/java/com/iluwatar/publish/subscribe/model/MessageTest.javasrc/test/java/com/iluwatar/sessionfacade/AppTest.javasrc/test/java/com/iluwatar/sessionfacade/PaymentServiceTest.javasrc/test/java/com/iluwatar/table/inheritance/AppTest.javasrc/test/java/com/iluwatar/table/inheritance/VehicleDatabaseTest.java