Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我的 Pojo 中的一个字段使用了 com.alibaba.fastjson.JSONObject 在 mock 的时候会抛数组越界异常 ArrayIndexOutOfBoundsException #62

Open
doushichao opened this issue May 25, 2021 · 2 comments

Comments

@doushichao
Copy link

Exception in thread "main" com.github.jsonzou.jmockdata.MockException: java.lang.ArrayIndexOutOfBoundsException: 0
	at com.github.jsonzou.jmockdata.mocker.BeanMocker.mock(BeanMocker.java:47)
	at com.github.jsonzou.jmockdata.mocker.ClassMocker.mock(ClassMocker.java:38)
	at com.github.jsonzou.jmockdata.mocker.BaseMocker.mock(BaseMocker.java:35)
	at com.github.jsonzou.jmockdata.JMockData.mock(JMockData.java:33)

我使用了如下的拦截器都是不生效的

mockConfig.registerBeanMockerInterceptor(JSONObject.class, (aClass, field, o, dataConfig) -> InterceptType.UNMOCK);
public class JSONObjectMock implements Mocker<JSONObject> {
    @Override
    public JSONObject mock(DataConfig dataConfig) {
        return new JSONObject();
    }
}

mockConfig.registerMocker(new JSONObjectMock(), JSONObject.class);
@pprain
Copy link

pprain commented Apr 17, 2023

遇到了同样的问题

@eye-gu
Copy link

eye-gu commented Apr 29, 2024

可以改一下ClassMocker里面的先后顺序,从config中获取放前面

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants