History log of /external/guice/extensions/multibindings/test/com/google/inject/multibindings/OptionalBinderTest.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
825f8c1df885b9d7643a9e18e336984f0138edaf 23-Mar-2015 sameb <sameb@google.com> Some work on issue 910 -- ensure that anonymous keys & typeliterals don't
retain references to their parent classes. Still some more work to do in
WeakKeySet to let it clean up more frequently, but this should help for now.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=89328452
/external/guice/extensions/multibindings/test/com/google/inject/multibindings/OptionalBinderTest.java
1d3f8cd0a163c7439589d80e6377edbf2ca4b43d 08-Oct-2014 sameb <sameb@google.com> Add support for java.util.Optional, reflectively. If the class exists, we bind
it the same way we bind com.google.common.base.Optional. Update tests
accordingly.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77215848
/external/guice/extensions/multibindings/test/com/google/inject/multibindings/OptionalBinderTest.java
c34e0185fcf508a890c6cd13bdafeb505c3e9e8a 06-Aug-2014 Sam Berlin <sameb@google.com> Implement binding deduplication for multibinder & mapbinder in a different way.
Instead of relying on Guice binding deduplication (and hacking up RealElement
to break the annotation contract to do so, causing weirdness in WeakKeySet &
forcing us to care about "rehashing keys"), we instead deduplicate within
Multibinder. The downside of this is that toInstance or toProvider(instance)
bindings that are deduplicated will remain in the object graph but effectively
be unreachable. However, that's a downside I'm willing to live with to remove
this hack.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=72570932
/external/guice/extensions/multibindings/test/com/google/inject/multibindings/OptionalBinderTest.java
d08bba96c4a647e2fd7588a7ea36c77b09ab2047 10-Jul-2014 Sam Berlin <sameb@google.com> More flake fixing: Refactor WeakKeySetUtils into one spot, make everything use
it, loop 10 times sleeping a second each before relying on things that were
GC'd.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=70898677
/external/guice/extensions/multibindings/test/com/google/inject/multibindings/OptionalBinderTest.java
08125e9287e577e167ca1186eeff9e14c51250c4 10-Jul-2014 Sam Berlin <sameb@google.com> Fix equal comparison against generated/system annotations. This should never
happen in practice, but some things generate annotations based on user input in
order to compare against Guice bindings.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=70843442
/external/guice/extensions/multibindings/test/com/google/inject/multibindings/OptionalBinderTest.java
842f351c4b2b3b0a90d9f3bcf164d8fd19aede6c 10-Jul-2014 Sam Berlin <sameb@google.com> Add support for OptionalBinder to link to normal bindings of that type if
neither setDefault nor setBinding are called. From the javadoc, example:

* <pre><code>
* public class FrameworkModule extends AbstractModule {
* protected void configure() {
* OptionalBinder.newOptionalBinder(binder(), Renamer.class);
* }
* }</code></pre>
*
* <p>With this module, an {@link Optional}{@code <Renamer>} can now be
* injected. With no other bindings, the optional will be absent.
* Users can specify bindings in one of two ways:
*
* <p>Option 1:
* <pre><code>
* public class UserRenamerModule extends AbstractModule {
* protected void configure() {
* bind(Renamer.class).to(ReplacingRenamer.class);
* }
* }</code></pre>
*
* <p>or Option 2:
* <pre><code>
* public class UserRenamerModule extends AbstractModule {
* protected void configure() {
* OptionalBinder.newOptionalBinder(binder(), Renamer.class)
* .setBinding().to(ReplacingRenamer.class);
* }
* }</code></pre>
* With both options, the {@code Optional<Renamer>} will be present and supply the
* ReplacingRenamer.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=70835975
/external/guice/extensions/multibindings/test/com/google/inject/multibindings/OptionalBinderTest.java
6ae9ff6c662e979efea1c5f7195c47ef5715b20a 10-Jul-2014 Sam Berlin <sameb@google.com> Wrap GcFinalization usage around wrappers that also await a ReferenceQueue. I
couldn't get any failures internally in 10,000 runs even w/o these changes, but
on the external builds I reliably reproduced some flakes in 100 runs w/o this,
and no flakes (that I saw) afterwards.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=70835114
/external/guice/extensions/multibindings/test/com/google/inject/multibindings/OptionalBinderTest.java
c66f08e3d6798e88f35be51679854568f337e7eb 10-Jul-2014 Sam Berlin <sameb@google.com> Automated g4 rollback of changelist 70738452.

*** Reason for rollback ***

Fix projects that were doing dependency analysis by returning a dependency on the Injector when run on raw Elements (instead of a dependency on @Actual+@Default, even though we didn't know which would really exist).

*** Original change description ***

Automated g4 rollback of changelist 70734332.

*** Reason for rollback ***

Broke a project.

*** Original change description ***

Simplify OptionalBinder implementation to not delegate to a MapBinder.
Instead, bind directly to annotated @Actual/@Default keys. This is in
preparation for future improvements.

This contains two logical changes:
1) The error message for duplicate actual/default bindings is now the default Guice message, instead of a custom thing in MapBinder.
2) getDependencies now...

