Skip to content

Commit 180a190

Browse files
authored
Merge pull request #295 from tmurakam/feature/fix-monitor-close
fix #294: ApnsConnectionImpl.monitorSocket() closes invalid socket.
2 parents a7d1e9f + 45dc3be commit 180a190

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

+5-5
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
logger.warn("The value of socket is null", ioe);
151151
in = null;
@@ -156,7 +156,7 @@ public void run() {
156156
logger.debug("Error-response packet {}", Utilities.encodeHex(bytes));
157157
// Quickly close socket, so we won't ever try to send push notifications
158158
// using the defective socket.
159-
Utilities.close(socket);
159+
Utilities.close(socketToMonitor);
160160

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

0 commit comments

Comments
 (0)