diff --git a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/DBControl.java b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/DBControl.java index 2a4fa9863f8..72d67edd8c1 100644 --- a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/DBControl.java +++ b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/DBControl.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) 2017 Payara Foundation and/or its affiliates. All rights reserved. + * Copyright (c) [2017-2024] 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 @@ -44,6 +44,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; +import java.nio.charset.StandardCharsets; import com.sun.enterprise.util.io.FileUtils; import org.glassfish.api.admin.CommandException; @@ -84,7 +85,7 @@ protected DBControl(final String dbCommand, final String dbHost, final String db } // Redirect stdout and stderr to a file - try (PrintStream printStream = new PrintStream(new FileOutputStream(dbLog, true), true)) { + try (PrintStream printStream = new PrintStream(new FileOutputStream(dbLog, true), false, StandardCharsets.UTF_8)) { System.setOut(printStream); System.setErr(printStream); } diff --git a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java index 0e03b82fa34..87e6d588f92 100644 --- a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java +++ b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java @@ -56,6 +56,7 @@ import com.sun.enterprise.util.io.FileUtils; import fish.payara.admin.launcher.PayaraDefaultJvmOptions; import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.logging.Level; import java.util.regex.Matcher; @@ -608,7 +609,7 @@ private void writeSecurityTokens(Process sp) throws GFLauncherException, IOExcep OutputStreamWriter osw = null; BufferedWriter bw = null; try { - osw = new OutputStreamWriter(os); + osw = new OutputStreamWriter(os, StandardCharsets.UTF_8); bw = new BufferedWriter(osw); for (String token : info.securityTokens) { bw.write(token); @@ -910,7 +911,7 @@ private Optional getConfiguredJdkVersion(String javaExePath) throws Runtime r = Runtime.getRuntime(); Process p = r.exec(javaExePath + " -version"); p.waitFor(); - try (BufferedReader b = new BufferedReader(new InputStreamReader(p.getErrorStream()))) { + try (BufferedReader b = new BufferedReader(new InputStreamReader(p.getErrorStream(), StandardCharsets.UTF_8))) { String line; while ((line = b.readLine()) != null) { Matcher m = JAVA_VERSION_PATTERN.matcher(line); diff --git a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteAdminCommand.java b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteAdminCommand.java index d2e44e1313d..93df64eda0c 100644 --- a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteAdminCommand.java +++ b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteAdminCommand.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -// Portions Copyright [2017-2018] [Payara Foundation and/or its affiliates] +// Portions Copyright [2017-2024] [Payara Foundation and/or its affiliates] package com.sun.enterprise.admin.remote; @@ -931,8 +931,8 @@ private void doHttpCommand(String uriString, String httpMethod, } catch (Exception e) { logger.log(Level.FINER, "doHttpCommand: exception", e); ByteArrayOutputStream buf = new ByteArrayOutputStream(); - e.printStackTrace(new PrintStream(buf)); - logger.finer(buf.toString()); + e.printStackTrace(new PrintStream(buf, false, UTF_8)); + logger.finer(buf.toString(UTF_8)); throw new CommandException(e); } } while (shouldTryCommandAgain); @@ -1123,7 +1123,7 @@ private StringBuilder addPasswordOption(StringBuilder uriString, String name, St passwordOptions .append(name) .append('=') - .append(URLEncoder.encode(new String(Base64.getMimeEncoder().encode(option.getBytes()), UTF_8), "UTF-8")); + .append(URLEncoder.encode(new String(Base64.getMimeEncoder().encode(option.getBytes(UTF_8)), UTF_8), "UTF-8")); return uriString; } @@ -1341,7 +1341,7 @@ private CommandModel parseMetadata(InputStream in, StringBuilder errors) { FileUtils.copy(in, baos, 0); } catch (IOException ex) { } in = new ByteArrayInputStream(baos.toByteArray()); - String response = baos.toString(); + String response = baos.toString(UTF_8); logger.finer("------- RAW METADATA RESPONSE ---------"); logger.finer(response); logger.finer("------- RAW METADATA RESPONSE ---------");