forked from open-telemetry/opentelemetry-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reject null instrumentationName for Meters and Tracers
The parameters were already marked as being @nonnull. However, the SDK implementation failed when null was passed, while the API allowed null. The result is that one may publish a library that compiles and tests fine, but fails when the SDK is applied by an application developer. This change adds test to verify the non-null behavior is consistently enforced, and adds checks to the API to enforce non-null. These checks will prevent library authors from creating libraries that crash at runtime. Fixes open-telemetry#1879
- Loading branch information
1 parent
1a7a117
commit d05c042
Showing
6 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
api/src/test/java/io/opentelemetry/api/metrics/DefaultMeterProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.opentelemetry.api.metrics; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class DefaultMeterProviderTest { | ||
|
||
@Test | ||
void rejectsNullInstrumentationName() { | ||
assertThrows(NullPointerException.class, () -> DefaultMeterProvider.getInstance().get(null)); | ||
assertThrows(NullPointerException.class, () -> DefaultMeterProvider.getInstance().get(null, "1.0.0")); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
api/src/test/java/io/opentelemetry/api/trace/DefaultTracerProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.opentelemetry.api.trace; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
class DefaultTracerProviderTest { | ||
|
||
@Test | ||
void rejectsNullInstrumentationName() { | ||
assertThrows(NullPointerException.class, () -> DefaultTracerProvider.getInstance().get(null)); | ||
assertThrows(NullPointerException.class, () -> DefaultTracerProvider.getInstance().get(null, "1.0.0")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters