Skip to content
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

Muzzle should recognise mismatch on unimplemented abstract methods at runtime #1357

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,25 @@
* create references from the method advice and helper classes.
*/
final class ReferenceCreationPredicate {
private static final String REFERENCE_CREATION_PACKAGE = "io.opentelemetry.instrumentation.";
// non-shaded packages
private static final String AUTO_INSTRUMENTATION_PACKAGE =
"io.opentelemetry.instrumentation.auto.";
private static final String JAVA_AGENT_TOOLING_PACKAGE = "io.opentelemetry.javaagent.tooling.";
private static final String AUTO_INSTRUMENTATION_API_PACKAGE =
"io.opentelemetry.instrumentation.auto.api.";

private static final String JAVA_AGENT_PACKAGE = "io.opentelemetry.javaagent.tooling.";

private static final String[] REFERENCE_CREATION_PACKAGE_EXCLUDES = {
"io.opentelemetry.instrumentation.api.", "io.opentelemetry.instrumentation.auto.api."
};
// shaded packages
private static final String LIBRARY_INSTRUMENTATION_PACKAGE = "io.opentelemetry.instrumentation.";
private static final String INSTRUMENTATION_API_PACKAGE = "io.opentelemetry.instrumentation.api.";

static boolean shouldCreateReferenceFor(String className) {
if (!className.startsWith(REFERENCE_CREATION_PACKAGE)) {
return className.startsWith(JAVA_AGENT_PACKAGE);
}
for (String exclude : REFERENCE_CREATION_PACKAGE_EXCLUDES) {
if (className.startsWith(exclude)) {
return false;
}
if (className.startsWith(INSTRUMENTATION_API_PACKAGE)
|| className.startsWith(AUTO_INSTRUMENTATION_API_PACKAGE)) {
return false;
}
return true;
return className.startsWith(AUTO_INSTRUMENTATION_PACKAGE)
|| className.startsWith(JAVA_AGENT_TOOLING_PACKAGE)
|| className.startsWith(LIBRARY_INSTRUMENTATION_PACKAGE);
}

private ReferenceCreationPredicate() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ class ReferenceCreationPredicateTest extends Specification {
ReferenceCreationPredicate.shouldCreateReferenceFor(className)

where:
desc | className
"Instrumentation class" | "io.opentelemetry.instrumentation.some_instrumentation.Advice"
"javaagent-tooling class" | "io.opentelemetry.javaagent.tooling.Constants"
desc | className
"auto instrumentation class" | "io.opentelemetry.instrumentation.auto.some_instrumentation.Advice"
"javaagent-tooling class" | "io.opentelemetry.javaagent.tooling.Constants"
"library instrumentation class" | "io.opentelemetry.instrumentation.LibraryClass"
}

@Unroll
Expand Down