Cleanup logging
This commit is contained in:
parent
3bafdd7de1
commit
6bb5cbf764
|
@ -55,4 +55,15 @@ public class ResourceVersionConflictException extends BaseServerResponseExceptio
|
||||||
super(STATUS_CODE, theMessage, theOperationOutcome);
|
super(STATUS_CODE, theMessage, theOperationOutcome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param theMessage
|
||||||
|
* The message
|
||||||
|
* @param theOperationOutcome The OperationOutcome resource to return to the client
|
||||||
|
*/
|
||||||
|
public ResourceVersionConflictException(String theMessage, Throwable theCause, IBaseOperationOutcome theOperationOutcome) {
|
||||||
|
super(STATUS_CODE, theMessage, theCause, theOperationOutcome);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
|
||||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||||
import ca.uhn.fhir.rest.server.util.CompositeInterceptorBroadcaster;
|
import ca.uhn.fhir.rest.server.util.CompositeInterceptorBroadcaster;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -115,19 +116,26 @@ public class HapiTransactionService {
|
||||||
theTransactionDetails.clearResolvedItems();
|
theTransactionDetails.clearResolvedItems();
|
||||||
theTransactionDetails.clearUserData(BaseHapiFhirDao.XACT_USERDATA_KEY_RESOLVED_TAG_DEFINITIONS);
|
theTransactionDetails.clearUserData(BaseHapiFhirDao.XACT_USERDATA_KEY_RESOLVED_TAG_DEFINITIONS);
|
||||||
theTransactionDetails.clearUserData(BaseHapiFhirDao.XACT_USERDATA_KEY_EXISTING_SEARCH_PARAMS);
|
theTransactionDetails.clearUserData(BaseHapiFhirDao.XACT_USERDATA_KEY_EXISTING_SEARCH_PARAMS);
|
||||||
sleepAtLeast(250, false);
|
double sleepAmount = (250.0d * i) * Math.random();
|
||||||
|
long sleepAmountLong = (long) sleepAmount;
|
||||||
|
sleepAtLeast(sleepAmountLong, false);
|
||||||
|
|
||||||
ourLog.info("About to start a transaction retry due to conflict or constraint error");
|
ourLog.info("About to start a transaction retry due to conflict or constraint error. Sleeping {}ms first.", sleepAmountLong);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IBaseOperationOutcome oo = null;
|
||||||
|
if (e instanceof ResourceVersionConflictException) {
|
||||||
|
oo = ((ResourceVersionConflictException) e).getOperationOutcome();
|
||||||
|
}
|
||||||
|
|
||||||
if (maxRetries > 0) {
|
if (maxRetries > 0) {
|
||||||
String msg = "Max retries (" + maxRetries + ") exceeded for version conflict: " + e.getMessage();
|
String msg = "Max retries (" + maxRetries + ") exceeded for version conflict: " + e.getMessage();
|
||||||
ourLog.info(msg, maxRetries);
|
ourLog.info(msg, maxRetries);
|
||||||
throw new ResourceVersionConflictException(msg);
|
throw new ResourceVersionConflictException(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw e;
|
throw new ResourceVersionConflictException(e.getMessage(), e, oo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue