-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
64 additions
and
9 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
27 changes: 27 additions & 0 deletions
27
...traps/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/config/DisableOptions.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,27 @@ | ||
package com.navercorp.pinpoint.bootstrap.config; | ||
|
||
import java.util.function.Function; | ||
|
||
public class DisableOptions { | ||
public static final String SYSTEM = "pinpoint.disable"; | ||
public static final String ENV = "PINPOINT_DISABLE"; | ||
public static final String CONFIG = SYSTEM; | ||
|
||
private DisableOptions() { | ||
} | ||
|
||
public static boolean isBootDisabled() { | ||
if (isDisabled(System::getProperty, SYSTEM)) { | ||
return true; | ||
} | ||
if (isDisabled(System::getenv, ENV)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public static boolean isDisabled(Function<String, String> properties, String key) { | ||
String value = properties.apply(key); | ||
return Boolean.parseBoolean(value); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...s/bootstrap/src/test/java/com/navercorp/pinpoint/bootstrap/config/DisableOptionsTest.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,33 @@ | ||
package com.navercorp.pinpoint.bootstrap.config; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Properties; | ||
|
||
class DisableOptionsTest { | ||
|
||
@AfterEach | ||
void afterEach() { | ||
Properties properties = System.getProperties(); | ||
properties.remove(DisableOptions.SYSTEM); | ||
} | ||
|
||
@Test | ||
void isBootDisabled() { | ||
Properties properties = System.getProperties(); | ||
properties.setProperty(DisableOptions.SYSTEM, "true"); | ||
|
||
Assertions.assertTrue(DisableOptions.isBootDisabled()); | ||
} | ||
|
||
@Test | ||
void isBootDisabled_true() { | ||
Properties properties = System.getProperties(); | ||
properties.setProperty(DisableOptions.SYSTEM, "false"); | ||
|
||
Assertions.assertFalse(DisableOptions.isBootDisabled()); | ||
} | ||
|
||
} |