From 0c2c4865f6803549b9acc037a68363c37d4f335c Mon Sep 17 00:00:00 2001 From: Joe Chacko Date: Tue, 24 Feb 2026 22:55:34 +0000 Subject: [PATCH] fix(giop): use Latin-1 charset to encode op name - Replace String.getBytes() with String.getBytes(ISO_8859_1) in GIOPOutgoingMessage - Add static import for StandardCharsets.ISO_8859_1 - Remove unused ISO_LATIN_1 import from GIOPClient - Reorder imports in GIOPClient for consistency - Ensure operation names are consistently encoded using ISO-8859-1 charset in GIOP 1.0, 1.1, and 1.2 messages This change makes the charset encoding explicit rather than relying on the platform default, improving portability and preventing potential encoding issues across different systems. --- .../src/main/java/org/apache/yoko/orb/OB/GIOPClient.java | 3 +-- .../java/org/apache/yoko/orb/OB/GIOPOutgoingMessage.java | 9 +++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPClient.java b/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPClient.java index a11047143..8e123c618 100644 --- a/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPClient.java +++ b/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPClient.java @@ -18,8 +18,8 @@ package org.apache.yoko.orb.OB; import org.apache.yoko.io.Buffer; -import org.apache.yoko.orb.CORBA.YokoOutputStream; import org.apache.yoko.orb.CORBA.OutputStreamHolder; +import org.apache.yoko.orb.CORBA.YokoOutputStream; import org.apache.yoko.orb.IOP.ServiceContexts; import org.apache.yoko.orb.OBPortableServer.POAManager_impl; import org.apache.yoko.orb.OCI.Connector; @@ -49,7 +49,6 @@ import static java.util.logging.Level.FINE; import static java.util.logging.Level.FINEST; import static org.apache.yoko.logging.VerboseLogging.CONN_OUT_LOG; -import static org.apache.yoko.orb.OB.CodeSetInfo.ISO_LATIN_1; import static org.apache.yoko.orb.OB.CodeSetUtil.getNegotiatedCodecs; import static org.apache.yoko.orb.OB.SendingContextRuntimes.SENDING_CONTEXT_RUNTIME; import static org.apache.yoko.orb.exceptions.Transients.ACTIVE_CONNECTION_MANAGEMENT; diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPOutgoingMessage.java b/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPOutgoingMessage.java index 6f5f22081..f5f39a109 100644 --- a/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPOutgoingMessage.java +++ b/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPOutgoingMessage.java @@ -34,6 +34,11 @@ import org.omg.IOP.ServiceContext; import org.omg.IOP.TaggedProfile; import org.omg.IOP.TaggedProfileHelper; +import sun.nio.cs.ISO_8859_1; + +import java.nio.charset.StandardCharsets; + +import static java.nio.charset.StandardCharsets.ISO_8859_1; public final class GIOPOutgoingMessage { private static int maxMessageSize_ = 0; // TODO: pick a default @@ -171,7 +176,7 @@ void writeRequestHeader(int id, String op, boolean response, ServiceContexts con // int opLen = op.length(); out_.write_ulong(opLen + 1); - out_.write_octet_array(op.getBytes(), 0, opLen); + out_.write_octet_array(op.getBytes(ISO_8859_1), 0, opLen); out_.write_octet((byte) 0); // nul terminator out_.write_ulong(0); // requesting_principal @@ -209,7 +214,7 @@ void writeRequestHeader(int id, String op, boolean response, ServiceContexts con // int opLen = op.length(); out_.write_ulong(opLen + 1); - out_.write_octet_array(op.getBytes(), 0, opLen); + out_.write_octet_array(op.getBytes(ISO_8859_1), 0, opLen); out_.write_octet((byte) 0); // nul terminator writeServiceContextList(contexts); // service_context