Skip to content
This repository was archived by the owner on May 6, 2022. It is now read-only.

Commit 4d70401

Browse files
committed
Handle SocketTimeoutException
1 parent d0f67c6 commit 4d70401

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ddiclient-core/src/main/java/com/kynetics/updatefactory/ddiclient/core/model/state/AbstractCommunicationState.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import com.kynetics.updatefactory.ddiclient.core.model.event.ErrorEvent;
1515
import com.kynetics.updatefactory.ddiclient.core.model.event.FailureEvent;
1616

17+
import java.net.SocketTimeoutException;
18+
1719
import static com.kynetics.updatefactory.ddiclient.core.model.state.AbstractState.StateName.UPDATE_DOWNLOAD;
1820

1921
/**
@@ -44,7 +46,8 @@ public AbstractState onEvent(AbstractEvent event) {
4446
return attemptsRemaining == 0 ? new WaitingState(0, this) : getStateOnError(errorEvent, getState(), attemptsRemaining - 1);
4547
case FAILURE:
4648
FailureEvent failureEvent = (FailureEvent) event;
47-
return attemptsRemaining == 0 ? new WaitingState(0, this) : new CommunicationFailureState(getState(), attemptsRemaining - 1, failureEvent.getThrowable());
49+
int newAttemptsRemaining = failureEvent.getThrowable() instanceof SocketTimeoutException ? attemptsRemaining : attemptsRemaining - 1;
50+
return newAttemptsRemaining < 0 ? new WaitingState(0, this) : new CommunicationFailureState(getState(), newAttemptsRemaining, failureEvent.getThrowable());
4851
default:
4952
return getState().onEvent(event);
5053
}

0 commit comments

Comments
 (0)