Skip to content

Commit

Permalink
bug fixed for 32 fields deserializer. issue #1071
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Mar 16, 2017
1 parent 775ceef commit 3d7d24a
Show file tree
Hide file tree
Showing 5 changed files with 325 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,13 @@ private void _deserialze(ClassWriter cw, Context context) {
mw.visitVarInsn(ALOAD, context.var("instance"));
mw.visitVarInsn(ILOAD, 4);

int flagSize = (fieldListSize / 32) + 1;

int flagSize = (fieldListSize / 32);

if (fieldListSize != 0 && (fieldListSize % 32) != 0) {
flagSize += 1;
}

if (flagSize == 1) {
mw.visitInsn(ICONST_1);
} else {
Expand Down
62 changes: 62 additions & 0 deletions src/test/java/com/alibaba/json/bvt/bug/Mogujie_01.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.alibaba.json.bvt.bug;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONWriter;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.json.bvtVO.mogujie.BindQueryRespDTO;
import junit.framework.TestCase;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import java.nio.charset.CodingErrorAction;

/**
* Created by wenshao on 16/03/2017.
*/
public class Mogujie_01 extends TestCase {
public void test_for_issue() throws Exception {
JSON.parseObject("{}", Model.class);


}
public static class Model {
public int f0;
public int f1;
public int f2;
public int f3;
public int f4;
public int f5;
public int f6;
public int f7;
public int f8;
public int f9;
public int f10;
public int f11;
public int f12;
public int f13;
public int f14;
public int f15;
public int f16;
public int f17;
public int f18;
public int f19;
public int f20;
public int f21;
public int f22;
public int f23;
public int f24;
public int f25;
public int f26;
public int f27;
public int f28;
public int f29;
public int f30;
public int f31;
}

}
34 changes: 34 additions & 0 deletions src/test/java/com/alibaba/json/bvtVO/mogujie/BankCard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.alibaba.json.bvtVO.mogujie;

import java.io.Serializable;

/**
* Created by wenshao on 16/03/2017.
*/
public class BankCard implements Serializable {
private static final long serialVersionUID = -8043292491053382301L;

public static final Integer CARD_TYPE_DEBIT = 1; //借记卡
public static final Integer CARD_TYPE_CREDIT = 2; //贷记卡

private Long id;
private String bankId;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}


public String getBankId() {
return bankId;
}

public void setBankId(String bankId) {
this.bankId = bankId;
}

}
51 changes: 51 additions & 0 deletions src/test/java/com/alibaba/json/bvtVO/mogujie/BaseDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.alibaba.json.bvtVO.mogujie;

import java.io.Serializable;

/**
* Created by wenshao on 16/03/2017.
*/
public class BaseDTO implements Serializable {
/**
* serialVersionUID
*/
private static final long serialVersionUID = -1;

/**
* version
*/
private String version;

/**
* is online test
*/
private Boolean onlineTest = Boolean.FALSE;

/**
* http referer
*/
private String referer;

public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public Boolean isOnlineTest() {
return onlineTest;
}
public void setOnlineTest(Boolean onlineTest) {
this.onlineTest = onlineTest;
}
public String getReferer() {
return referer;
}
public void setReferer(String referer) {
this.referer = referer;
}
@Override
public String toString() {
return "BaseDTO [version=" + version + ", onlineTest=" + onlineTest + ", referer=" + referer + "]";
}
}
171 changes: 171 additions & 0 deletions src/test/java/com/alibaba/json/bvtVO/mogujie/BindQueryRespDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
package com.alibaba.json.bvtVO.mogujie;

import java.io.Serializable;

/**
* Created by wenshao on 16/03/2017.
*/
public class BindQueryRespDTO {

/**
* version
*/
public int f0;

/**
* is online test
*/
public int f1;

/**
* http referer
*/
public String referer;

/**
* 签约ID
*/
public Long bindId;

/**
* 签约银行卡ID
*/
public int bankCardId;

/**
* 签约号
*/
public String bindNo;

/**
* 用户ID
*/
public Long userId;

/**
* 签约状态
*/
public Integer status;

/**
* 签约时间(10位时间戳)
*/
public Long bindTime;

/**
* 签约银行卡号
*/
public String cardNo;

/**
* 签约银行卡号标记
*/
public String cardNoMark;

/**
* 签约银行卡号缩写
*/
public String cardNoClip;

/**
* 银行ID
*/
public String bankId;

/**
* 银行名称
*/
public String bankName;

/**
* 银行LOGO
*/
public String bankLogo;

/**
* 银行背景色
*/
public String bankColor;

/**
* 银行卡类
*/
public Integer cardType;

/**
* 银行卡类描述
*/
public String cardTypeDesc;

/**
* 持卡人姓名缩写
*/
public String cardHolderNameClip;

/**
* 签约银行卡预留手机号
*/
public String mobile;

/**
* 签约银行卡预留手机号缩写
*/

public String mobileClip;

/**
* 银行卡开户省 see new
*/

public String province;

/**
* 银行卡开户市
*/
public String city;

/**
* 平安提现通道-大小额通道编号
*/
public String pinganBankCode;

/**
* 平安提现通道-超网通道编号
*/
public String pinganSuperBankCode;

/**
* 开户支行
*/
public String subBank;

/**
* 联行号
*/
public String cnapsCode;

/**
* 渠道签约ID
*/
public Long channelBindId;

/**
* 渠道签约号
*/
public String channelBindNo;

/**
* 渠道签约类型
*/
public Integer channelBindType;

public String subBankDesc;


/**
* 银行卡信息
*/
public BankCard bankCard;


}

0 comments on commit 3d7d24a

Please sign in to comment.