Skip to content

Commit 0163695

Browse files
committed
fix: replace Path.of() with Paths.get() for Java 8 compatibility
1 parent 4a7f154 commit 0163695

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

aws-resources/src/main/java/io/opentelemetry/contrib/aws/resource/LambdaResource.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.io.IOException;
2222
import java.nio.file.Files;
2323
import java.nio.file.Path;
24+
import java.nio.file.Paths;
2425
import java.util.Map;
2526
import java.util.stream.Stream;
2627

@@ -40,12 +41,12 @@ public static Resource get() {
4041
}
4142

4243
private static Resource buildResource() {
43-
return buildResource(System.getenv(), Path.of(ACCOUNT_ID_SYMLINK_PATH));
44+
return buildResource(System.getenv(), Paths.get(ACCOUNT_ID_SYMLINK_PATH));
4445
}
4546

4647
// Visible for testing
4748
static Resource buildResource(Map<String, String> environmentVariables) {
48-
return buildResource(environmentVariables, Path.of(ACCOUNT_ID_SYMLINK_PATH));
49+
return buildResource(environmentVariables, Paths.get(ACCOUNT_ID_SYMLINK_PATH));
4950
}
5051

5152
// Visible for testing

aws-resources/src/test/java/io/opentelemetry/contrib/aws/resource/LambdaResourceTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import io.opentelemetry.semconv.SchemaUrls;
2323
import java.nio.file.Files;
2424
import java.nio.file.Path;
25+
import java.nio.file.Paths;
2526
import java.util.HashMap;
2627
import java.util.Map;
2728
import java.util.ServiceLoader;
@@ -72,7 +73,7 @@ void shouldAddAllAttributes() {
7273
@Test
7374
void shouldReadCloudAccountIdFromSymlink(@TempDir Path tempDir) throws Exception {
7475
Path symlink = tempDir.resolve(".otel-account-id");
75-
Files.createSymbolicLink(symlink, Path.of("123456789012"));
76+
Files.createSymbolicLink(symlink, Paths.get("123456789012"));
7677

7778
Resource resource =
7879
LambdaResource.buildResource(
@@ -106,7 +107,7 @@ void shouldSkipCloudAccountIdWhenSymlinkMissing(@TempDir Path tempDir) {
106107
@Test
107108
void shouldPreserveLeadingZerosInAccountId(@TempDir Path tempDir) throws Exception {
108109
Path symlink = tempDir.resolve(".otel-account-id");
109-
Files.createSymbolicLink(symlink, Path.of("012345678901"));
110+
Files.createSymbolicLink(symlink, Paths.get("012345678901"));
110111

111112
Resource resource =
112113
LambdaResource.buildResource(

0 commit comments

Comments
 (0)