From cee61dfe26bab4fd5168fdb9b9077983a3226c75 Mon Sep 17 00:00:00 2001 From: plough Date: Tue, 11 Dec 2018 10:34:57 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-13402=20=E3=80=90=E9=98=BB=E5=A1=9E?= =?UTF-8?q?=E3=80=91=E3=80=9010.0.2=E5=9B=9E=E5=BD=92=E3=80=91=E5=85=AC?= =?UTF-8?q?=E5=BC=8F=E9=9D=A2=E6=9D=BF=E7=82=B9=E4=B8=8D=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/formula/FunctionConstants.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java b/designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java index 750df1bad..9df15fd8f 100644 --- a/designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java +++ b/designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java @@ -13,6 +13,7 @@ import com.fr.function.SUM; import com.fr.function.TIME; import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralUtils; import com.fr.log.FineLoggerFactory; import com.fr.plugin.ExtraClassManager; import com.fr.stable.EncodeConstants; @@ -66,7 +67,6 @@ public final class FunctionConstants { while (urlEnumeration.hasMoreElements()) { URL url = urlEnumeration.nextElement(); String classFilePath = url.getFile(); - /* * alex:url.getFile获取的地址中,如果有空格或中文会被URLEncoder.encode处理 * 会变成%20这种%打头的东西,但是new File的时候%20是无法解析成空格,所以在此需要做URLDecoder.decode处理 @@ -77,10 +77,9 @@ public final class FunctionConstants { FRContext.getLogger().error(e1.getMessage(), e1); } FRContext.getLogger().info("ClassFilePath:" + classFilePath); - /* - * alex:如果是jar包中的class文件 - * file:/D:/opt/FineReport6.5/WebReport/WEB-INF/lib/fr-server-6.5.jar!/com/fr/rpt/script/function - */ + if (isCustomFormulaPath(classFilePath)) { + continue; + } for (String fileName : findClassNamesUnderFilePath(classFilePath)) { try { Class cls = Class.forName(pkgName + "." + fileName.substring(0, fileName.length() - 6)); @@ -94,11 +93,19 @@ public final class FunctionConstants { } } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ignore) { + } catch (Throwable e) { + // 不要因为个别公式加载失败,而导致整个函数面板无法启动 + FineLoggerFactory.getLogger().error(e.getMessage()); } } } } + private static boolean isCustomFormulaPath(String classFilePath) { + // 除非是代码启动,否则不读取 WEB-INF/classes/com/fr/function 目录下的类 + return !classFilePath.contains("!/") && GeneralUtils.readBuildNO().contains("-"); + } + /** * 将函数分组插件中的函数添加到对应的列表中 * @param listModel