Fix for #2892 basePath with configuration - #2893
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughRouterCLI startup ordering changed: router base location is now set after registry startup to avoid being overwritten. Minor local-variable and return simplifications applied. Tests were reorganized and extended; a Log4j test appender and OpenAPI fixtures were added for integration-style tests. Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as RouterCLI
participant YAML as YAML Parser
participant Reg as Registry
participant Router as Router Configuration
CLI->>YAML: parse(location)
YAML-->>Reg: register components from config
Reg->>Reg: start registered components
Reg-->>CLI: registry started
CLI->>Router: setBaseLocation(location) %% applied after registry start
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@core/src/test/java/com/predic8/membrane/core/cli/RouterCLITest.java`:
- Around line 39-55: The test installs a root TestAppender and starts a
background Thread running RouterCLI.main without cleaning them up; wrap the
Logger/TestAppender and Thread lifecycle in a try/finally: start the Thread (t)
then in finally ensure the thread is signalled and waited on (e.g.,
t.interrupt() and t.join with a short timeout or set t as daemon) to avoid
background router activity, and remove/stop the appender from the root Logger
(logger.removeAppender(appender); appender.stop()) so global logging state is
restored; keep existing assertions like appender.awaitContainsOrThrow("running",
...) but perform the cleanup after the assertion.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6f3894be-e224-430c-9ccf-477aadd50fb9
📒 Files selected for processing (6)
core/src/main/java/com/predic8/membrane/core/cli/RouterCLI.javacore/src/main/java/com/predic8/membrane/core/openapi/serviceproxy/OpenAPIRecordFactory.javacore/src/test/java/com/predic8/membrane/core/RouterCLITest.javacore/src/test/java/com/predic8/membrane/core/cli/RouterCLITest.javacore/src/test/resources/configuration/config.apis.yamlcore/src/test/resources/configuration/openapi/simple.oas.yml
💤 Files with no reviewable changes (1)
- core/src/test/java/com/predic8/membrane/core/RouterCLITest.java
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@core/src/test/java/com/predic8/membrane/core/cli/RouterCLITest.java`:
- Around line 37-55: The test starts RouterCLI.main in a background Thread (t)
and attaches a TestAppender to the root Logger but never stops the thread or
removes the appender, causing test pollution and resource leaks; modify the test
to ensure cleanup by stopping/removing the TestAppender from the Logger and
interrupting/stopping/joining the Thread (t) after the assertion (or in a
finally/@AfterEach), and if possible call RouterCLI shutdown/waitFor/stop method
on the router instance (or trigger graceful shutdown) so the background router
terminates before the test ends.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 261b62d3-e3d4-4759-9959-e88e6ff8cc7f
📒 Files selected for processing (6)
core/src/main/java/com/predic8/membrane/core/cli/RouterCLI.javacore/src/main/java/com/predic8/membrane/core/openapi/serviceproxy/OpenAPIRecordFactory.javacore/src/test/java/com/predic8/membrane/core/RouterCLITest.javacore/src/test/java/com/predic8/membrane/core/cli/RouterCLITest.javacore/src/test/resources/configuration/config.apis.yamlcore/src/test/resources/configuration/openapi/simple.oas.yml
💤 Files with no reviewable changes (1)
- core/src/test/java/com/predic8/membrane/core/RouterCLITest.java
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
core/src/test/java/com/predic8/membrane/test/TestAppender.java (1)
23-25: Do not expose mutable internal state directly
getMessages()returns the live list, so callers can mutate internal appender state. Returning a snapshot/read-only view keeps assertions deterministic.Proposed refactor
public List<String> getMessages() { - return messages; + return List.copyOf(messages); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@core/src/test/java/com/predic8/membrane/test/TestAppender.java` around lines 23 - 25, The TestAppender.getMessages() currently exposes the mutable internal List messages; change getMessages() in TestAppender to return an immutable snapshot instead (e.g., return an unmodifiable view or a copy: use List.copyOf(messages) or Collections.unmodifiableList(new ArrayList<>(messages))) so callers cannot mutate internal state and tests remain deterministic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@core/src/test/java/com/predic8/membrane/test/TestAppender.java`:
- Around line 31-42: The polling loop in awaitContains can miss messages that
arrive during the final sleep window; update awaitContains so it checks contains
immediately, then computes remaining time (deadline - System.nanoTime()), and if
remainingTime <= 0 returns false, otherwise sleeps for Math.min(50ms,
remainingTime) and repeats; reference the awaitContains method and the
contains(...) call and ensure you use remaining nanos->millis conversion when
calling Thread.sleep to avoid sleeping past the deadline.
---
Nitpick comments:
In `@core/src/test/java/com/predic8/membrane/test/TestAppender.java`:
- Around line 23-25: The TestAppender.getMessages() currently exposes the
mutable internal List messages; change getMessages() in TestAppender to return
an immutable snapshot instead (e.g., return an unmodifiable view or a copy: use
List.copyOf(messages) or Collections.unmodifiableList(new
ArrayList<>(messages))) so callers cannot mutate internal state and tests remain
deterministic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 0f1e1e82-5330-405d-8980-b5fc8ae657a1
📒 Files selected for processing (1)
core/src/test/java/com/predic8/membrane/test/TestAppender.java
Summary by CodeRabbit
Bug Fixes
Tests