Skip to content

Commit

Permalink
Muzzle should recognise mismatch on unimplemented abstract methods at…
Browse files Browse the repository at this point in the history
… runtime (#1357)
  • Loading branch information
Mateusz Rzeszutek authored Oct 9, 2020
1 parent c79c235 commit 59784a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
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

0 comments on commit 59784a5

Please sign in to comment.