DefaultErrorAnalyzer.java

1
package fr.sii.ogham.sms.sender.impl.cloudhopper.session;
2
3
import java.nio.channels.ClosedChannelException;
4
5
import com.cloudhopper.smpp.pdu.EnquireLink;
6
import com.cloudhopper.smpp.type.SmppChannelException;
7
import com.cloudhopper.smpp.type.SmppTimeoutException;
8
import com.cloudhopper.smpp.type.UnrecoverablePduException;
9
10
import fr.sii.ogham.sms.sender.impl.cloudhopper.exception.KeepAliveException;
11
import fr.sii.ogham.sms.sender.impl.cloudhopper.exception.SmppException;
12
13
/**
14
 * Default error analyzer that indicates to use a new session in the following
15
 * cases:
16
 * <ul>
17
 * <li>{@link KeepSessionAliveStrategy} is used for session handling and several
18
 * (configurable) {@link EnquireLink} requests have failed due to a timeout</li>
19
 * <li>The connection has been closed by the server</li>
20
 * <li>The error is unrecoverable (see {@link UnrecoverablePduException}</li>
21
 * </ul>
22
 * 
23
 * <p>
24
 * This class can be extended if additional checks are needed.
25
 * 
26
 * @author Aurélien Baudet
27
 *
28
 */
29
public class DefaultErrorAnalyzer implements ErrorAnalyzer {
30
	private final int maxConsecutiveTimeouts;
31
32
	public DefaultErrorAnalyzer(int maxConsecutiveTimeouts) {
33
		super();
34
		this.maxConsecutiveTimeouts = maxConsecutiveTimeouts;
35
	}
36
37
	@Override
38
	public boolean requiresNewConnection(Throwable failure) {
39 1 1. requiresNewConnection : negated conditional → NO_COVERAGE
		if (failure == null) {
40 1 1. requiresNewConnection : replaced boolean return with true for fr/sii/ogham/sms/sender/impl/cloudhopper/session/DefaultErrorAnalyzer::requiresNewConnection → NO_COVERAGE
			return false;
41
		}
42 1 1. requiresNewConnection : negated conditional → NO_COVERAGE
		if (tooManyEnquireLinkTimeouts(failure)) {
43 1 1. requiresNewConnection : replaced boolean return with false for fr/sii/ogham/sms/sender/impl/cloudhopper/session/DefaultErrorAnalyzer::requiresNewConnection → NO_COVERAGE
			return true;
44
		}
45 1 1. requiresNewConnection : negated conditional → NO_COVERAGE
		if (failure instanceof SmppException) {
46 2 1. requiresNewConnection : replaced boolean return with true for fr/sii/ogham/sms/sender/impl/cloudhopper/session/DefaultErrorAnalyzer::requiresNewConnection → NO_COVERAGE
2. requiresNewConnection : replaced boolean return with false for fr/sii/ogham/sms/sender/impl/cloudhopper/session/DefaultErrorAnalyzer::requiresNewConnection → NO_COVERAGE
			return requiresNewConnection(failure.getCause());
47
		}
48 3 1. requiresNewConnection : negated conditional → NO_COVERAGE
2. requiresNewConnection : negated conditional → NO_COVERAGE
3. requiresNewConnection : replaced boolean return with true for fr/sii/ogham/sms/sender/impl/cloudhopper/session/DefaultErrorAnalyzer::requiresNewConnection → NO_COVERAGE
		return connectionClosed(failure) || isUnrecoverableError(failure);
49
	}
50
51
	protected boolean tooManyEnquireLinkTimeouts(Throwable failure) {
52 2 1. tooManyEnquireLinkTimeouts : replaced boolean return with true for fr/sii/ogham/sms/sender/impl/cloudhopper/session/DefaultErrorAnalyzer::tooManyEnquireLinkTimeouts → NO_COVERAGE
2. tooManyEnquireLinkTimeouts : negated conditional → NO_COVERAGE
		return failure instanceof KeepAliveException 
53 1 1. tooManyEnquireLinkTimeouts : negated conditional → NO_COVERAGE
				&& failure.getCause() instanceof SmppTimeoutException 
54 2 1. tooManyEnquireLinkTimeouts : negated conditional → NO_COVERAGE
2. tooManyEnquireLinkTimeouts : changed conditional boundary → NO_COVERAGE
				&& ((KeepAliveException) failure).getConsecutiveFailures() >= maxConsecutiveTimeouts;
55
	}
56
57
	protected boolean connectionClosed(Throwable failure) {
58 3 1. connectionClosed : replaced boolean return with true for fr/sii/ogham/sms/sender/impl/cloudhopper/session/DefaultErrorAnalyzer::connectionClosed → NO_COVERAGE
2. connectionClosed : negated conditional → NO_COVERAGE
3. connectionClosed : negated conditional → NO_COVERAGE
		return failure instanceof ClosedChannelException || failure instanceof SmppChannelException;
59
	}
60
61
	protected boolean isUnrecoverableError(Throwable failure) {
62 2 1. isUnrecoverableError : replaced boolean return with true for fr/sii/ogham/sms/sender/impl/cloudhopper/session/DefaultErrorAnalyzer::isUnrecoverableError → NO_COVERAGE
2. isUnrecoverableError : replaced boolean return with false for fr/sii/ogham/sms/sender/impl/cloudhopper/session/DefaultErrorAnalyzer::isUnrecoverableError → NO_COVERAGE
		return failure instanceof UnrecoverablePduException;
63
	}
64
}

