-
Notifications
You must be signed in to change notification settings - Fork 1k
add Nullaway to instrumentation API incubator #14459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
dd97a48
29ba526
b9771f9
4711bdc
d674a12
857057f
0bbe11c
2ac3acd
3f2916f
47554c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,8 @@ | |
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
|
@@ -41,6 +41,11 @@ public final class CommonConfig { | |
private final String loggingSpanIdKey; | ||
private final String loggingTraceFlagsKey; | ||
|
||
interface ValueProvider<T> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this needed because the return type of java.util.function.Function is considered to be non-nullable? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
@Nullable | ||
T get(ConfigProvider configProvider); | ||
} | ||
|
||
public CommonConfig(InstrumentationConfig config) { | ||
peerServiceResolver = | ||
PeerServiceResolver.create( | ||
|
@@ -159,12 +164,12 @@ public String getTraceFlagsKey() { | |
|
||
private static <T> T getFromConfigProviderOrFallback( | ||
InstrumentationConfig config, | ||
Function<ConfigProvider, T> getFromConfigProvider, | ||
ValueProvider<T> getFromConfigProvider, | ||
T defaultValue, | ||
Supplier<T> fallback) { | ||
ConfigProvider configProvider = config.getConfigProvider(); | ||
if (configProvider != null) { | ||
T value = getFromConfigProvider.apply(configProvider); | ||
T value = getFromConfigProvider.get(configProvider); | ||
return value != null ? value : defaultValue; | ||
} | ||
// fallback doesn't return null, so we can safely call it | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -62,7 +62,7 @@ public String resolveService( | |||||
@AutoValue | ||||||
abstract static class ServiceMatcher { | ||||||
|
||||||
static ServiceMatcher create(Integer port, String path) { | ||||||
static ServiceMatcher create(@Nullable Integer port, @Nullable String path) { | ||||||
return new AutoValue_PeerServiceResolverImpl_ServiceMatcher(port, path); | ||||||
} | ||||||
|
||||||
|
@@ -72,7 +72,7 @@ static ServiceMatcher create(Integer port, String path) { | |||||
@Nullable | ||||||
abstract String getPath(); | ||||||
|
||||||
public boolean matches(Integer port, Supplier<String> pathSupplier) { | ||||||
public boolean matches(@Nullable Integer port, @Nullable Supplier<String> pathSupplier) { | ||||||
|
public boolean matches(@Nullable Integer port, @Nullable Supplier<String> pathSupplier) { | |
public boolean matches(@Nullable Integer port, Supplier<String> pathSupplier) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I see, how about zeitlinger#7?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simply adding
@Nullable
to the generic arg didn't work