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

1.2.29版本可以解析,1.2.36版本解析报错 #1548

Closed
yafngzh opened this issue Oct 26, 2017 · 3 comments
Closed

1.2.29版本可以解析,1.2.36版本解析报错 #1548

yafngzh opened this issue Oct 26, 2017 · 3 comments
Labels
Milestone

Comments

@yafngzh
Copy link

yafngzh commented Oct 26, 2017

public class TestIncSelector {
    public static class PublishDoc implements Serializable {

        public static final String LSN_META_NAME = "LSN";
        public static final String DOCTYPE_META_NAME = "TYPE";
        public static final String AREA_META_NAME = "AREA";
        public static final String PRIMARY_KEY_META_NAME = "PRIMARY_KEY";
        public static final String SECONDARY_KEY_META_NAME = "SECONDARY_KEY";

        private JSONObject meta;
        private JSONObject doc;

        public PublishDoc() {
            this.meta = new JSONObject();
            this.doc = new JSONObject();
        }

        public JSONObject getMeta() {
            return meta;
        }

        public void setMeta(JSONObject meta) {
            this.meta = meta;
        }

        public JSONObject getDoc() {
            return doc;
        }

        public void setDoc(JSONObject doc) {
            this.doc = doc;
        }

        @JSONField(serialize = false)
        public void addMeta(String name, Object value) {
            this.meta.put(name, value);
        }

        @JSONField(serialize = false)
        public Object getMeta(String name) {
            return this.meta.get(name);
        }

        @JSONField(serialize = false)
        public Long getLSN() {
            return this.meta.getLong(LSN_META_NAME);
        }

        @JSONField(serialize = false)
        public void setLSN(Long lsn) {
            this.meta.put(LSN_META_NAME, lsn);
        }

        @JSONField(serialize = false)
        public DocType getDocType() {
            return DocType.valueOf(this.meta.getString(DOCTYPE_META_NAME));
        }

        @JSONField(serialize = false)
        public void setDocType(DocType docType) {
            this.meta.put(DOCTYPE_META_NAME, docType.toString());
        }

        @JSONField(serialize = false)
        public List<String> getPrimaryKey() {
            return this.meta.getJSONArray(PRIMARY_KEY_META_NAME).toJavaList(String.class);
        }

        @JSONField(serialize = false)
        public void setPrimaryKey(List<String> primaryKey) {
            this.meta.put(PRIMARY_KEY_META_NAME, primaryKey);
        }

        @JSONField(serialize = false)
        public List<String> getSecondaryKey() {
            return this.meta.getJSONArray(SECONDARY_KEY_META_NAME).toJavaList(String.class);
        }

        @JSONField(serialize = false)
        public void setSecondaryKey(List<String> secondaryKey) {
            this.meta.put(SECONDARY_KEY_META_NAME, secondaryKey);
        }

        @JSONField(serialize = false)
        public String getArea() {
            return this.meta.getString(AREA_META_NAME);
        }

        @JSONField(serialize = false)
        public void setArea(String area) {
            this.meta.put(AREA_META_NAME, area);
        }

