Skip to content

Commit 3ccd549

Browse files
author
Tilmann Zäschke
committed
Refactoring and fixes
1 parent d763dd6 commit 3ccd549

File tree

4 files changed

+9
-22
lines changed

4 files changed

+9
-22
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2222
[#13](https://github.com/netsec-ethz/scion-java-multiping/pull/13)
2323
- Fixed calculation of average and median values
2424
[#17](https://github.com/netsec-ethz/scion-java-multiping/pull/17)
25+
- Added proper tests, refactored PingAll and fixed minor issues
26+
[#18](https://github.com/netsec-ethz/scion-java-multiping/pull/18)
2527

2628
## [0.4.0] - 2025-04-04
2729

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<dependency>
8484
<groupId>org.scion</groupId>
8585
<artifactId>jpan</artifactId>
86-
<version>0.6.0-SNAPSHOT</version>
86+
<version>0.5.3</version>
8787
</dependency>
8888

8989
<dependency>

src/main/java/org/scion/multiping/PingAll.java

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -312,24 +312,12 @@ private Scmp.TracerouteMessage findFastestTRasync(List<Path> paths, Ref<Path> re
312312
new ScmpSenderAsync.ResponseHandler() {
313313
@Override
314314
public void onResponse(Scmp.TimedMessage msg) {
315-
System.out.println(
316-
"Received response for "
317-
+ ScionUtil.toStringIA(msg.getIdentifier())
318-
+ " "
319-
+ msg.getSequenceNumber());
320315
barrier.countDown();
321316
messages.put(msg.getIdentifier(), msg);
322317
}
323318

324319
@Override
325320
public void onTimeout(Scmp.TimedMessage msg) {
326-
System.out.println(
327-
"Timeout for "
328-
+ ScionUtil.toStringIA(msg.getIdentifier())
329-
+ " "
330-
+ msg.getSequenceNumber()
331-
+ " "
332-
+ msg.getPath().getRemoteAddress());
333321
barrier.countDown();
334322
messages.put(msg.getIdentifier(), msg);
335323
}
@@ -351,21 +339,18 @@ public void onException(Throwable t) {
351339
try (ScionProvider.Async sender = service.getAsync(handler)) {
352340
for (Path path : paths) {
353341
summary.incPathTried();
354-
int x = sender.sendTracerouteLast(path);
355-
System.out.println("Sending " + x + " " + ScionUtil.toStringPath(path.getRawPath()) + " to " + path.getRemoteAddress());
342+
sender.sendTracerouteLast(path);
356343
}
357-
} catch (IOException e) {
358-
println("ERROR: " + e.getMessage());
359-
summary.incAsError();
360-
return null;
361-
}
362344

363-
// Wait for all messages to be received
364-
try {
345+
// Wait for all messages to be received, BEFORE closing the "sender".
365346
if (!barrier.await(1100, TimeUnit.MILLISECONDS)) {
366347
throw new IllegalStateException(
367348
"Missing messages: " + barrier.getCount() + "/" + paths.size());
368349
}
350+
} catch (IOException e) {
351+
println("ERROR: " + e.getMessage());
352+
summary.incAsError();
353+
return null;
369354
} catch (InterruptedException e) {
370355
Thread.currentThread().interrupt();
371356
throw new IllegalStateException(e);
File renamed without changes.

0 commit comments

Comments
 (0)