-
Notifications
You must be signed in to change notification settings - Fork 1.7k
CIRCULAR_PROXY_DISABLED
Guice will throw a CIRCULAR_PROXY_DISABLED error when it runs into a circular
dependency cycle and the injector is configured to disable
circular proxy.
Example:
final class Foo {
@Inject
Foo(Bar bar) {
...
}
}
final class Bar {
@Inject
Bar(Baz baz) {
...
}
}
final class Baz {
@Inject
Baz(Foo foo) {
...
}
}In the above example, in order to create instance of Foo, Guice runs into a
circular dependency cycle: Foo -> Bar -> Baz -> Foo. In a real
application the circular dependency cycle might be much more complicated and
less obvious than this example.
Take the example from the summary section above. Class Baz is
changed from:
final class Baz {
@Inject
Baz() {
...
}
}to
final class Baz {
// Baz now depends on Foo
@Inject
Baz(Foo foo) {
...
}
}By depending on Foo in Baz, a new circular dependency cycle that previously
does not exist is introduced.
To fix this type of issues, see ways to avoid circular dependencies.
NOTE: Depending on the types involved in the circular cycle, you may get a
CAN_NOT_PROXY_CLASS error instead of CIRCULAR_PROXY_DISABLED.
If no new circular dependency cycle was added and you suddenly start getting
CIRCULAR_PROXY_DISABLED error then it's likely that some module that your
application installs has
disabled circular proxy
feature in Guice.
There are two ways to fix this:
- (recommended) Break the circular dependencies.
- (discouraged) Re-enable circular proxy feature in Guice by removing the
code that calls
binder().disableCircularProxies().
-
User's Guide
-
Integration
-
Extensions
-
Internals
-
Releases
-
Community