fix(TUP-21019): Can't install component patch in some special cases (#1938)

fix(TUP-21019): Can't install component patch in some special cases
https://jira.talendforge.org/browse/TUP-21019
This commit is contained in:
Chao MENG
2018-10-23 14:45:23 +08:00
committed by kjwang-talend
parent 9f81eba83f
commit e5923f0c58

View File

@@ -362,16 +362,24 @@ public class ComponentIndexManager {
try {
// must use another stream
jarEntryStream = new JarInputStream(zipFile.getInputStream(zipEntry));
// find the bundleId and version
Manifest manifest = jarEntryStream.getManifest();
if (manifest != null) {
bundleId = JarMenifestUtil.getBundleSymbolicName(manifest);
bundleVersion = JarMenifestUtil.getBundleVersion(manifest);
}
boolean checkManifest = StringUtils.isBlank(bundleId) || StringUtils.isBlank(bundleVersion);
// find the pom.properties
JarEntry jarEntry = null;
while ((jarEntry = jarEntryStream.getNextJarEntry()) != null) {
final String entryPath = jarEntry.getName();
if (JarFile.MANIFEST_NAME.equalsIgnoreCase(entryPath)) {
Manifest manifest = new Manifest();
if (checkManifest && JarFile.MANIFEST_NAME.equalsIgnoreCase(entryPath)) {
manifest = new Manifest();
manifest.read(jarEntryStream);
bundleId = JarMenifestUtil.getBundleSymbolicName(manifest);
bundleVersion = JarMenifestUtil.getBundleVersion(manifest);
checkManifest = false;
}
final Path fullPath = new Path(entryPath);
final String fileName = fullPath.lastSegment();