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

fix #294: ApnsConnectionImpl.monitorSocket() closes invalid socket. #295

Merged
merged 1 commit into from Dec 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/main/java/com/notnoop/apns/internal/ApnsConnectionImpl.java
Expand Up @@ -132,8 +132,8 @@ public synchronized void close() {
Utilities.close(socket);
}

private void monitorSocket(final Socket socket) {
logger.debug("Launching Monitoring Thread for socket {}", socket);
private void monitorSocket(final Socket socketToMonitor) {
logger.debug("Launching Monitoring Thread for socket {}", socketToMonitor);

Thread t = threadFactory.newThread(new Runnable() {
final static int EXPECTED_SIZE = 6;
Expand All @@ -145,7 +145,7 @@ public void run() {
try {
InputStream in;
try {
in = socket.getInputStream();
in = socketToMonitor.getInputStream();
} catch (IOException ioe) {
in = null;
}
Expand All @@ -155,7 +155,7 @@ public void run() {
logger.debug("Error-response packet {}", Utilities.encodeHex(bytes));
// Quickly close socket, so we won't ever try to send push notifications
// using the defective socket.
Utilities.close(socket);
Utilities.close(socketToMonitor);

int command = bytes[0] & 0xFF;
if (command != 8) {
Expand Down Expand Up @@ -221,7 +221,7 @@ public void run() {
logger.info("Exception while waiting for error code", e);
delegate.connectionClosed(DeliveryError.UNKNOWN, -1);
} finally {
close();
Utilities.close(socketToMonitor);
drainBuffer();
}
}
Expand Down