Skip to content

Commit c1cedcb

Browse files
committed
Update EC2MetadataUtilServer to only accept localhost address
1 parent 4ad1e42 commit c1cedcb

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

core/src/it/java/software/amazon/awssdk/core/util/EC2MetadataUtilsIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class EC2MetadataUtilsIntegrationTest {
2929

3030
@BeforeClass
3131
public static void setUp() throws IOException {
32-
SERVER = new EC2MetadataUtilsServer("localhost", 0);
32+
SERVER = new EC2MetadataUtilsServer( 0);
3333
SERVER.start();
3434

3535
System.setProperty(AwsSystemSetting.AWS_EC2_METADATA_SERVICE_ENDPOINT.property(),

core/src/test/java/software/amazon/awssdk/core/regions/providers/InstanceProfileRegionProviderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static class MetadataServiceRunningTest {
4747

4848
@BeforeClass
4949
public static void setupFixture() throws IOException {
50-
server = new EC2MetadataUtilsServer("localhost", 0);
50+
server = new EC2MetadataUtilsServer(0);
5151
server.start();
5252

5353
System.setProperty(AwsSystemSetting.AWS_EC2_METADATA_SERVICE_ENDPOINT.property(),

core/src/test/java/software/amazon/awssdk/core/util/EC2MetadataUtilsServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public class EC2MetadataUtilsServer {
3333

3434
private ServerSocket server;
3535

36-
public EC2MetadataUtilsServer(String address, int port)
36+
public EC2MetadataUtilsServer(int port)
3737
throws UnknownHostException, IOException {
38-
server = new ServerSocket(port, 1, InetAddress.getByName(address));
38+
server = new ServerSocket(port, 1, InetAddress.getLoopbackAddress());
3939
}
4040

4141
public void start()

0 commit comments

Comments
 (0)