Mutations

39

1.1
Location : requiresNewConnection
Killed by :
negated conditional → NO_COVERAGE

40

1.1
Location : requiresNewConnection
Killed by :
replaced boolean return with true for fr/sii/ogham/sms/sender/impl/cloudhopper/session/DefaultErrorAnalyzer::requiresNewConnection → NO_COVERAGE

42

1.1
Location : requiresNewConnection
Killed by :
negated conditional → NO_COVERAGE

43

1.1
Location : requiresNewConnection
Killed by :
replaced boolean return with false for fr/sii/ogham/sms/sender/impl/cloudhopper/session/DefaultErrorAnalyzer::requiresNewConnection → NO_COVERAGE

45

1.1
Location : requiresNewConnection
Killed by :
negated conditional → NO_COVERAGE

46

1.1
Location : requiresNewConnection
Killed by :
replaced boolean return with true for fr/sii/ogham/sms/sender/impl/cloudhopper/session/DefaultErrorAnalyzer::requiresNewConnection → NO_COVERAGE

2.2
Location : requiresNewConnection
Killed by :
replaced boolean return with false for fr/sii/ogham/sms/sender/impl/cloudhopper/session/DefaultErrorAnalyzer::requiresNewConnection → NO_COVERAGE

48

1.1
Location : requiresNewConnection
Killed by :
negated conditional → NO_COVERAGE

2.2
Location : requiresNewConnection
Killed by :
negated conditional → NO_COVERAGE

3.3
Location : requiresNewConnection
Killed by :
replaced boolean return with true for fr/sii/ogham/sms/sender/impl/cloudhopper/session/DefaultErrorAnalyzer::requiresNewConnection → NO_COVERAGE

52

1.1
Location : tooManyEnquireLinkTimeouts
Killed by :
replaced boolean return with true for fr/sii/ogham/sms/sender/impl/cloudhopper/session/DefaultErrorAnalyzer::tooManyEnquireLinkTimeouts → NO_COVERAGE

2.2
Location : tooManyEnquireLinkTimeouts
Killed by :
negated conditional → NO_COVERAGE

53

1.1
Location : tooManyEnquireLinkTimeouts
Killed by :
negated conditional → NO_COVERAGE

54

1.1
Location : tooManyEnquireLinkTimeouts
Killed by :
negated conditional → NO_COVERAGE

2.2
Location : tooManyEnquireLinkTimeouts
Killed by :
changed conditional boundary → NO_COVERAGE

58

1.1
Location : connectionClosed
Killed by :
replaced boolean return with true for fr/sii/ogham/sms/sender/impl/cloudhopper/session/DefaultErrorAnalyzer::connectionClosed → NO_COVERAGE

2.2
Location : connectionClosed
Killed by :
negated conditional → NO_COVERAGE

3.3
Location : connectionClosed
Killed by :
negated conditional → NO_COVERAGE

62

1.1
Location : isUnrecoverableError
Killed by :
replaced boolean return with true for fr/sii/ogham/sms/sender/impl/cloudhopper/session/DefaultErrorAnalyzer::isUnrecoverableError → NO_COVERAGE

2.2
Location : isUnrecoverableError
Killed by :
replaced boolean return with false for fr/sii/ogham/sms/sender/impl/cloudhopper/session/DefaultErrorAnalyzer::isUnrecoverableError → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.13.1