-
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Pull Request: SonarQube Security & Code Quality Fixes #3466
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
Open
Sagar-S-R
wants to merge
103
commits into
iluwatar:test-branch
Choose a base branch
from
Sagar-S-R:master
base: test-branch
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
103 commits
Select commit
Hold shift + click to select a range
f01235b
docs: add notification diagram
iseppala 7ed9e39
docs: null object diagram
iseppala 6bae409
docs: object mother diagrams
iseppala 2aaf712
docs: object pool and observer diagrams
iseppala 32dbc7f
docs: optimistic offline lock diagram
iseppala ecfd944
docs: page object and parameter object diagrams
iseppala fdd07c7
docs: partial response and pipeline diagrams
iseppala 261da00
docs: poison pill and private class data diagrams
iseppala 3abaa83
docs: producer-consumer and promise diagrams
iseppala 23af67c
docs: property, prototype, proxy diagrams
iseppala ae737f6
docs: queue-based load leveling diagram
iseppala 6d6638f
docs: reactor diagram
iseppala 09e5313
docs: registry diagram
iseppala 9e5d9e5
docs: repository diagram
iseppala 21fed21
docs: raii diagram
iseppala 44f6ab3
docs: retry and role object diagrams
iseppala 6cadf25
fix: handle awaitTermination result and ensure proper ExecutorService…
2897robo 54048a1
docs: add saga flowchart
iseppala a97bfec
docs: separated interface diagram
iseppala 30d6875
docs: diagrams for serialized entity and serialized lob
iseppala b8f3869
docs: diagrams for servant and server session
iseppala 73a5828
docs: service locator and service stub diagrams
iseppala e5485da
docs: service to worker, session facade, sharding diagrams
iseppala 8e82390
docs: single table inheritance and singleton diagrams
iseppala cd224ea
docs: add diagrams for spatial partition, special case, specification…
iseppala 0b83b6d
feat: Adding backpressure design pattern #3233 (#3249)
sanurah ba7be25
docs: diagrams for table module and template method
iseppala 95bfd6c
docs: new diagrams for template view and throttling
iseppala 21914f9
docs: updated diagrams for tolerant reader and trampoline
iseppala 6195d5e
docs: diagrams for transaction script, twin, and type object
iseppala 81ecb56
docs: diagrams for unit of work, update method, and value object
iseppala 32c9031
docs: diagrams for version number, virtual proxy, visitor
iseppala ce2e5f7
docs: update backpressure description
iseppala 8ca487e
docs: update function composition pattern
iseppala 4b06dc2
docs: updates for MapReduce
iseppala 5241a4a
docs: update client-side ui composition
iseppala 4afabdb
docs: update bloc pattern
iseppala 9de12ea
docs: update clean architecture
iseppala acb40e1
docs: update microservices distributed tracing
iseppala 076fc21
docs: update microservices idempotent consumer
iseppala d95c679
docs: update money pattern
iseppala b8aa775
fix: fix code formatting
iseppala b95bf24
build(deps): bump org.jacoco:jacoco-maven-plugin from 0.8.12 to 0.8.1…
dependabot[bot] 2e686b2
build(deps): bump io.micrometer:micrometer-tracing-bridge-brave (#3253)
dependabot[bot] 0f37b4e
build(deps): bump com.diffplug.spotless:spotless-maven-plugin (#3254)
dependabot[bot] 1a08b73
docs: update monolithic architecture
iseppala 9f7ce4e
docs: update publish-subscribe
iseppala bc42e38
docs: update service stub
iseppala 67bc5e3
docs: update session facade
iseppala cb3853a
docs: update table inheritance
iseppala d80eca1
docs: update book link
iseppala 1cde704
docs: remove some old diagrams
iseppala fe522fd
feat: Implement Actor Model pattern
ssrijan-007-sys e359f1b
docs: add ssrijan-007-sys as a contributor for code (#3263)
allcontributors[bot] 55bef7c
chore: removed duplicated dependency (#3258)
e5LA e4681e4
docs: add e5LA as a contributor for code (#3264)
allcontributors[bot] 6e20d32
build(deps): bump org.springframework:spring-web (#3262)
dependabot[bot] ad6bdf8
build(deps): bump org.sonarsource.scanner.maven:sonar-maven-plugin (#…
dependabot[bot] dae93ad
translation: Translate selected patterns to persian (#3256)
maziyar-gerami f8f33f5
docs: add maziyar-gerami as a contributor for translation (#3265)
allcontributors[bot] 8a64f4c
docs: update dependency injection
iseppala 7d2e626
build(deps): bump com.mycila:license-maven-plugin from 4.6 to 5.0.0 (…
dependabot[bot] a62601a
build(deps): bump com.fasterxml.jackson.core:jackson-core (#3270)
dependabot[bot] 0da4dcd
docs: update producer-consumer
iseppala 3ac1a36
docs: update prototype
iseppala 8529017
feat: Implement Thread-Pool Executor pattern (#3271)
yybmion bf16400
docs: add yybmion as a contributor for code (#3279)
allcontributors[bot] f6bb515
chore: adding missing license (#3273)
e5LA ede37bd
docs: add e5LA as a contributor for doc (#3281)
allcontributors[bot] 98d3601
docs: Formatted spacing and updated documentation (#3290)
ronodhirSoumik 0ab6019
docs: add ronodhirSoumik as a contributor for doc (#3418)
allcontributors[bot] 08651d0
chore: Update presubmit.ai configuration
iseppala 3ba2560
build(deps-dev): bump org.htmlunit:htmlunit from 4.7.0 to 4.17.0 (#3334)
dependabot[bot] 812e4cd
feat: Microservices pattern : Self-Registration (#3245)
naman-sriv fecf7e7
build(deps-dev): bump io.projectreactor:reactor-test (#3377)
dependabot[bot] f92e682
feat: Implement DAO Factory pattern (#3282)
letdtcode 4caa0bf
docs: Persian translation: Abstract Factory (#3280)
maziyar-gerami 7c12643
docs: add naman-sriv as a contributor for code (#3428)
allcontributors[bot] dc3425d
docs: add letdtcode as a contributor for code (#3429)
allcontributors[bot] a3fcc63
feat: Implement View Helper pattern (#3278)
e5LA 265e3d0
feat: Rate Limiting Pattern #2973 (#3291)
skamble2 ce5154e
docs: add skamble2 as a contributor for code (#3437)
allcontributors[bot] b8f8199
docs: Update README.md (#3298)
Olexandr88 2d39fe7
docs: add Olexandr88 as a contributor for doc (#3440)
allcontributors[bot] 80e928a
Fixed security hotspots and bugs
Sagar-S-R ad42f7b
Fix : Security issues
Sagar-S-R ba6af84
Update special-case/README.md
Sagar-S-R 45aa296
Update microservices-self-registration/greetingservice/src/main/java/…
Sagar-S-R 6d0e071
Update backpressure/src/test/java/com/iluwatar/backpressure/Publisher…
Sagar-S-R d00936c
Update dao-factory/src/main/java/com/iluwatar/daofactory/DAOFactoryPr…
Sagar-S-R 3f7bfff
Update function-composition/src/main/java/com/iluwatar/function/compo…
Sagar-S-R 6b20179
Update money/README.md
Sagar-S-R 49f248c
Update leader-followers/src/main/java/com/iluwatar/leaderfollowers/Ap…
Sagar-S-R ffe8b96
Update dao-factory/src/main/java/com/iluwatar/daofactory/MongoDataSou…
Sagar-S-R ee1689c
Update .github/workflows/presubmit.yml
Sagar-S-R 18b076e
Update dao-factory/src/main/java/com/iluwatar/daofactory/FlatFileData…
Sagar-S-R 29f11b5
Update caching/src/main/java/com/iluwatar/caching/database/MongoDb.java
Sagar-S-R ec1a6fb
Update backpressure/src/main/java/com/iluwatar/backpressure/App.java
Sagar-S-R 576ecd1
Update rate-limiting-pattern/src/test/java/com/iluwatar/rate/limiting…
Sagar-S-R 5ba7f71
Update rate-limiting-pattern/pom.xml
Sagar-S-R 363a64a
Update backpressure/src/main/java/com/iluwatar/backpressure/App.java
Sagar-S-R 3b197dd
Update backpressure/src/test/java/com/iluwatar/backpressure/Subscribe…
Sagar-S-R 44a1e48
Merge branch 'test-branch' into master
Sagar-S-R File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,35 +1,28 @@ | ||
| name: Presubmit.ai | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| issues: write | ||
| contents: read | ||
| pull-requests: write | ||
| issues: write | ||
|
|
||
| on: | ||
| pull_request_target: # Handle forked repository PRs in the base repository context | ||
| types: [opened, synchronize] | ||
| pull_request_review_comment: # Handle review comments | ||
| types: [created] | ||
| pull_request_target: | ||
| types: [opened, synchronize] | ||
| pull_request_review_comment: | ||
| types: [created] | ||
|
Sagar-S-R marked this conversation as resolved.
|
||
|
|
||
| jobs: | ||
| review: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check required secrets | ||
| run: | | ||
| if [ -z "${{ secrets.LLM_API_KEY }}" ]; then | ||
| echo "Error: LLM_API_KEY secret is not configured" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Check out PR code | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha }} | ||
|
|
||
| - name: Run AI Reviewer | ||
| uses: presubmit/ai-reviewer@latest | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| LLM_API_KEY: ${{ secrets.LLM_API_KEY }} | ||
| LLM_MODEL: "gemini-1.5-flash" | ||
| review: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check required secrets | ||
| run: | | ||
| if [ -z "${{ secrets.LLM_API_KEY }}" ]; then | ||
| echo "Error: LLM_API_KEY secret is not configured" | ||
| exit 1 | ||
| fi | ||
| - uses: presubmit/ai-reviewer@<FULL_40_CHARACTER_COMMIT_SHA> | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| LLM_API_KEY: ${{ secrets.LLM_API_KEY }} | ||
| LLM_MODEL: "gpt-5-nano" | ||
|
Sagar-S-R marked this conversation as resolved.
Sagar-S-R marked this conversation as resolved.
Sagar-S-R marked this conversation as resolved.
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,201 @@ | ||
| --- | ||
| title: "Actor Model Pattern in Java: Building Concurrent Systems with Elegance" | ||
| shortTitle: Actor Model | ||
| description: "Explore the Actor Model pattern in Java with real-world examples and practical implementation. Learn how to build scalable, message-driven systems using actors, messages, and asynchronous communication." | ||
| category: Concurrency | ||
| language: en | ||
| tag: | ||
| - Concurrency | ||
| - Messaging | ||
| - Isolation | ||
| - Asynchronous | ||
| - Distributed Systems | ||
| - Actor Model | ||
| --- | ||
|
|
||
| ## Also Known As | ||
|
|
||
| - Message-passing concurrency | ||
| - Actor-based concurrency | ||
|
|
||
| --- | ||
|
|
||
| ## Intent of Actor Model Pattern | ||
|
|
||
| The Actor Model pattern enables the construction of highly concurrent, distributed, and fault-tolerant systems by using isolated components (actors) that interact exclusively through asynchronous message passing. | ||
|
|
||
| --- | ||
|
|
||
| ## Detailed Explanation of Actor Model Pattern with Real-World Examples | ||
|
|
||
| ### 📦 Real-world Example | ||
|
|
||
| Imagine a customer service system: | ||
| - Each **customer support agent** is an **actor**. | ||
| - Customers **send questions (messages)** to agents. | ||
| - Each agent handles one request at a time and can **respond asynchronously** without interfering with other agents. | ||
|
|
||
| --- | ||
|
|
||
| ### 🧠 In Plain Words | ||
|
|
||
| > "Actors are like independent workers that never share memory and only communicate through messages." | ||
|
|
||
| --- | ||
|
|
||
| ### 📖 Wikipedia Says | ||
|
|
||
| > [Actor model](https://en.wikipedia.org/wiki/Actor_model) is a mathematical model of concurrent computation that treats "actors" as the universal primitives of concurrent computation. | ||
|
|
||
| --- | ||
|
|
||
| ### 🧹 Architecture Diagram | ||
|
|
||
|  | ||
|
|
||
| --- | ||
|
|
||
| ## Programmatic Example of Actor Model Pattern in Java | ||
|
|
||
| ### Actor.java | ||
|
|
||
| ```java | ||
| public abstract class Actor implements Runnable { | ||
|
|
||
| @Setter @Getter private String actorId; | ||
| private final BlockingQueue<Message> mailbox = new LinkedBlockingQueue<>(); | ||
| private volatile boolean active = true; | ||
|
|
||
|
|
||
| public void send(Message message) { | ||
| mailbox.add(message); | ||
| } | ||
|
|
||
| public void stop() { | ||
| active = false; | ||
| } | ||
|
|
||
| @Override | ||
| public void run() { | ||
|
|
||
| } | ||
|
|
||
| protected abstract void onReceive(Message message); | ||
| } | ||
|
|
||
| ``` | ||
|
|
||
| ### Message.java | ||
|
|
||
| ```java | ||
|
|
||
| @AllArgsConstructor | ||
| @Getter | ||
| @Setter | ||
| public class Message { | ||
| private final String content; | ||
| private final String senderId; | ||
| } | ||
| ``` | ||
|
|
||
| ### ActorSystem.java | ||
|
|
||
| ```java | ||
| public class ActorSystem { | ||
| public void startActor(Actor actor) { | ||
| 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 | ||
| } | ||
| public Actor getActorById(String actorId) { | ||
| return actorRegister.get(actorId); // Find by Id | ||
| } | ||
|
|
||
| public void shutdown() { | ||
| executor.shutdownNow(); // Stop all threads | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### App.java | ||
|
|
||
| ```java | ||
| public class App { | ||
| public static void main(String[] args) { | ||
| ActorSystem system = new ActorSystem(); | ||
| Actor srijan = new ExampleActor(system); | ||
| Actor ansh = new ExampleActor2(system); | ||
|
|
||
| system.startActor(srijan); | ||
| system.startActor(ansh); | ||
| ansh.send(new Message("Hello ansh", srijan.getActorId())); | ||
| srijan.send(new Message("Hello srijan!", ansh.getActorId())); | ||
|
|
||
| Thread.sleep(1000); // Give time for messages to process | ||
|
|
||
| srijan.stop(); // Stop the actor gracefully | ||
| ansh.stop(); | ||
| system.shutdown(); // Stop the actor system | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## When to Use the Actor Model Pattern in Java | ||
|
|
||
| - When building **concurrent or distributed systems** | ||
| - When you want **no shared mutable state** | ||
| - When you need **asynchronous, message-driven communication** | ||
| - When components should be **isolated and loosely coupled** | ||
|
|
||
| --- | ||
|
|
||
| ## Actor Model Pattern Java Tutorials | ||
|
|
||
| - [Baeldung – Akka with Java](https://www.baeldung.com/java-akka) | ||
| - [Vaughn Vernon – Reactive Messaging Patterns](https://vaughnvernon.co/?p=1143) | ||
|
|
||
| --- | ||
|
|
||
| ## Real-World Applications of Actor Model Pattern in Java | ||
|
|
||
| - [Akka Framework](https://akka.io/) | ||
| - [Erlang and Elixir concurrency](https://www.erlang.org/) | ||
| - [Microsoft Orleans](https://learn.microsoft.com/en-us/dotnet/orleans/) | ||
| - JVM-based game engines and simulators | ||
|
|
||
| --- | ||
|
|
||
| ## Benefits and Trade-offs of Actor Model Pattern | ||
|
|
||
| ### ✅ Benefits | ||
| - High concurrency support | ||
| - Easy scaling across threads or machines | ||
| - Fault isolation and recovery | ||
| - Message ordering within actors | ||
|
|
||
| ### ⚠️ Trade-offs | ||
| - Harder to debug due to asynchronous behavior | ||
| - Slight performance overhead due to message queues | ||
| - More complex to design than simple method calls | ||
|
|
||
| --- | ||
|
|
||
| ## Related Java Design Patterns | ||
|
|
||
| - [Command Pattern](../command) | ||
| - [Mediator Pattern](../mediator) | ||
| - [Event-Driven Architecture](../event-driven-architecture) | ||
| - [Observer Pattern](../observer) | ||
|
|
||
| --- | ||
|
|
||
| ## References and Credits | ||
|
|
||
| - *Programming Erlang*, Joe Armstrong | ||
| - *Reactive Design Patterns*, Roland Kuhn | ||
| - *The Actor Model in 10 Minutes*, [InfoQ Article](https://www.infoq.com/articles/actor-model/) | ||
| - [Akka Documentation](https://doc.akka.io/docs/akka/current/index.html) | ||
|
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.