Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection failure listener (fixes #32) #51

Merged
merged 26 commits into from
Mar 26, 2014

Conversation

jchambers
Copy link
Owner

This change introduces the FailedConnectionListener interface. Applications using Pushy can register connection failure listeners to watch for connection failures that are unlikely to be resolved by future reconnection attempts (i.e. SSLHandshakeExceptions) and respond accordingly. There are a couple other changes rolled up in here, too:

  1. Add a PushManager argument for rejected notification listeners, so listeners associated with multiple push managers can tell which one had the rejection.
  2. Made the push manager's listener ExecutorService externally-configurable; failed connection listeners and rejected notification listeners will be called by tasks from that service.

@jchambers jchambers mentioned this pull request Feb 17, 2014
4 tasks
* @param pushManager the push manager that failed to open a connection
* @param cause the cause for the connection failure
*/
void handleFailedConnection(PushManager<? extends T> pushManager, Throwable cause);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not PushManager<T> pushManager since T is only defined as extending ApnsPushNotification ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, let's say you have the following push notification subclasses:

  • FancyApnsPushNotification extends SimpleApnsPushNotification
  • ShinyApnsPushNotification extends SimpleApnsPushNotification

You might have two PushManager instances in your app, each with one of those two push notification subclasses. You could then use a single listener typed for the base class to listen for failures on both push managers. It might look something like this:

public class MyFailedConnectionListener implements FailedConnectionListener<SimpleApnsPushNotification> {

    public void handleFailedConnection(final PushManager<? extends SimpleApnsPushNotification> pushManager, final Throwable cause) {
        // …
    }
}

That would work because both push managers would be typed to subclasses of SimpleApnsPushNotification, and thus would match PushManager<? extends SimpleApnsPushNotification>. If we just did <T> for the push manager argument, we'd have to match the type exactly and would lose some flexibility. Does that make any sense?

Conflicts:
	src/main/java/com/relayrides/pushy/apns/PushManager.java
	src/test/java/com/relayrides/pushy/apns/PushManagerTest.java
@jchambers jchambers added this to the v0.3 milestone Feb 26, 2014
Conflicts:
	src/main/java/com/relayrides/pushy/apns/PushManager.java
@shawnfeldman
Copy link

We are having issues where if one of our clients uploads a bad cert pushy will continually try to reconnect, will this PR be merged at some point?

@jchambers
Copy link
Owner Author

…will this PR be merged at some point?

Yes. We have a couple high-priority things to resolve this week, but reviewing/shipping v0.3 (this included) is high on the to-do list.

Conflicts:
	src/main/java/com/relayrides/pushy/apns/PushManager.java
@romanzadov
Copy link

👍 still looks good

jchambers added a commit that referenced this pull request Mar 26, 2014
@jchambers jchambers merged commit 035300b into threadless_connections Mar 26, 2014
@jchambers jchambers deleted the connection_failure_listener branch April 3, 2014 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants