google / guice

Guice (pronounced 'juice') is a lightweight dependency injection framework for Java 11 and above, brought to you by Google.
https://github.com/google/guice
Apache License 2.0
12.47k stars 1.67k forks source link

Robot Legs PrivateModule leakage #805

Open gissuebot opened 10 years ago

gissuebot commented 10 years ago

From michael.kralka on May 03, 2014 01:15:43

Description of the issue: When using a PrivateModule (or PrivateBinding) to solve the robot legs problem, the private bindings used to construct a leg appear to leak into the other private bindings if one of the legs lack an binding annotation.

The attached example produces the following output:

left=RobotLegs$Leg@17a83597 foot=RobotLegs$Foot@245658a3 (righty) right=RobotLegs$Leg@20d547f8 foot=RobotLegs$Foot@245658a3 (righty)

(Notice the legs have the same right foot).

If both legs are annotated, this works as expected:

left=RobotLegs$Leg@17a83597 foot=RobotLegs$Foot@245658a3 (lefty) right=RobotLegs$Leg@20d547f8 foot=RobotLegs$Foot@1267fb9f (righty) Steps to reproduce: See attached.

Original issue: http://code.google.com/p/google-guice/issues/detail?id=805

gissuebot commented 10 years ago

From michael.kralka on May 02, 2014 22:16:38

Attaching missing example.

Attachment: gist    RobotLegs.java