Skip to content

Commit 45dc3be

Browse files
committed
fix #294: ApnsConnectionImpl.monitorSocket() closes invalid socket.
1 parent 4c0bc5e commit 45dc3be

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/java/com/notnoop/apns/internal/ApnsConnectionImpl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ public synchronized void close() {
132132
Utilities.close(socket);
133133
}
134134

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

138138
Thread t = threadFactory.newThread(new Runnable() {
139139
final static int EXPECTED_SIZE = 6;
@@ -145,7 +145,7 @@ public void run() {
145145
try {
146146
InputStream in;
147147
try {
148-
in = socket.getInputStream();
148+
in = socketToMonitor.getInputStream();
149149
} catch (IOException ioe) {
150150
in = null;
151151
}
@@ -155,7 +155,7 @@ public void run() {
155155
logger.debug("Error-response packet {}", Utilities.encodeHex(bytes));
156156
// Quickly close socket, so we won't ever try to send push notifications
157157
// using the defective socket.
158-
Utilities.close(socket);
158+
Utilities.close(socketToMonitor);
159159

160160
int command = bytes[0] & 0xFF;
161161
if (command != 8) {
@@ -221,7 +221,7 @@ public void run() {
221221
logger.info("Exception while waiting for error code", e);
222222
delegate.connectionClosed(DeliveryError.UNKNOWN, -1);
223223
} finally {
224-
close();
224+
Utilities.close(socketToMonitor);
225225
drainBuffer();
226226
}
227227
}

0 commit comments

Comments
 (0)