Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
fix header control
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetyz committed Sep 19, 2023
1 parent 20e0c37 commit 24fcd09
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,27 @@ public class ChaosConfiguration {

private static final short RANDOM_EXCEPTION_RATIO = 5;

@Value("${chaos.enabled:false}")

@Value("${chaos.enabled:true}")
private boolean enabled;

private boolean isRandomException;

private final Random random = new Random();

public void setEnabled(boolean enabled) {
isRandomException = enabled;
}

public void restore() {
isRandomException = enabled;
}

public ChaosConfiguration() {
restore();
}


private static class ServerDownException extends Exception {
ServerDownException() {
super("Server is down!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ public TodoController(TodoService service, ChaosConfiguration chaosConfiguration
public void handleMap(Map<String, String> map) {
if (map.containsKey("x-chaos-inject-error") && map.get("x-chaos-inject-error").equals("true")) {
throw new RuntimeException("This error is thrown for testing purpose.");
}

if (map.containsKey("x-chaos-inject-latency") && map.get("x-chaos-inject-latency").equals("true")) {
} else if (map.containsKey("x-chaos-inject-latency") && map.get("x-chaos-inject-latency").equals("true")) {
chaosConfiguration.setEnabled(false);
try {
Thread.sleep(TEN_SECONDS_AS_MILLIS);
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
chaosConfiguration.restore();
}

}

public void checkUserAccess(Map<String, String> headers) {
Expand Down

0 comments on commit 24fcd09

Please sign in to comment.