package io.tus.java.client;

import java.io.IOException;
import java.net.HttpURLConnection;

/**
 * This exception is thrown if the server sends a request with an unexpected status code or
 * missing/invalid headers.
 */
public class ProtocolException extends Exception {
    private HttpURLConnection connection;

    public ProtocolException(String message) {
        super(message);
    }

    public ProtocolException(String message, HttpURLConnection connection) {
        super(message);
        this.connection = connection;
    }

    public HttpURLConnection getCausingConnection() {
        return connection;
    }

    public boolean shouldRetry() {
        if(connection == null) {
            return false;
        }

        try {
            int responseCode = connection.getResponseCode();

            return responseCode >= 500 && responseCode < 600 || responseCode == 423;
        } catch(IOException e) {
            return false;
        }
    }
}

@@ -801,16 +801,91 @@
 ode();%0A%0A
+            // 5XX and 423 Resource Locked status codes should be retried.%0A
         
@@ -895,16 +895,17 @@
  return 
+(
 response
@@ -937,16 +937,17 @@
 de %3C 600
+)
  %7C%7C resp

Add explaination to selection of retrying status codes