博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
FST fast-serialization 1.52版本中一个造成代码死循环的BUG
阅读量:6415 次
发布时间:2019-06-23

本文共 2941 字,大约阅读时间需要 9 分钟。

  hot3.png

public class FSTClazzInfoRegistry {     ... ...  public FSTClazzInfo getCLInfo(Class c) {        //1).此处会出现死循环,而且线程一直是运行状态        while(!rwLock.compareAndSet(false,true));        FSTClazzInfo res = (FSTClazzInfo) mInfos.get(c);        if ( res == null ) {            if ( c == null ) {                rwLock.set(false);                throw new NullPointerException("Class is null");            }            //2).在构造FSTClazzInfo对象时会抛出运行时异常,一旦抛出异常造成代码1处死循环            res = new FSTClazzInfo(c, this, ignoreAnnotations);            mInfos.put( c, res );        }        rwLock.set(false);        return res;    } ... ...}public final class FSTClazzInfo {	... ...    public FSTClazzInfo(Class clazz, FSTClazzInfoRegistry infoRegistry, boolean ignoreAnnotations) {        this.clazz = clazz;        enumConstants = clazz.getEnumConstants();        reg = infoRegistry;        ignoreAnn = ignoreAnnotations;        createFields(clazz);        if ( !reg.isStructMode() ) {            if (Externalizable.class.isAssignableFrom(clazz)) {                externalizable = true;                cons = FSTUtil.findConstructorForExternalize(clazz);            } else if (Serializable.class.isAssignableFrom(clazz) || clazz == Object.class ) {                externalizable = false;                cons = FSTUtil.findConstructorForSerializable(clazz);            } else {                //3).一旦需要序列化的对象没有实现Serializable接口或Externalizable接口的话,就会抛出运行时异常                throw new RuntimeException("Class "+clazz.getName()+" does not implement Serializable or externalizable");            }            if ( ! ignoreAnnotations ) {                Predict annotation = (Predict) clazz.getAnnotation(Predict.class);                if (annotation != null) {                    predict = annotation.value();                } else {                       //default predictions (disabled, no speedup)//                    if ( clazz == List.class ) {//                        predict = new Class[]{ArrayList.class};//                    } else if ( clazz == Map.class ) {//                        predict = new Class[]{HashMap.class};//                    }                }                equalIsIdentity = clazz.isAnnotationPresent(EqualnessIsIdentity.class);                equalIsBinary = clazz.isAnnotationPresent(EqualnessIsBinary.class);                flat = clazz.isAnnotationPresent(Flat.class);            }        }        if (cons != null) {            cons.setAccessible(true);        }        final String name = clazz.getName();        if (name.length()<127) {            isAsciiNameShortString = true;            for (int i=0; i < name.length();i++) {                if (name.charAt(i) > 127) {                    isAsciiNameShortString = false;                    break;                }            }        }        requiresInit = isExternalizable() || useCompatibleMode() || hasTransient;    }   ... ...}

转载于:https://my.oschina.net/dakev/blog/217804

你可能感兴趣的文章
flink 获取上传的Jar源码
查看>>
Spring Data JPA Batch Insertion
查看>>
UEditor自动调节宽度
查看>>
JAVA做验证码图片(转自CSDN)
查看>>
Delphi TServerSocket,TClientSocket实现传送文件代码
查看>>
JS无聊之作
查看>>
Mac上搭建ELK
查看>>
443 Chapter7.Planning for High Availability in the Enterprise
查看>>
框架和语言的作用
查看>>
unidac连接ORACLE免装客户端驱动
查看>>
Cygwin + OpenSSH FOR Windows的安装配置
查看>>
咏南中间件支持手机客户端
查看>>
fastscript增加三方控件之二
查看>>
Windows Vista RTM 你准备好了么?
查看>>
Tensorflow Serving 模型部署和服务
查看>>
Java Web开发详解——XML+DTD+XML Schema+XSLT+Servlet 3.0+JSP 2.2深入剖析与实例应用
查看>>
topcoder srm 680 div1 -3
查看>>
具体数学第二版第四章习题(1)
查看>>
高效前端优化工具--Fiddler入门教程
查看>>
【翻译】我钟爱的HTML5和CSS3在线工具
查看>>