Skip to content

[ES-2992B] added custom audit executor#203

Merged
anushasunkada merged 1 commit into
mosip:developfrom
Infosys:ES-2992B
Apr 22, 2026
Merged

[ES-2992B] added custom audit executor#203
anushasunkada merged 1 commit into
mosip:developfrom
Infosys:ES-2992B

Conversation

@KashiwalHarsh
Copy link
Copy Markdown
Contributor

@KashiwalHarsh KashiwalHarsh commented Apr 21, 2026

Summary by CodeRabbit

  • Performance Improvements
    • Audit logging is now processed asynchronously, reducing latency for user-initiated operations and improving overall system responsiveness.

Signed-off-by: Harsh Kashiwal <harsh.kashiwal@infosys.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

Walkthrough

Two logAudit method overloads in IdaAuditPluginImpl are now annotated with @Async("auditTaskExecutor"), enabling asynchronous execution via a named Spring task executor. The underlying audit logic remains unchanged. An import for org.springframework.scheduling.annotation.Async was added to support the annotations.

Changes

Cohort / File(s) Summary
Async Audit Execution
mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/service/IdaAuditPluginImpl.java
Added @Async("auditTaskExecutor") annotations to both logAudit method overloads to dispatch audit operations asynchronously. Added import for org.springframework.scheduling.annotation.Async.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hops of speed, no more delays,
Audit logs now run their ways,
Async magic, swift and free,
Tasks that hop asynchronously!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding @Async annotation with a custom audit executor to the logAudit methods.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/service/IdaAuditPluginImpl.java (1)

55-65: ⚠️ Potential issue | 🟠 Major

Ensure consuming application configures auditTaskExecutor bean and @EnableAsync; otherwise @Async will be a no-op or fail at runtime.

The @Async("auditTaskExecutor") annotations added at lines 55 and 61 require two things in the Spring context of the consuming application:

  1. @EnableAsync must be present on a configuration class in the consumer's application.
  2. A bean named auditTaskExecutor (TaskExecutor or Executor) must be defined in the consumer's application.

Neither exists in this plugin repository. When the named executor is not found, Spring's behavior varies: older versions silently fall back to SimpleAsyncTaskExecutor, while newer versions may throw an exception at invocation. Since the plugin is a library consumed by eSignet (or another parent app), responsibility for this configuration lies with the consumer—but the lack of enforcement or documentation here creates a significant risk of misconfiguration going unnoticed in production.

Additionally:

  • Existing unit tests instantiate IdaAuditPluginImpl directly without a Spring proxy, so the @Async path is uncovered by tests. Misconfiguration in the consuming app will not be caught by the plugin's test suite.
  • Exceptions from async calls are silently logged (no exception propagation with void return type), which is acceptable given audit(...) already wraps logic in try/catch.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/service/IdaAuditPluginImpl.java`
around lines 55 - 65, The async annotations on IdaAuditPluginImpl.logAudit(...)
require a named executor and `@EnableAsync` in the consumer; add a safe
library-side fallback by creating a configuration class (e.g., AuditAsyncConfig)
that is annotated with `@Configuration` and `@EnableAsync` and defines a `@Bean`(name
= "auditTaskExecutor") method that is `@ConditionalOnMissingBean`(name =
"auditTaskExecutor") and returns a sensible TaskExecutor (e.g., a
ThreadPoolTaskExecutor with reasonable defaults) so consumers that don't provide
one still get async behavior; also add JavaDoc to IdaAuditPluginImpl referencing
the requirement and update unit tests to load AuditAsyncConfig (or use a Spring
test context) so the `@Async` path for logAudit(...) is exercised.
🧹 Nitpick comments (1)
mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/service/IdaAuditPluginImpl.java (1)

22-22: Minor: indentation inconsistency.

Lines 22 (import), 55 and 61 (the new @Async annotations) use space indentation, while the rest of the file uses tabs. Not functional, but worth aligning to keep the file consistent.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/service/IdaAuditPluginImpl.java`
at line 22, The import and two `@Async` annotations in IdaAuditPluginImpl are
indented with spaces while the file uses tabs; update the indentation to use
tabs for the import statement "import
org.springframework.scheduling.annotation.Async;" and for the two occurrences of
the "@Async" annotation (around the methods in IdaAuditPluginImpl) so they match
the rest of the file's tab-based indentation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In
`@mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/service/IdaAuditPluginImpl.java`:
- Around line 55-65: The async annotations on IdaAuditPluginImpl.logAudit(...)
require a named executor and `@EnableAsync` in the consumer; add a safe
library-side fallback by creating a configuration class (e.g., AuditAsyncConfig)
that is annotated with `@Configuration` and `@EnableAsync` and defines a `@Bean`(name
= "auditTaskExecutor") method that is `@ConditionalOnMissingBean`(name =
"auditTaskExecutor") and returns a sensible TaskExecutor (e.g., a
ThreadPoolTaskExecutor with reasonable defaults) so consumers that don't provide
one still get async behavior; also add JavaDoc to IdaAuditPluginImpl referencing
the requirement and update unit tests to load AuditAsyncConfig (or use a Spring
test context) so the `@Async` path for logAudit(...) is exercised.

---

Nitpick comments:
In
`@mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/service/IdaAuditPluginImpl.java`:
- Line 22: The import and two `@Async` annotations in IdaAuditPluginImpl are
indented with spaces while the file uses tabs; update the indentation to use
tabs for the import statement "import
org.springframework.scheduling.annotation.Async;" and for the two occurrences of
the "@Async" annotation (around the methods in IdaAuditPluginImpl) so they match
the rest of the file's tab-based indentation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 56ac79db-4add-49fe-a63b-933e198bf0bc

📥 Commits

Reviewing files that changed from the base of the PR and between 1c7cf4b and af47146.

📒 Files selected for processing (1)
  • mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/service/IdaAuditPluginImpl.java

@KashiwalHarsh
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@anushasunkada anushasunkada merged commit ddf6a56 into mosip:develop Apr 22, 2026
13 checks passed
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.

2 participants