Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…6/pull/5/files - should clean up a memory leak
  • Loading branch information
mlaccetti committed Jul 12, 2016
1 parent 51f7809 commit be42077
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/java/javapns/Push.java
Expand Up @@ -211,16 +211,21 @@ public static PushedNotifications payload(final Payload payload, final Object ke
if (numberOfThreads <= 0) {
return sendPayload(payload, keystore, password, production, devices);
}

final AppleNotificationServer server = new AppleNotificationServerBasicImpl(keystore, password, production);
final List<Device> deviceList = Devices.asDevices(devices);
final NotificationThreads threads = new NotificationThreads(server, payload, deviceList, numberOfThreads);
threads.start();

try {
threads.waitForAllThreads(true);
} catch (final InterruptedException e) {
logger.error(e.getMessage(), e);
}
return threads.getPushedNotifications();

final PushedNotifications notifications = threads.getPushedNotifications();
threads.destroy();
return notifications;
}

/**
Expand Down Expand Up @@ -271,16 +276,21 @@ public static PushedNotifications payloads(final Object keystore, final String p
if (numberOfThreads <= 0) {
return sendPayloads(keystore, password, production, payloadDevicePairs);
}

final AppleNotificationServer server = new AppleNotificationServerBasicImpl(keystore, password, production);
final List<PayloadPerDevice> payloadPerDevicePairs = Devices.asPayloadsPerDevices(payloadDevicePairs);
final NotificationThreads threads = new NotificationThreads(server, payloadPerDevicePairs, numberOfThreads);
threads.start();

try {
threads.waitForAllThreads(true);
} catch (final InterruptedException e) {
logger.error(e.getMessage(), e);
}
return threads.getPushedNotifications();

final PushedNotifications notifications = threads.getPushedNotifications();
threads.destroy();
return notifications;
}

/**
Expand Down

0 comments on commit be42077

Please sign in to comment.