|
1 | 1 | /* |
2 | | - * Copyright 2002-2014 the original author or authors. |
| 2 | + * Copyright 2002-2015 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
32 | 32 | import java.util.Set; |
33 | 33 | import java.util.jar.JarEntry; |
34 | 34 | import java.util.jar.JarFile; |
| 35 | +import java.util.zip.ZipException; |
35 | 36 |
|
36 | 37 | import org.apache.commons.logging.Log; |
37 | 38 | import org.apache.commons.logging.LogFactory; |
@@ -517,18 +518,26 @@ protected Set<Resource> doFindPathMatchingJarResources(Resource rootDirResource, |
517 | 518 | // being arbitrary as long as following the entry format. |
518 | 519 | // We'll also handle paths with and without leading "file:" prefix. |
519 | 520 | String urlFile = rootDirResource.getURL().getFile(); |
520 | | - int separatorIndex = urlFile.indexOf(ResourceUtils.JAR_URL_SEPARATOR); |
521 | | - if (separatorIndex != -1) { |
522 | | - jarFileUrl = urlFile.substring(0, separatorIndex); |
523 | | - rootEntryPath = urlFile.substring(separatorIndex + ResourceUtils.JAR_URL_SEPARATOR.length()); |
524 | | - jarFile = getJarFile(jarFileUrl); |
| 521 | + try { |
| 522 | + int separatorIndex = urlFile.indexOf(ResourceUtils.JAR_URL_SEPARATOR); |
| 523 | + if (separatorIndex != -1) { |
| 524 | + jarFileUrl = urlFile.substring(0, separatorIndex); |
| 525 | + rootEntryPath = urlFile.substring(separatorIndex + ResourceUtils.JAR_URL_SEPARATOR.length()); |
| 526 | + jarFile = getJarFile(jarFileUrl); |
| 527 | + } |
| 528 | + else { |
| 529 | + jarFile = new JarFile(urlFile); |
| 530 | + jarFileUrl = urlFile; |
| 531 | + rootEntryPath = ""; |
| 532 | + } |
| 533 | + newJarFile = true; |
525 | 534 | } |
526 | | - else { |
527 | | - jarFile = new JarFile(urlFile); |
528 | | - jarFileUrl = urlFile; |
529 | | - rootEntryPath = ""; |
| 535 | + catch (ZipException ex) { |
| 536 | + if (logger.isDebugEnabled()) { |
| 537 | + logger.debug("Skipping invalid jar classpath entry [" + urlFile + "]"); |
| 538 | + } |
| 539 | + return Collections.emptySet(); |
530 | 540 | } |
531 | | - newJarFile = true; |
532 | 541 | } |
533 | 542 |
|
534 | 543 | try { |
|
0 commit comments