        @Override
        public String toString() {
            return JSON.toJSONString(this);
        }
    }
        @Test
    public void test_1(){
        String msg = "[{\"doc\":{\"bottomprice\":80,\"cashpool_isdeleted\":0,\"shopcityid\":190,\"timerange\":\"2017-10-25;2017-10-26\",\"launchentityid\":3048,\"bidprice\":700,\"targetitems\":\"{}\",\"type\":0,\"slottagid\":44,\"targetid\":330048,\"entity_isdeleted\":0,\"bu\":2,\"target_isdeleted\":0,\"shopid\":6067941,\"slotids\":\"50041,10233,50051,10033,50061,50001,10099,10133,50101,10051\",\"launchscope\":0,\"productid\":74,\"creativeid\":300048,\"dpentitystatus\":1,\"accountid\":20151002,\"entitytype\":4,\"launchplatforms\":\"\",\"iszhuantou\":0,\"dpentityid\":6067941,\"timeslotperiod\":\"0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167\",\"templateid\":23,\"category1\":246,\"launch_isdeleted\":0,\"cashpoolid\":20151002,\"creative_isdeleted\":0,\"settlementstatus\":1,\"cityid\":\"190\",\"planid\":1042007,\"categoryid\":\"10 246\",\"price\":700,\"shoptype\":10,\"plan_isdeleted\":0,\"launchid\":30000048,\"creativeext\":\"{\\\"content\\\":\\\"啊啊啊啊啊啊啊啊\\\",\\\"title\\\":\\\"啊啊啊啊啊\\\",\\\"smartPic\\\":0,\\\"mobUrl\\\":\\\"https://evt.dianping.com/midas/1activities/3809/index.html?dpid=7997757988618737578&cityid=1&longitude=121.41543&latitude=31.21684&token=&product=dpapp&area=pc\\\",\\\"mtMobUrl\\\":\\\"https://evt.dianping.com/midas/1activities/3809/index.html?dpid=7997757988618737578&cityid=1&longitude=121.41543&latitude=31.21684&token=&product=dpapp&area=mtapp\\\"}\",\"chargetype\":1,\"channel\":0,\"generatedchannel\":0,\"promotype\":2},\"meta\":{\"LSN\":2077395,\"AREA\":\"engine-searchcpc\",\"PRIMARY_KEY\":[\"creativeid\",\"targetid\"],\"SECONDARY_KEY\":[\"planid\",\"shopid\",\"launchentityid\",\"launchid\",\"cashpoolid\"],\"TYPE\":\"UPDATE\"}}]";
        // JSONArray.parse(msg);
        JSON.parseArray(msg).toJavaList(PublishDoc.class);
        // System.out.println(parseMsg(msg));
    }
}

如下报错:

java.lang.VerifyError: (class: com/alibaba/fastjson/parser/deserializer/FastjsonASMDeserializer_1_PublishDoc, method: deserialzeArrayMapping signature: (Lcom/alibaba/fastjson/parser/DefaultJSONParser;Ljava/lang/reflect/Type;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;) Unable to pop operand off an empty stack

	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
	at java.lang.Class.getConstructor0(Class.java:3075)
	at java.lang.Class.getConstructor(Class.java:1825)
	at com.alibaba.fastjson.parser.deserializer.ASMDeserializerFactory.createJavaBeanDeserializer(ASMDeserializerFactory.java:81)
	at com.alibaba.fastjson.parser.ParserConfig.createJavaBeanDeserializer(ParserConfig.java:651)
	at com.alibaba.fastjson.parser.ParserConfig.getDeserializer(ParserConfig.java:502)
	at com.alibaba.fastjson.parser.ParserConfig.getDeserializer(ParserConfig.java:357)
	at com.alibaba.fastjson.util.TypeUtils.castToJavaBean(TypeUtils.java:1077)
	at com.alibaba.fastjson.util.TypeUtils.cast(TypeUtils.java:725)
	at com.alibaba.fastjson.JSONArray.toJavaList(JSONArray.java:430)
	at com.dianping.midas.lego.select.test.TestIncSelector.test_1(TestIncSelector.java:122)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

经测试 1.29版本正常运行,1.36版本报上述错误

@yafngzh yafngzh changed the title 1.29版本可以解析,1.36版本解析报错 1.2.29版本可以解析,1.2.36版本解析报错 Oct 26, 2017
@wenshao wenshao added the bug label Oct 26, 2017
@wenshao wenshao added this to the 1.2.40 milestone Oct 26, 2017
wenshao added a commit that referenced this issue Oct 26, 2017
@wenshao
Copy link
Member

wenshao commented Oct 27, 2017

问题出在这个地方

@JSONField(serialize = false)
        public void addMeta(String name, Object value) {
            this.meta.put(name, value);
        }

新版将会修复,预计11月1日前后发布

@wenshao
Copy link
Member

wenshao commented Nov 4, 2017

https://github.com/alibaba/fastjson/releases/tag/1.2.40
问题已经修复,请用新版本

@wenshao wenshao closed this as completed Nov 4, 2017
@vipcxj
Copy link

vipcxj commented Nov 10, 2017

错误配置比起忽略错误,更应该给出更明确的错误信息吧~ 不然还以为配置是对的,以后继续错下去

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

No branches or pull requests

3 participants