Skip to content

Commit 1435ce7

Browse files
authored
Merge pull request #293 from oracle/fixtempfileprefix
fix persist problem when creating temp archive file with filename les…
2 parents b328532 + 303b1d4 commit 1435ce7

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

core/src/main/java/oracle/weblogic/deploy/util/WLSDeployZipFile.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -775,14 +775,6 @@ private void saveChangesToZip(Map<String, ZipEntry> updatedZipEntries, Map<Strin
775775
private File getNewOutputFile() throws WLSDeployArchiveIOException {
776776
final String METHOD = "getNewOutputFile";
777777

778-
String fileName = getFileName();
779-
if (fileName.contains(File.separator)) {
780-
int lastSeparator = fileName.lastIndexOf(File.separator);
781-
if (lastSeparator > 0)
782-
fileName = fileName.substring(lastSeparator+1);
783-
}
784-
785-
String[] nameComponents = FileUtils.parseFileName(fileName);
786778

787779
File directory = getFile().getParentFile();
788780
File newOutputFile;
@@ -791,7 +783,18 @@ private File getNewOutputFile() throws WLSDeployArchiveIOException {
791783
newOutputFile = getFile();
792784
LOGGER.finest("WLSDPLY-01523", newOutputFile.getAbsolutePath());
793785
} else {
794-
newOutputFile = File.createTempFile(nameComponents[0], DOT + nameComponents[1], directory);
786+
// Is there a real case the the archive file with no extension ?
787+
String fileName = getFileName();
788+
if (fileName.contains(File.separator)) {
789+
int lastSeparator = fileName.lastIndexOf(File.separator);
790+
if (lastSeparator > 0)
791+
fileName = fileName.substring(lastSeparator+1);
792+
}
793+
String[] nameComponents = FileUtils.parseFileName(fileName);
794+
795+
// prefix shouldn't matter what we put here, but it has to be at least 3 characters
796+
797+
newOutputFile = File.createTempFile("wdt_temparchive", DOT + nameComponents[1], directory);
795798
LOGGER.finest("WLSDPLY-01524", newOutputFile.getAbsolutePath());
796799
}
797800
LOGGER.finer("WLSDPLY-01525", getFileName(), newOutputFile.getAbsolutePath());

0 commit comments

Comments
 (0)