Skip to content

Commit 083e18d

Browse files
committed
判断文件路径是否存在
1 parent 8b51270 commit 083e18d

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

paoding-rose-load/src/main/java/net/paoding/rose/load/ResourceRef.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,21 @@ public static ResourceRef toResourceRef(Resource folder) throws IOException {
8181
+ Arrays.toString(modifiers));
8282
}
8383
} else {
84-
JarFile jarFile = new JarFile(rr.getResource().getFile());
85-
Manifest manifest = jarFile.getManifest();
86-
if (manifest != null) {
87-
Attributes attributes = manifest.getMainAttributes();
88-
String attrValue = attributes.getValue("rose");
89-
if (attrValue == null) {
90-
attrValue = attributes.getValue("Rose");
91-
}
92-
if (attrValue != null) {
93-
modifiers = StringUtils.split(attrValue, ", ;\n\r\t");
94-
if (logger.isDebugEnabled()) {
95-
logger.debug("modifiers[by manifest.mf][" + rr.getResource().getURI()
96-
+ "]=" + Arrays.toString(modifiers));
84+
if(rr.getResource().getFile().exists()){
85+
JarFile jarFile = new JarFile(rr.getResource().getFile());
86+
Manifest manifest = jarFile.getManifest();
87+
if (manifest != null) {
88+
Attributes attributes = manifest.getMainAttributes();
89+
String attrValue = attributes.getValue("rose");
90+
if (attrValue == null) {
91+
attrValue = attributes.getValue("Rose");
92+
}
93+
if (attrValue != null) {
94+
modifiers = StringUtils.split(attrValue, ", ;\n\r\t");
95+
if (logger.isDebugEnabled()) {
96+
logger.debug("modifiers[by manifest.mf][" + rr.getResource().getURI()
97+
+ "]=" + Arrays.toString(modifiers));
98+
}
9799
}
98100
}
99101
}

0 commit comments

Comments
 (0)