***
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=70742247
/external/guice/extensions/multibindings/test/com/google/inject/multibindings/OptionalBinderTest.java
8f89a23e16435f81bd4e083185f2f2c5a520f954 10-Jul-2014 Sam Berlin <sameb@google.com> Automated g4 rollback of changelist 70734332.

*** Reason for rollback ***

Broke a project.

*** Original change description ***

Simplify OptionalBinder implementation to not delegate to a MapBinder.
Instead, bind directly to annotated @Actual/@Default keys. This is in
preparation for future improvements.

This contains two logical changes:
1) The error message for duplicate actual/default bindings is now the default Guice message, instead of a custom thing in MapBinder.
2) getDependencies now returns the live dependency (either the actual or the default, not both). Also, Optional<Provider<T>> continues to return a de...

***
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=70738452
/external/guice/extensions/multibindings/test/com/google/inject/multibindings/OptionalBinderTest.java
9040306545ddd134a8b0ebe97a21b581cc3df962 10-Jul-2014 Sam Berlin <sameb@google.com> Simplify OptionalBinder implementation to not delegate to a MapBinder.
Instead, bind directly to annotated @Actual/@Default keys. This is in
preparation for future improvements.

This contains two logical changes:
1) The error message for duplicate actual/default bindings is now the default Guice message, instead of a custom thing in MapBinder.
2) getDependencies now returns the live dependency (either the actual or the default, not both). Also, Optional<Provider<T>> continues to return a dep to Provider<T>, but Optional<T> returns a dep of T directly.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=70734332
/external/guice/extensions/multibindings/test/com/google/inject/multibindings/OptionalBinderTest.java
d57f8ece5508afc66c4768396c54b412dc9f2cc2 08-Apr-2014 Sam Berlin <sameb@google.com> The bug in the test that became flaky has been fixed. Note that this is not a strict rollback of the rollback - I've added protection against the NPE that would happen if there's a GC between the isBlacklisted call and the getSources call.

*** Original change description ***

Enhance WeakKeySet to auto evict keys and avoid calling toString on Keys.

This should fix https://code.google.com/p/google-guice/issues/detail?id=756.

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=64507759
/external/guice/extensions/multibindings/test/com/google/inject/multibindings/OptionalBinderTest.java
c013facb2aa0af03206fd1af2d8314f6a414ec98 08-Apr-2014 Sam Berlin <sameb@google.com> *** Reason for rollback ***

Causes an internal test to become flaky.

*** Original change description ***

Enhance WeakKeySet to auto evict keys and avoid calling toString on Keys.

This should fix https://code.google.com/p/google-guice/issues/detail?id=756.

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=64181193
/external/guice/extensions/multibindings/test/com/google/inject/multibindings/OptionalBinderTest.java
bab9b6082ff7c3aefac2dc8c7de0468fe60fe8f6 02-Apr-2014 Christian Edward Gruber <cgruber@google.com> Enhance WeakKeySet to auto evict keys and avoid calling toString on Keys.

This should fix https://code.google.com/p/google-guice/issues/detail?id=756.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=64083354
/external/guice/extensions/multibindings/test/com/google/inject/multibindings/OptionalBinderTest.java
af24f632f90fc91daeb30172b874405c131592c8 02-Apr-2014 Christian Edward Gruber <cgruber@google.com> Adds a new OptionalBinder. OptionalBinder allows frameworks to setup bindings for items that user code may or may not bind. It also allows frameworks to set default values that users can override.

The API is:
OptionalBinder.newOptionalBinder(Binder, Class|TypeLiteral|Key) -> OptionalBinder
optionalBinder.setDefault -> LinkedBindingBuilder
optionalBinder.setBinding -> LinkedBindingBuilder

By way of example, this will do:

newOptionalBinder(..) -> @Inject Thing -> exception: neither setDefault nor setBinding called
newOptionalBinder(..) -> @Inject Optional<Thing> -> isPresent() == false
newOptionalBinder(..).setDefault().to("a") -> @Inject Thing -> "a"
newOptionalBinder(..).setDefault().to("a") -> @Inject Optional<Thing> --> get() == "a"
newOptionalBinder(..).setDefault().to("a") + newOptionalBinder(..).setBinding().to("b") -> @Inject Thing -> "b"
newOptionalBinder(..).setDefault().to("a") + newOptionalBinder(..).setBinding().to("b") -> @Inject Optional<Thing> -> get() == "b"
newOptionalBinder(..).setBinding().to("b") -> @Inject Thing -> "b"
newOptionalBinder(..).setBinding().to("b") -> @Inject Optional<Thing> -> get() == "b"
newOptionalBinder(..).setDefault().to("a") + newOptionalBinder(..).setDefault().to("b") -> configuration exception
newOptionalBinder(..).setBinding().to("a") + newOptionalBinder(..).setBinding().to("b") -> configuration exception

(This also adds the jsr305 jar for build time, because doclava wanted it. Frustrating.)

(This also fixes users that implemented MultibindingsTargetVisitor, because I can't use default methods yet.)
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=63873859
/external/guice/extensions/multibindings/test/com/google/inject/multibindings/OptionalBinderTest.java