Skip to content

Commit

Permalink
Merge pull request #6014 from aubi/FISH-6606-fix-empty-uploaded-file
Browse files Browse the repository at this point in the history
FISH-6606 Use Temporary Filename Only While Saving the Uploaded File
  • Loading branch information
Pandrex247 authored Nov 8, 2022
2 parents 7dbf3f4 + 6360f88 commit 25f99af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2022] Payara Foundation and/or its affiliates

/*
* CommonHandlers.java
Expand Down Expand Up @@ -181,11 +182,12 @@ public static void uploadFileToTempDir(HandlerContext handlerCtx) {
prefix = prefix + new SecureRandom().nextInt(100000);
}
tmpFile = File.createTempFile(prefix, suffix);
FileUtils.deleteOnExit(tmpFile);
tmpFile.delete(); // remove the file as uploader fails, if it exists
if (logger.isLoggable(Level.FINE)) {
logger.fine(GuiUtil.getCommonMessage("log.writeToTmpFile"));
}
uploadedFile.write(tmpFile);
FileUtils.deleteOnExit(tmpFile);
if (logger.isLoggable(Level.FINE)) {
logger.fine(GuiUtil.getCommonMessage("log.afterWriteToTmpFile"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2020 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2020-2022 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -66,10 +66,17 @@ public void setupMicroprofile() {
}
List<String> output = new ArrayList<>();
CliCommands.payaraGlassFish(asList("get-metrics-configuration"), output);
if (output.size() != 3) {
throw new IllegalStateException("Can't get current micproprofile state");
if (!output.contains("Command get-metrics-configuration executed successfully.")) {
throw new IllegalStateException("Can't get current micproprofile state, the output was: '" + output + "'");
}
String header = output.get(0);
// reliably find headers
for (String line : output) {
if (line.startsWith("Enabled")) {
header = line;
break;
}
}
int securityIndex = header.indexOf("Security");
String securityString = output.get(1).substring(securityIndex).replaceFirst("[ \t\n].*", "");
boolean security = Boolean.parseBoolean(securityString);
Expand Down

0 comments on commit 25f99af

Please sign in to comment.