Skip to content

Commit

Permalink
Fix: LogRequestor : Replaced com.google.common.base.Charsets.UTF_8 wi…
Browse files Browse the repository at this point in the history
…th StandardCharsets.UTF_8

Signed-off-by: Mohamed Abdullah <[email protected]>
  • Loading branch information
mdxabu committed Mar 2, 2024
1 parent 110a8f8 commit dd33df5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
23 changes: 11 additions & 12 deletions src/main/java/io/fabric8/maven/docker/access/log/LogRequestor.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,27 @@
* limitations under the License.
*/

import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.time.ZonedDateTime;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.google.common.base.Charsets;
import com.google.common.io.ByteStreams;
import io.fabric8.maven.docker.access.DockerAccessException;
import io.fabric8.maven.docker.access.UrlBuilder;
import io.fabric8.maven.docker.access.util.RequestUtil;
import io.fabric8.maven.docker.util.TimestampFactory;

import org.apache.commons.codec.binary.Hex;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.CloseableHttpClient;

import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.time.ZonedDateTime;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* Extractor for parsing the response of a log request
*
Expand Down Expand Up @@ -170,7 +169,7 @@ private boolean readStreamFrame(InputStream is) throws IOException, LogCallback.
" [ Header: " + Hex.encodeHexString(headerBuffer.array()) + "]", e);
}

String message = Charsets.UTF_8.newDecoder().decode(payload).toString();
String message = StandardCharsets.UTF_8.decode(payload).toString();
callLogCallback(type, message);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.fabric8.maven.docker.access.log;

import com.google.common.base.Charsets;
import io.fabric8.maven.docker.access.UrlBuilder;
import org.apache.commons.text.RandomStringGenerator;
import org.apache.http.HttpEntity;
Expand All @@ -22,12 +21,12 @@
import java.nio.ByteOrder;
import java.nio.CharBuffer;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.StandardCharsets;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.regex.Matcher;

import java.time.ZonedDateTime;

@ExtendWith(MockitoExtension.class)
class LogRequestorTest {
Expand Down Expand Up @@ -321,7 +320,7 @@ private static ByteBuffer combineBuffers(ByteBuffer... buffers) {
private static ByteBuffer messageToBuffer(Streams stream, String message) throws IOException {
String logMessage = logMessage(message);

CharsetEncoder encoder = Charsets.UTF_8.newEncoder();
CharsetEncoder encoder = StandardCharsets.UTF_8.newEncoder();
ByteBuffer payload = encoder.encode(CharBuffer.wrap(logMessage.toCharArray()));
assert payload.order() == ByteOrder.BIG_ENDIAN;
int length = payload.limit();
Expand Down

0 comments on commit dd33df5

Please sign in to comment.