Skip to content

Refactor remove proxy aware#2884

Merged
rrayst merged 6 commits into
masterfrom
refactor-remove-proxy-aware
Mar 17, 2026
Merged

Refactor remove proxy aware#2884
rrayst merged 6 commits into
masterfrom
refactor-remove-proxy-aware

Conversation

@predic8

@predic8 predic8 commented Mar 17, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Refactor

    • Removed legacy proxy contract and simplified proxy handling across interceptors; interceptors now expose their proxy via a unified accessor.
    • Enhanced flow management API for nested interceptor initialization.
    • Streamlined rule management by removing per-source tracking and listener notifications.
  • Documentation

    • Roadmap updated with Proxy Server Configuration Sample and ReplaceInterceptor language support.
  • Tests

    • Added tests validating propagation of router and proxy to nested interceptors.

predic8 added 3 commits March 17, 2026 13:12
- Eliminated `ProxyAware` interface, simplifying codebase and reducing unused complexity.
- Updated `AbstractInterceptor`, `Interceptor`, and related implementations to directly manage proxy references via `getProxy()` and `init()`.
- Refactored interceptors to remove unused `Proxy` fields and redundant `setProxy()` methods.
- Adjusted roadmap to reflect removal of `ProxyAware` and associated refactoring tasks.
- Simplified `AbstractFlowInterceptor`, `OAuth2AuthorizationServerInterceptor`, `WebServiceExplorerInterceptor`, and `RuleManager` by removing unused fields, imports, and redundant logic.
- Cleaned up code to improve maintainability and readability across core interceptor and proxy-related classes.
@coderabbitai

coderabbitai Bot commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 446681ea-ec9f-48fd-9b88-18efb87fe0eb

📥 Commits

Reviewing files that changed from the base of the PR and between 093a89e and b2a3680.

📒 Files selected for processing (1)
  • core/src/test/java/com/predic8/membrane/core/interceptor/flow/AbstractFlowInterceptorTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • core/src/test/java/com/predic8/membrane/core/interceptor/flow/AbstractFlowInterceptorTest.java

📝 Walkthrough

Walkthrough

Removed the ProxyAware interface and centralized proxy storage/propagation: AbstractInterceptor now stores the Proxy and exposes getProxy(); Interceptor gained getProxy(); initialization now passes Proxy to interceptors via init(router, proxy); RuleManager removed listener and per-source tracking; Flow interceptors propagate router+proxy to nested interceptors.

Changes

Cohort / File(s) Summary
ProxyAware Interface Removal
core/src/main/java/com/predic8/membrane/core/config/ProxyAware.java
Deleted the ProxyAware interface and its setProxy(Proxy) contract.
Interceptor core API & storage
core/src/main/java/com/predic8/membrane/core/interceptor/AbstractInterceptor.java, core/src/main/java/com/predic8/membrane/core/interceptor/Interceptor.java
Added protected proxy field and getProxy() in AbstractInterceptor; added Proxy getProxy() to Interceptor interface; AbstractInterceptor.init stores the proxy.
Initialization flow change
core/src/main/java/com/predic8/membrane/core/proxies/AbstractProxy.java
Init loop simplified to call init(router, this) on interceptors directly (no ProxyAware checks).
Removed ProxyAware implementations
core/src/main/java/com/predic8/membrane/core/interceptor/authentication/session/LoginInterceptor.java, core/src/main/java/com/predic8/membrane/core/interceptor/groovy/GroovyInterceptor.java, core/src/main/java/com/predic8/membrane/core/interceptor/oauth2/OAuth2AuthorizationServerInterceptor.java, core/src/main/java/com/predic8/membrane/core/interceptor/soap/WebServiceExplorerInterceptor.java
Removed implements ProxyAware, removed private proxy fields and setProxy() overrides; adjusted logging/usages accordingly.
Flow interceptor propagation
core/src/main/java/com/predic8/membrane/core/interceptor/flow/AbstractFlowInterceptor.java, core/src/test/java/com/predic8/membrane/core/interceptor/flow/AbstractFlowInterceptorTest.java
Added getFlow()/setFlow() and interceptors field; child interceptors are initialized with init(router, proxy); added test verifying propagation of router and proxy to nested interceptors.
RuleManager simplification
core/src/main/java/com/predic8/membrane/core/proxies/RuleManager.java
Removed ruleSources and listeners fields, listener notifications, and getRulesBySource(); rule changes no longer notify listeners or track sources.
Docs
docs/ROADMAP.md
Removed YAML Support note; added Proxy Server Configuration Sample (PRIO 1) and ReplaceInterceptor: Support Languages (PRIO 3).

