Skip to content

Commit 83b78bc

Browse files
committedFeb 28, 2025·
String calls byte
1 parent 7b48861 commit 83b78bc

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed
 

‎hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestDataUtil.java

+20-9
Original file line numberDiff line numberDiff line change
@@ -108,39 +108,50 @@ public static OzoneVolume createVolume(OzoneClient client,
108108
public static void createKey(OzoneBucket bucket, String keyName,
109109
String content) throws IOException {
110110
createKey(bucket, keyName, ReplicationFactor.ONE,
111-
ReplicationType.RATIS, content);
111+
ReplicationType.RATIS, content.getBytes(UTF_8));
112112
}
113113

114114
public static void createKey(OzoneBucket bucket, String keyName,
115115
byte[] content) throws IOException {
116116
createKey(bucket, keyName, ReplicationFactor.ONE,
117-
ReplicationType.RATIS, new String(content, UTF_8));
117+
ReplicationType.RATIS, content);
118+
118119
}
119120

120121
public static void createKey(OzoneBucket bucket, String keyName,
121122
ReplicationFactor repFactor, ReplicationType repType, byte[] content)
122123
throws IOException {
123124
ReplicationConfig repConfig = ReplicationConfig
124125
.fromTypeAndFactor(repType, repFactor);
125-
createKey(bucket, keyName, repConfig, new String(content, UTF_8));
126+
try (OutputStream stream = bucket
127+
.createKey(keyName, content.length, repConfig,
128+
new HashMap<>())) {
129+
stream.write(content);
130+
}
131+
}
132+
133+
public static void createKey(OzoneBucket bucket, String keyName,
134+
ReplicationConfig repConfig, byte[] content)
135+
throws IOException {
136+
try (OutputStream stream = bucket
137+
.createKey(keyName, content.length, repConfig,
138+
new HashMap<>())) {
139+
stream.write(content);
140+
}
126141
}
127142

128143
public static void createKey(OzoneBucket bucket, String keyName,
129144
ReplicationFactor repFactor, ReplicationType repType, String content)
130145
throws IOException {
131146
ReplicationConfig repConfig = ReplicationConfig
132147
.fromTypeAndFactor(repType, repFactor);
133-
createKey(bucket, keyName, repConfig, content);
148+
createKey(bucket, keyName, repConfig, content.getBytes(UTF_8));
134149
}
135150

136151
public static void createKey(OzoneBucket bucket, String keyName,
137152
ReplicationConfig repConfig, String content)
138153
throws IOException {
139-
try (OutputStream stream = bucket
140-
.createKey(keyName, content.length(), repConfig,
141-
new HashMap<>())) {
142-
stream.write(content.getBytes(UTF_8));
143-
}
154+
createKey(bucket, keyName, repConfig, content.getBytes(UTF_8));
144155
}
145156

146157
public static void createKey(OzoneBucket bucket, String keyName,

0 commit comments

Comments
 (0)
Please sign in to comment.