1717
1818public class MockedProfilerSettingsServlet extends HttpServlet {
1919
20- private static final Map <ProfilerState , String > CONFIGS ;
21-
22- static {
20+ private static Map <ProfilerState , String > getConfigs () {
2321 String now =
2422 DateTimeFormatter .ISO_OFFSET_DATE_TIME .format (OffsetDateTime .now (ZoneOffset .ofHours (0 )));
2523
26- CONFIGS = new HashMap <>();
24+ Map < ProfilerState , String > configs = new HashMap <>();
2725
28- CONFIGS .put (
26+ configs .put (
2927 ProfilerState .unconfigured ,
3028 "{\n "
3129 + " \" agentConcurrency\" : 0,\n "
@@ -39,7 +37,7 @@ public class MockedProfilerSettingsServlet extends HttpServlet {
3937 + " \" memoryTriggerConfiguration\" : \" --memory-threshold 80 --memory-trigger-profilingDuration 120 --memory-trigger-cooldown 14400 --memory-trigger-enabled true\" \n "
4038 + "}\n " );
4139
42- CONFIGS .put (
40+ configs .put (
4341 ProfilerState .configuredEnabled ,
4442 "{\n "
4543 + " \" agentConcurrency\" : 0,\n "
@@ -57,7 +55,7 @@ public class MockedProfilerSettingsServlet extends HttpServlet {
5755 + " \" memoryTriggerConfiguration\" : \" --memory-threshold 80 --memory-trigger-profilingDuration 120 --memory-trigger-cooldown 14400 --memory-trigger-enabled true\" \n "
5856 + "}\n " );
5957
60- CONFIGS .put (
58+ configs .put (
6159 ProfilerState .configuredDisabled ,
6260 "{\n "
6361 + " \" agentConcurrency\" : 0,\n "
@@ -77,7 +75,7 @@ public class MockedProfilerSettingsServlet extends HttpServlet {
7775
7876 long expire = toSeconds (Instant .now ().plusSeconds (100 ));
7977
80- CONFIGS .put (
78+ configs .put (
8179 ProfilerState .manualprofile ,
8280 "{\n "
8381 + " \" agentConcurrency\" : 0,\n "
@@ -96,6 +94,8 @@ public class MockedProfilerSettingsServlet extends HttpServlet {
9694 + "\" ,\n "
9795 + " \" memoryTriggerConfiguration\" : \" --memory-threshold 80 --memory-trigger-profilingDuration 120 --memory-trigger-cooldown 14400 --memory-trigger-enabled true\" \n "
9896 + "}\n " );
97+
98+ return configs ;
9999 }
100100
101101 private static long toSeconds (Instant time ) {
@@ -105,8 +105,9 @@ private static long toSeconds(Instant time) {
105105
106106 @ Override
107107 protected void doGet (HttpServletRequest req , HttpServletResponse resp ) throws IOException {
108+ Map <ProfilerState , String > configs = getConfigs ();
108109 Optional <Map .Entry <ProfilerState , String >> entry =
109- CONFIGS .entrySet ().stream ()
110+ configs .entrySet ().stream ()
110111 .filter (
111112 it ->
112113 ("/" + it .getKey ().name () + "/api/profileragent/v4/settings" )
0 commit comments