Sequence Diagram(s)

sequenceDiagram
    participant AbstractProxy
    participant Interceptor
    participant AbstractInterceptor
    participant AbstractFlowInterceptor
    participant ChildInterceptor

    AbstractProxy->>Interceptor: init(router, proxy)
    Note right of Interceptor: Concrete interceptor\ncalls super.init(router, proxy)
    Interceptor->>AbstractInterceptor: init(router, proxy)
    AbstractInterceptor->>AbstractInterceptor: this.proxy = proxy
    AbstractFlowInterceptor->>AbstractFlowInterceptor: iterate getFlow()
    AbstractFlowInterceptor->>ChildInterceptor: child.init(router, proxy)
    ChildInterceptor->>AbstractInterceptor: child stores proxy via init
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • rrayst
  • christiangoerdes

Poem

🐰 Hopping through the init and flow,
I tuck the proxy where it needs to go,
No more contracts scattered wide,
One warm field where proxies bide,
Code’s snug, and logs glow. 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.88% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Refactor remove proxy aware' clearly describes the main change: removing the ProxyAware pattern and refactoring the codebase to eliminate the ProxyAware interface and related implementations.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor-remove-proxy-aware
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@membrane-ci-server

Copy link
Copy Markdown

This pull request needs "/ok-to-test" from an authorized committer.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

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

⚠️ Outside diff range comments (1)
core/src/main/java/com/predic8/membrane/core/interceptor/flow/AbstractFlowInterceptor.java (1)

39-44: ⚠️ Potential issue | 🔴 Critical

Nested interceptors won't receive the proxy reference.

Line 43 calls i.init(router) for child interceptors, but should call i.init(router, proxy) to propagate the proxy reference. Without this, any interceptor nested inside a flow interceptor (e.g., inside <if>, <request>, etc.) will have getProxy() return null.

The parent AbstractProxy.init(Router) correctly calls i.init(router, this) for top-level interceptors, so this flow interceptor should do the same for its children.

