Skip to content

Commit 667a598

Browse files
authored
Merge pull request #2275 from newrelic/aws-fargate-id-fix
Refactor AWS docker id fetch
2 parents 83666de + 8b4eaad commit 667a598

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

newrelic-agent/src/main/java/com/newrelic/agent/utilization/AwsFargateMetadataFetcher.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.io.InputStream;
1111
import java.net.MalformedURLException;
1212
import java.net.URL;
13+
import java.net.URLConnection;
1314

1415
/**
1516
* Thin wrapper class over the JRE URL class to assist in testing
@@ -22,6 +23,10 @@ public AwsFargateMetadataFetcher(String metadataUrl) throws MalformedURLExceptio
2223
}
2324

2425
public InputStream openStream() throws IOException {
25-
return (url == null ? null : url.openStream());
26+
URLConnection connection = url.openConnection();
27+
connection.setConnectTimeout(5000);
28+
connection.setReadTimeout(5000);
29+
30+
return connection.getInputStream();
2631
}
2732
}

0 commit comments

Comments
 (0)