Skip to content

Commit c683999

Browse files
java-team-github-botGuice Team
authored andcommitted
Tweak Guice to suggest toProvider(() -> null) rather than toProvider(Providers.of(null)).
PiperOrigin-RevId: 780105053
1 parent 2a1d0fb commit c683999

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

core/src/com/google/inject/internal/AbstractBindingBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public abstract class AbstractBindingBuilder<T> {
4141
public static final String SCOPE_ALREADY_SET = "Scope is set more than once.";
4242
public static final String BINDING_TO_NULL =
4343
"Binding to null instances is not allowed. "
44-
+ "Use toProvider(Providers.of(null)) if this is your intended behaviour.";
44+
+ "Use toProvider(() -> null) if this is your intended behaviour.";
4545
public static final String CONSTANT_VALUE_ALREADY_SET = "Constant value is set more than once.";
4646
public static final String ANNOTATION_ALREADY_SPECIFIED =
4747
"More than one annotation is specified for this binding.";

core/test/com/google/inject/BinderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ public void configure() {
223223
} catch (CreationException expected) {
224224
assertContains(
225225
expected.getMessage(),
226-
"1) Binding to null instances is not allowed. Use toProvider(Providers.of(null))",
227-
"2) Binding to null instances is not allowed. Use toProvider(Providers.of(null))");
226+
"1) Binding to null instances is not allowed. Use toProvider(() -> null)",
227+
"2) Binding to null instances is not allowed. Use toProvider(() -> null)");
228228
}
229229
}
230230

0 commit comments

Comments
 (0)