Skip to content

Commit 2192fa4

Browse files
committed
Propagate the exception thrown from the callback
Signed-off-by: Rafael Luis Ibasco <[email protected]>
1 parent d759ecb commit 2192fa4

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

examples/src/main/resources/logback.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,4 @@
9191

9292
<logger name="io.netty" level="error"/>
9393
<logger name="com.ibasco" level="error"/>
94-
<logger name="org.jline" level="debug"/>
9594
</configuration>

protocols/valve/steam/master/src/main/java/com/ibasco/agql/protocols/valve/steam/master/MasterServerMessenger.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@
5454
import java.time.Duration;
5555
import java.util.HashSet;
5656
import java.util.Set;
57+
import java.util.concurrent.CancellationException;
5758
import java.util.concurrent.CompletableFuture;
5859
import java.util.concurrent.CompletionException;
60+
import java.util.concurrent.RejectedExecutionException;
5961
import java.util.concurrent.ScheduledExecutorService;
6062
import java.util.concurrent.TimeUnit;
6163
import java.util.concurrent.atomic.AtomicReference;
@@ -106,6 +108,9 @@ private void initFailSafe(final Options options, final ScheduledExecutorService
106108
return new MasterServerResponse(new HashSet<>(timeoutException.getAddresses()));
107109
}
108110
return new MasterServerResponse(new HashSet<>());
111+
}).handleIf(p -> {
112+
Throwable cause = Errors.unwrap(p);
113+
return !(cause instanceof CancellationException) && !(cause instanceof InterruptedException) && !(cause instanceof RejectedExecutionException);
109114
}).build();
110115

111116
//retry policy
@@ -130,6 +135,10 @@ private void initFailSafe(final Options options, final ScheduledExecutorService
130135

131136
private RetryPolicy<MasterServerResponse> buildRetryPolicy(final Options options) {
132137
RetryPolicyBuilder<MasterServerResponse> builder = FailsafeBuilder.buildRetryPolicy(FailsafeOptions.class, options);
138+
builder.abortOn(p -> {
139+
Throwable error = Errors.unwrap(p);
140+
return (error instanceof CancellationException) || (error instanceof RejectedExecutionException) || (error instanceof InterruptedException);
141+
});
133142
return builder.build();
134143
}
135144

protocols/valve/steam/master/src/main/java/com/ibasco/agql/protocols/valve/steam/master/handlers/MasterServerAddressDecoder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ protected Object decodeMessage(ChannelHandlerContext ctx, AbstractRequest reques
7171
if (masterRequest.getCallback() != null && fullSet.add(address)) {
7272
partialSet.add(address);
7373
try {
74-
masterRequest.getCallback().accept(address, envelope.recipient(), null);
74+
if (context.isValid())
75+
masterRequest.getCallback().accept(address, envelope.recipient(), null);
7576
} catch (Exception e) {
7677
error("Error thrown by the callback", e);
78+
throw e;
7779
}
7880
}
7981
return null;

0 commit comments

Comments
 (0)