我正在运行一个与30个并行运行的应用程序并行运行的应用程序,所以我遇到了需要处理的冲突问题。
我从以下代码中获取以下异常。我不清楚为什么不处理异常。
即使我有逻辑来捕获调用此代码的代码中的异常,该异常也会导致Spring Boot应用程序停止运行。异常处理有多个级别,但未处理异常。
// check to see if the product exists
if (repository.existsByAsin(asin))
sPFBT2 = repository.findByAsin(asin).get(
} else {
//product does not exists.. create product
sPFBT2 = new SProduct(asin, new Long(0));
sPFBT2.setDownload(new Download(sPFBT2)));
try {
repository.saveAndFlush(sPFBT2);
} catch (Exception e)
//product does exists.. find in database
sPFBT2 = null;
sPFBT2 = findByAsin(asin).get(0);
sPFBT2.setDownload(new Download(sPFBT2);
repository.saveAndFlush(sPFBT2);
}
}
<record>
<date>2018-11-06T11:29:51</date>
<millis>1541503791418</millis>
<sequence>211</sequence>
<logger>org.jdeferred.impl.AbstractPromise</logger>
<level>SEVERE</level>
<class>org.jdeferred.impl.AbstractPromise</class>
<method>triggerDone</method>
<thread>23</thread>
<message>an uncaught exception occured in a DoneCallback</message>
<exception>
<message>org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [idx_downloadProduct]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement</message>
<frame>
<class>org.springframework.orm.jpa.vendor.HibernateJpaDialect</class>
<method>convertHibernateAccessException</method>
<line>259</line>
</frame>
<frame>
<class>org.springframework.orm.jpa.vendor.HibernateJpaDialect</class>
<method>translateExceptionIfPossible</method>
<line>225</line>
</frame>
<frame>
<class>org.springframework.orm.jpa.AbstractEntityManagerFactoryBean</class>
<method>translateExceptionIfPossible</method>
<line>527</line>
</frame>
<frame>
<class>org.springframework.dao.support.ChainedPersistenceExceptionTranslator</class>
<method>translateExceptionIfPossible</method>
<line>61</line>
</frame>
<frame>
<class>org.springframework.dao.support.DataAccessUtils</class>
<method>translateIfNecessary</method>
<line>242</line>
</frame>
<frame>
<class>org.springframework.dao.support.PersistenceExceptionTranslationInterceptor</class>
<method>invoke</method>
<line>153</line>
</frame>
<frame>
<class>org.springframework.aop.framework.ReflectiveMethodInvocation</class>
<method>proceed</method>
<line>185</line>
</frame>
<frame>
<class>org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor</class>
<method>invoke</method>
<line>135</line>
</frame>
<frame>
<class>org.springframework.aop.framework.ReflectiveMethodInvocation</class>
<method>proceed</method>
<line>185</line>
</frame>
<frame>
<class>org.springframework.aop.interceptor.ExposeInvocationInterceptor</class>
<method>invoke</method>
<line>92</line>
</frame>
<frame>
<class>org.springframework.aop.framework.ReflectiveMethodInvocation</class>
<method>proceed</method>
<line>185</line>
</frame>
<frame>
<class>org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor</class>
<method>invoke</method>
<line>61</line>
</frame>
<frame>
<class>org.springframework.aop.framework.ReflectiveMethodInvocation</class>
<method>proceed</method>
<line>185</line>
</frame>
<frame>
<class>org.springframework.aop.framework.JdkDynamicAopProxy</class>
<method>invoke</method>
<line>212</line>
</frame>
<frame>
<class>com.sun.proxy.$Proxy81</class>
<method>saveAndFlush</method>
</frame>
<frame>
<class>com.jahtoe.tech.fbtdownloader.KEEPA</class>
<method>lambda$getProductsInfo$1</method>
<line>222</line>
</frame>
<frame>
<class>org.jdeferred.impl.AbstractPromise</class>
<method>triggerDone</method>
<line>107</line>
</frame>
<frame>
<class>org.jdeferred.impl.AbstractPromise</class>
<method>triggerDone</method>
<line>98</line>
</frame>
<frame>
<class>org.jdeferred.impl.DeferredObject</class>
<method>resolve</method>
<line>70</line>
</frame>
<frame>
<class>com.keepa.api.backend.KeepaAPI</class>
<method>lambda$sendRequest$2</method>
<line>180</line>
</frame>
<frame>
<class>java.util.concurrent.ThreadPoolExecutor</class>
<method>runWorker</method>
<line>1149</line>
</frame>
<frame>
<class>java.util.concurrent.ThreadPoolExecutor$Worker</class>
<method>run</method>
<line>624</line>
</frame>
<frame>
<class>java.lang.Thread</class>
<method>run</method>
<line>748</line>
</frame>
</exception>
</record>