DataSource才会出现重播错误

DataSource才会出现重播错误

本文介绍了为什么只有在单元测试时我的Oracle DataSource才会出现重播错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Spring Boot 1.5.17(Spring 4.3.20)服务器可以在bootRun或部署时正常工作.

My Spring Boot 1.5.17 (Spring 4.3.20) server works fine with bootRun or when deployed.

但是,我有一个Oracle DataSource,它仅在单元测试时会失败 :

However, I have an Oracle DataSource that fails only when unit-testing:

针对此错误的Google搜索没有确切结果.

A Google Search for this error doesn't have exact results.

我能够使用其他Oracle数据库进行单元测试.

I am able to unit-test with a different Oracle database.

我在完整的应用程序测试上下文中收到错误消息

I get the error with a full Application testing context

@RunWith(SpringRunner.class)
@SpringBootTest(
        webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
        classes = { TestingUserConfiguration.class, Application.class }
)

以及单个DataSource配置和服务

As well as just the single DataSource config and Service

@RunWith(SpringRunner.class)
@SpringBootTest(classes = {
        MyDbConfig.class,
        MyService.class
})

oracle.jdbc.pool.OracleDataSourceoracle.jdbc.replay.OracleConnectionPoolDataSourceImpl都有错误.UCP没有影响.

Both oracle.jdbc.pool.OracleDataSource and oracle.jdbc.replay.OracleConnectionPoolDataSourceImpl have the error.UCP makes no difference.

OracleConnectionPoolDataSourceImpl具有不同的错误:

尝试从OJDBC 12.2升级到2018.3,没有区别.

Tried upgrading from OJDBC 12.2 to 2018.3, no difference.

有人以前见过此错误吗?关于为什么只在Spring单元测试中出现的任何想法?

Has anyone seen this error before?Any ideas on why it only appears with Spring unit tests?

推荐答案

经过一番摸索,我发现可以在测试套件中做到这一点:

After much head scratching, I found that doing this in the test suite:

static {
 ClassLoader.getSystemClassLoader().setPackageAssertionStatus("oracle.jdbc.driver", false);
}

解决了我的问题,我确定这是oracle.jdbc.driver.T4CTTIfun类中的错误

Solved My issue, I am sure this is a bug in the oracle.jdbc.driver.T4CTTIfun class

这篇关于为什么只有在单元测试时我的Oracle DataSource才会出现重播错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 06:57