🐛 Proposed fix to propagate proxy to nested interceptors
     `@Override`
     public void init() {
         super.init();
         for (Interceptor i : interceptors)
-            i.init(router);
+            i.init(router, proxy);
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@core/src/main/java/com/predic8/membrane/core/interceptor/flow/AbstractFlowInterceptor.java`
around lines 39 - 44, AbstractFlowInterceptor.init currently calls
i.init(router) for child interceptors so nested interceptors never receive the
proxy reference; change the call to pass the proxy (call i.init(router,
getProxy()) or i.init(router, this.getProxy())) so nested interceptors get the
same proxy as the parent; update AbstractFlowInterceptor.init to invoke
Interceptor.init(Router, Proxy) for each interceptor, mirroring
AbstractProxy.init(Router) which uses i.init(router, this).
🤖 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/main/java/com/predic8/membrane/core/interceptor/AbstractInterceptor.java`:
- Around line 114-116: In AbstractInterceptor.init(Router router, Proxy proxy)
assign this.proxy = proxy before calling init(router) so subclasses' overridden
init(Router) see a non-null proxy; i.e., move the this.proxy assignment to
precede the call to init(router) (affects AbstractInterceptor.init(Router,
Proxy) and ensures subclass init(Router) methods that compute values from proxy
get the proper proxy reference).

In `@docs/ROADMAP.md`:
- Line 55: Fix the typo in the ROADMAP entry referencing ReplaceInterceptor:
change "tansformation" to "transformation" so the line reads
"ReplaceInterceptor: Support Languages, tutorial/transformation" (or
"tutorial/transformation" if you prefer a slash) — update the text where
ReplaceInterceptor is mentioned in the ROADMAP.md.

---

Outside diff comments:
In
`@core/src/main/java/com/predic8/membrane/core/interceptor/flow/AbstractFlowInterceptor.java`:
- Around line 39-44: AbstractFlowInterceptor.init currently calls i.init(router)
for child interceptors so nested interceptors never receive the proxy reference;
change the call to pass the proxy (call i.init(router, getProxy()) or
i.init(router, this.getProxy())) so nested interceptors get the same proxy as
the parent; update AbstractFlowInterceptor.init to invoke
Interceptor.init(Router, Proxy) for each interceptor, mirroring
AbstractProxy.init(Router) which uses i.init(router, this).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 179a0c1d-ceea-4b40-8729-dbc05b977238

📥 Commits

Reviewing files that changed from the base of the PR and between eed215a and 0279a1d.

📒 Files selected for processing (11)
  • core/src/main/java/com/predic8/membrane/core/config/ProxyAware.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/AbstractInterceptor.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/Interceptor.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/authentication/session/LoginInterceptor.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/flow/AbstractFlowInterceptor.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/groovy/GroovyInterceptor.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/oauth2/OAuth2AuthorizationServerInterceptor.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/soap/WebServiceExplorerInterceptor.java
  • core/src/main/java/com/predic8/membrane/core/proxies/AbstractProxy.java
  • core/src/main/java/com/predic8/membrane/core/proxies/RuleManager.java
  • docs/ROADMAP.md
💤 Files with no reviewable changes (1)
  • core/src/main/java/com/predic8/membrane/core/config/ProxyAware.java

Comment thread docs/ROADMAP.md Outdated
@coderabbitai

coderabbitai Bot commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

No open human review comments were found in this PR to create a plan for.

predic8 added 2 commits March 17, 2026 13:56
…nterceptor

- Improved proxy initialization in `AbstractInterceptor` and `AbstractFlowInterceptor` to ensure consistent propagation.
- Updated `init()` logic to handle `proxy` references appropriately across interceptors.
- Added `AbstractFlowInterceptorTest` to validate proxy propagation and router integration.
- Minor corrections in `ROADMAP.md` and cleanup of unused fields.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
core/src/test/java/com/predic8/membrane/core/interceptor/flow/AbstractFlowInterceptorTest.java (1)

14-24: Consider using the public API for cleaner test setup.

The test directly accesses the protected interceptors field. While this works (same package), using the public setFlow() method would make the test more resilient to internal refactoring and better document the intended usage.

♻️ Suggested refactor using public API
     void propagationOfProxy() {
         var r = new TestRouter();
         var p = new ServiceProxy();
         var ri = new RequestInterceptor();
         var ti = new LogInterceptor();
-        ri.interceptors.add(ti);
+        ri.setFlow(java.util.List.of(ti));
         ri.init(r,p);
         assertSame(r,ti.getRouter());
         assertSame(p,ti.getProxy());
     }
🤖 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/core/interceptor/flow/AbstractFlowInterceptorTest.java`
around lines 14 - 24, The test directly mutates the protected field
ri.interceptors; replace that with the public API by calling
RequestInterceptor.setFlow(...) to install the child interceptor(s). Concretely,
remove ri.interceptors.add(ti) and call
ri.setFlow(Collections.singletonList(ti)) (or Arrays.asList(ti)) so the test
uses the public setFlow method on RequestInterceptor and keeps the rest of the
assertions (assertSame(r, ti.getRouter()), assertSame(p, ti.getProxy()))
unchanged.
🤖 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/interceptor/flow/AbstractFlowInterceptorTest.java`:
- Line 7: Remove the unused Groovy logging import from the test class: delete
the line "import groovy.util.logging.*" in AbstractFlowInterceptorTest so the
class no longer contains an unused import; verify compilation/tests still pass
after removing it.

---

Nitpick comments:
In
`@core/src/test/java/com/predic8/membrane/core/interceptor/flow/AbstractFlowInterceptorTest.java`:
- Around line 14-24: The test directly mutates the protected field
ri.interceptors; replace that with the public API by calling
RequestInterceptor.setFlow(...) to install the child interceptor(s). Concretely,
remove ri.interceptors.add(ti) and call
ri.setFlow(Collections.singletonList(ti)) (or Arrays.asList(ti)) so the test
uses the public setFlow method on RequestInterceptor and keeps the rest of the
assertions (assertSame(r, ti.getRouter()), assertSame(p, ti.getProxy()))
unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f7e12ef5-9139-400f-b7f0-072e436032ad

📥 Commits

Reviewing files that changed from the base of the PR and between 0279a1d and 093a89e.

📒 Files selected for processing (4)
  • core/src/main/java/com/predic8/membrane/core/interceptor/AbstractInterceptor.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/flow/AbstractFlowInterceptor.java
  • core/src/test/java/com/predic8/membrane/core/interceptor/flow/AbstractFlowInterceptorTest.java
  • docs/ROADMAP.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • docs/ROADMAP.md
  • core/src/main/java/com/predic8/membrane/core/interceptor/AbstractInterceptor.java

… and router

- Renamed test method for clarity and updated logic to use `setFlow` with `List.of`.
- Verified proper initialization of nested interceptors with proxy and router.
@predic8

predic8 commented Mar 17, 2026

Copy link
Copy Markdown
Member Author

/ok-to-test

@predic8 predic8 requested a review from rrayst March 17, 2026 14:52
@rrayst rrayst merged commit e7eb3b5 into master Mar 17, 2026
5 checks passed
@rrayst rrayst deleted the refactor-remove-proxy-aware branch March 17, 2026 17:07
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