Skip to content

Commit 081020b

Browse files
author
Jon Elverkilde
authored
Merge pull request #225 from pusher/remove_state_change_exception
Make a no-op state change non-fatal
2 parents 14dfcd6 + 4ae2f8e commit 081020b

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/main/java/com/pusher/client/connection/ConnectionStateChange.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package com.pusher.client.connection;
22

3+
import java.util.logging.Logger;
4+
35
/**
46
* Represents a change in connection state.
57
*/
68
public class ConnectionStateChange {
79

10+
private static final Logger log = Logger.getLogger(ConnectionStateChange.class.getName());
811
private final ConnectionState previousState;
912
private final ConnectionState currentState;
1013

@@ -18,9 +21,8 @@ public class ConnectionStateChange {
1821
public ConnectionStateChange(final ConnectionState previousState, final ConnectionState currentState) {
1922

2023
if (previousState == currentState) {
21-
throw new IllegalArgumentException(
22-
"Attempted to create an connection state update where both previous and current state are: "
23-
+ currentState);
24+
log.fine("Attempted to create an connection state update where both previous and current state are: "
25+
+ currentState);
2426
}
2527

2628
this.previousState = previousState;

src/test/java/com/pusher/client/connection/ConnectionStateChangeTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ public void testGetters() {
2020
assertSame(current, change.getCurrentState());
2121
}
2222

23-
@Test(expected = IllegalArgumentException.class)
24-
public void testFailFastIfPreviousStateIsSameAsCurrentState() {
25-
new ConnectionStateChange(ConnectionState.CONNECTED, ConnectionState.CONNECTED);
26-
}
27-
2823
@Test
2924
public void testHashCodeAndEquals() {
3025
final ConnectionStateChange instanceOne = new ConnectionStateChange(ConnectionState.DISCONNECTED,

0 commit comments

Comments
 (0)