盘古BPM体验地址    盘古BPM交流群盘古BPM交流群号:963222735

Flowable实战-Flowable6.1.2下载以及修复的bug说明

分享牛 3737℃

Flowable项目近期更新到了最新的版本Flowable6.1.2,为什么这次更新悄无声息呢?这次从Flowable6.1.1发布没多久就立马升级到Flowable6.1.2。很简单,官方修复了一个idm引擎的bug。这个功能可能大家平时开发用不到,那我们看一下这个bug的修改点以及涉及到的功能。重点关注AbstractEngineConfigurator类,这个类位于flowable-engine-6.1.2.jar中,既然是引擎核心 包的代码有bug,那我们最好升级到最高版本,避免自己踩坑。

为了看起来直观,我们先看下flowable-engine-6.1.1.jar中中的AbstractEngineConfigurator类,核心实现如下:

registerCustomMybatisMappings方法如下:

 protected void registerCustomMybatisMappings(ProcessEngineConfigurationImpl processEngineConfiguration) {
        String cfgPath = getMybatisCfgPath();
        if (cfgPath != null) {
            Set<String> resources = new HashSet<>();
            try (InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(cfgPath)) {
                DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
                DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
                Document document = docBuilder.parse(inputStream);
                NodeList nodeList = document.getElementsByTagName("mapper");
                for (int i = 0; i < nodeList.getLength(); i++) {
                    Node node = nodeList.item(i);
                    resources.add(node.getAttributes().getNamedItem("resource").getTextContent());
                }
            } catch (IOException e) {
                throw new FlowableException("Could not read IDM Mybatis configuration file", e);
            } catch (ParserConfigurationException | SAXException e) {
                throw new FlowableException("Could not parse Mybatis configuration file", e);
            }
            
            if (processEngineConfiguration.getCustomMybatisXMLMappers() == null) {
                processEngineConfiguration.setCustomMybatisXMLMappers(resources);
            } else {
                processEngineConfiguration.getCustomMybatisXMLMappers().addAll(resources);
            }
        }
    }

貌似没看过源码的朋友,感觉没什么问题,那我们看下flowable-engine-6.1.2.jar中中的AbstractEngineConfigurator类

protected void registerCustomMybatisMappings(ProcessEngineConfigurationImpl processEngineConfiguration) {
        String cfgPath = getMybatisCfgPath();
        if (cfgPath != null) {
            Set<String> resources = new HashSet<>();
            try (InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(cfgPath)) {
                DocumentBuilderFactory docBuilderFactory = createDocumentBuilderFactory();
                DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
                Document document = docBuilder.parse(inputStream);
                NodeList nodeList = document.getElementsByTagName("mapper");
                for (int i = 0; i < nodeList.getLength(); i++) {
                    Node node = nodeList.item(i);
                    resources.add(node.getAttributes().getNamedItem("resource").getTextContent());
                }
            } catch (IOException e) {
                throw new FlowableException("Could not read IDM Mybatis configuration file", e);
            } catch (ParserConfigurationException | SAXException e) {
                throw new FlowableException("Could not parse Mybatis configuration file", e);
            }
            
            if (processEngineConfiguration.getCustomMybatisXMLMappers() == null) {
                processEngineConfiguration.setCustomMybatisXMLMappers(resources);
            } else {
                processEngineConfiguration.getCustomMybatisXMLMappers().addAll(resources);
            }
        }
    }

那我们看一下createDocumentBuilderFactory方法,因为两个版本的对比,我们发现只有这个地方的代码被修改了:

 protected DocumentBuilderFactory createDocumentBuilderFactory() throws ParserConfigurationException {
        DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
        if (!enableMybatisXmlMappingValidation) {
            docBuilderFactory.setValidating(false);
            docBuilderFactory.setNamespaceAware(false);
            docBuilderFactory.setExpandEntityReferences(false);
            docBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
            docBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
        }
        return docBuilderFactory;
    }

多了一个判断,校验客户端是否开启了xml文件的校验功能,该功能默认是false。

总结:

1.Flowable6.1.2仅仅修复了idm引擎的这一个紧急bug。其他的暂时没有变化,所以为了避免踩坑,我们可以直接升级到该版本即可。关于idm引擎的使用,作为Flowable的核心6大引擎之一,我们后续也会逐步展开描述。

2.Flowable6.1.2程序包可以进入对应的交流群进行下载。

~~~~~~~~~~~~ 正文结束 下面没了 ~~~~~~~~~~~~

分享牛老师再出新作,倾力打造Activiti精品课程系列以及Flowable精品系列课程,以最短的时间高效完成学习目标,入门、进阶、提升、源码与实战案例并重,是0基础的新手从入门到精通的必备课程。

《Activiti源码分析》------从零入门进阶的最佳课程------【点此查看详情】

《Activiti 中国式特色流程》------企业级实战视频------【点此查看详情】





转载请注明:分享牛 » Flowable实战-Flowable6.1.2下载以及修复的bug说明