@Test public void shouldSendStoredExceptionsOnce() throws InterruptedException { handler.enabled = true; handler.hasStoredExceptions = true; RaygunMessage message = mock(RaygunMessage.class); when(storage.listFiles((FilenameFilter) anyObject())).thenReturn(new File[0]); handler.storage = storage; assertThat(handler.onBeforeSend(client, message), is(message)); Thread.sleep(200); verify(storage, times(2)).listFiles((FilenameFilter) anyObject()); assertThat(handler.onBeforeSend(client, message), is(message)); Thread.sleep(200); verify(storage, times(2)).listFiles((FilenameFilter) anyObject()); }
public RaygunMessage onBeforeSend(RaygunClient client, RaygunMessage message) { if (enabled && hasStoredExceptions && sendingStoredExceptions == null) { synchronized (this) { if (sendingStoredExceptions == null) { sendingStoredExceptions = new RaygunSendStoredExceptions(client, this.getStorage(this.storageDir)); new Thread(new Runnable() { public void run() { sendingStoredExceptions.run(); sendingStoredExceptions = null; hasStoredExceptions = false; } }).start(); } } } return message; }
RaygunOnFailedSendOfflineStorageHandler implements IRaygunOnFailedSend, IRaygunOnBeforeSend, IRaygunSendEventFactory { public RaygunMessage onBeforeSend(RaygunClient client, RaygunMessage message) { if (enabled && hasStoredExceptions && sendingStoredExceptions == null) { synchronized (this) { if (sendingStoredExceptions == null) { sendingStoredExceptions = new RaygunSendStoredExceptions(client, this.getStorage(this.storageDir)); new Thread(new Runnable() { public void run() { sendingStoredExceptions.run(); sendingStoredExceptions = null; hasStoredExceptions = false; } }).start(); } } } return message; } }
RaygunOnFailedSendOfflineStorageHandler implements IRaygunOnFailedSend, IRaygunOnBeforeSend, IRaygunSendEventFactory { public RaygunMessage onBeforeSend(RaygunClient client, RaygunMessage message) { if (enabled && hasStoredExceptions && sendingStoredExceptions == null) { synchronized (this) { if (sendingStoredExceptions == null) { sendingStoredExceptions = new RaygunSendStoredExceptions(client, this.getStorage(this.storageDir)); new Thread(new Runnable() { public void run() { sendingStoredExceptions.run(); sendingStoredExceptions = null; hasStoredExceptions = false; } }).start(); } } } return message; } RaygunOnFailedSendOfflineStorageHandler(String storageDir, String apiKey); }
RaygunOnFailedSendOfflineStorageHandler implements IRaygunOnFailedSend, IRaygunOnBeforeSend, IRaygunSendEventFactory { public RaygunMessage onBeforeSend(RaygunClient client, RaygunMessage message) { if (enabled && hasStoredExceptions && sendingStoredExceptions == null) { synchronized (this) { if (sendingStoredExceptions == null) { sendingStoredExceptions = new RaygunSendStoredExceptions(client, this.getStorage(this.storageDir)); new Thread(new Runnable() { public void run() { sendingStoredExceptions.run(); sendingStoredExceptions = null; hasStoredExceptions = false; } }).start(); } } } return message; } RaygunOnFailedSendOfflineStorageHandler(String storageDir, String apiKey); void setEnabled(boolean enabled); RaygunMessage onBeforeSend(RaygunClient client, RaygunMessage message); String onFailedSend(RaygunClient client, String jsonPayload); IRaygunOnBeforeSend create(); }
RaygunOnFailedSendOfflineStorageHandler implements IRaygunOnFailedSend, IRaygunOnBeforeSend, IRaygunSendEventFactory { public RaygunMessage onBeforeSend(RaygunClient client, RaygunMessage message) { if (enabled && hasStoredExceptions && sendingStoredExceptions == null) { synchronized (this) { if (sendingStoredExceptions == null) { sendingStoredExceptions = new RaygunSendStoredExceptions(client, this.getStorage(this.storageDir)); new Thread(new Runnable() { public void run() { sendingStoredExceptions.run(); sendingStoredExceptions = null; hasStoredExceptions = false; } }).start(); } } } return message; } RaygunOnFailedSendOfflineStorageHandler(String storageDir, String apiKey); void setEnabled(boolean enabled); RaygunMessage onBeforeSend(RaygunClient client, RaygunMessage message); String onFailedSend(RaygunClient client, String jsonPayload); IRaygunOnBeforeSend create();  }