This repository was archived by the owner on May 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +17
-7
lines changed
src/main/java/com/launchdarkly/client Expand file tree Collapse file tree 4 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -390,7 +390,10 @@ private void handleResponse(Response response) {
390390 }
391391 if (!isHttpErrorRecoverable (response .code ())) {
392392 disabled .set (true );
393- logger .error (httpErrorMessage (response .code (), "posting events" ));
393+ logger .error (httpErrorMessage (response .code (), "posting events" , "some events were dropped" ));
394+ // It's "some events were dropped" because we're not going to retry *this* request any more times -
395+ // we only get to this point if we have used up our retry attempts. So the last batch of events was
396+ // lost, even though we will still try to post *other* events in the future.
394397 }
395398 }
396399 }
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ public void run() {
6464 initFuture .set (null );
6565 }
6666 } catch (HttpErrorException e ) {
67- logger .error (httpErrorMessage (e .getStatus (), "polling request" ));
67+ logger .error (httpErrorMessage (e .getStatus (), "polling request" , "will retry" ));
6868 if (!isHttpErrorRecoverable (e .getStatus ())) {
6969 scheduler .shutdown ();
7070 initFuture .set (null ); // if client is initializing, make it stop waiting; has no effect if already inited
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ public Future<Void> start() {
6969 public Action onConnectionError (Throwable t ) {
7070 if (t instanceof UnsuccessfulResponseException ) {
7171 int status = ((UnsuccessfulResponseException )t ).getCode ();
72- logger .error (httpErrorMessage (status , "streaming connection" ));
72+ logger .error (httpErrorMessage (status , "streaming connection" , "will retry" ));
7373 if (!isHttpErrorRecoverable (status )) {
7474 initFuture .set (null ); // if client is initializing, make it stop waiting; has no effect if already inited
7575 return Action .SHUTDOWN ;
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ static Request.Builder getRequestBuilder(String sdkKey) {
3535
3636 /**
3737 * Tests whether an HTTP error status represents a condition that might resolve on its own if we retry.
38- * @param statusCode
38+ * @param statusCode the HTTP status
3939 * @return true if retrying makes sense; false if it should be considered a permanent failure
4040 */
4141 static boolean isHttpErrorRecoverable (int statusCode ) {
@@ -51,16 +51,23 @@ static boolean isHttpErrorRecoverable(int statusCode) {
5151 return true ;
5252 }
5353
54- static String httpErrorMessage (int statusCode , String context ) {
54+ /**
55+ * Builds an appropriate log message for an HTTP error status.
56+ * @param statusCode the HTTP status
57+ * @param context description of what we were trying to do
58+ * @param recoverableMessage description of our behavior if the error is recoverable; typically "will retry"
59+ * @return a message string
60+ */
61+ static String httpErrorMessage (int statusCode , String context , String recoverableMessage ) {
5562 StringBuilder sb = new StringBuilder ();
5663 sb .append ("Received HTTP error " ).append (statusCode );
5764 switch (statusCode ) {
5865 case 401 :
5966 case 403 :
6067 sb .append (" (invalid SDK key)" );
6168 }
62- sb .append (" for " ).append (context );
63- sb .append (isHttpErrorRecoverable (statusCode ) ? " - will retry " : " - will not retry " );
69+ sb .append (" for " ).append (context ). append ( " - " ) ;
70+ sb .append (isHttpErrorRecoverable (statusCode ) ? recoverableMessage : "giving up permanently " );
6471 return sb .toString ();
6572 }
6673}
You can’t perform that action at this time.
0 commit comments