Skip to content

Commit

Permalink
displayErrors
Browse files Browse the repository at this point in the history
  • Loading branch information
leleuj committed Nov 23, 2023
1 parent 8f3b454 commit b577e23
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
13 changes: 13 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@
<release>${java.version}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.casinthecloud.simpleperf.execution;

import com.casinthecloud.simpleperf.test.BaseTest;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.val;

import java.util.concurrent.atomic.AtomicInteger;
Expand All @@ -23,6 +25,10 @@ public class Execution {

private final Supplier<BaseTest> supplierTest;

@Getter
@Setter
private boolean displayErrors;

public void launch() throws Exception {
val time = new AtomicLong(0);
val completed = new AtomicInteger(0);
Expand All @@ -43,7 +49,7 @@ public void launch() throws Exception {
for (var i = 0; i < nbThreads; i++) {
val test = supplierTest.get();
test.setTime(time);
val t = new ExecutionThread(i, nbIterationsPerThread, test, completed);
val t = new ExecutionThread(i, nbIterationsPerThread, test, completed, displayErrors);
t.start();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class ExecutionThread extends Thread {

private final AtomicInteger completed;

private final boolean displayErrors;

@Override
public void run() {
val client = HttpClient.newBuilder()
Expand All @@ -50,7 +52,11 @@ public void run() {
}
nbError = 0;
} catch (final Exception e) {
System.out.print("!");
if (displayErrors) {
e.printStackTrace();
} else {
System.out.print("!");
}
nbError++;
if (maxErrors != -1 && nbError > maxErrors) {
stopError = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ protected String addUrlParameter(final String url, final String key, final Strin

protected void assertStatus(final int s) {
if (_response.statusCode() != s) {
throw new IllegalStateException("Expected HTTP " + s);
throw new IllegalStateException("Expected HTTP " + s + " / Received: " + _response.statusCode());
}
}
}

0 comments on commit b577e23

Please sign in to comment.