Skip to content

Commit

Permalink
Merge pull request #4094 from thelsing/compression-1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
cwisniew authored May 29, 2023
2 parents a9e5290 + 7ff7f25 commit 85a1481
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ dependencies {
implementation 'com.google.guava:guava:31.0.1-jre'
// compression of messages between client and server
implementation 'org.apache.commons:commons-compress:1.22'
implementation 'org.tukaani:xz:1.9'
implementation 'com.github.luben:zstd-jni:1.5.5-3'
// intellij forms runtime
implementation 'com.jetbrains.intellij.java:java-gui-forms-rt:223.7571.182'
// layout for forms created in code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import net.rptools.clientserver.ActivityListener;
import net.rptools.clientserver.ActivityListener.Direction;
import net.rptools.clientserver.ActivityListener.State;
import org.apache.commons.compress.compressors.lzma.LZMACompressorInputStream;
import org.apache.commons.compress.compressors.lzma.LZMACompressorOutputStream;
import org.apache.commons.compress.compressors.zstandard.ZstdCompressorInputStream;
import org.apache.commons.compress.compressors.zstandard.ZstdCompressorOutputStream;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand Down Expand Up @@ -84,7 +84,7 @@ public synchronized void addMessage(Object channel, byte[] message) {
private byte[] compress(byte[] message) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream(message.length);
OutputStream ios = new LZMACompressorOutputStream(baos);
OutputStream ios = new ZstdCompressorOutputStream(baos);
ios.write(message);
ios.close();

Expand All @@ -96,10 +96,9 @@ private byte[] compress(byte[] message) {
}

private byte[] inflate(byte[] compressedMessage) {
ByteArrayOutputStream baos = new ByteArrayOutputStream(compressedMessage.length);
InputStream bytesIn = new ByteArrayInputStream(compressedMessage);
try {
InputStream ios = new LZMACompressorInputStream(bytesIn);
InputStream ios = new ZstdCompressorInputStream(bytesIn);
var decompressed = ios.readAllBytes();
ios.close();
return decompressed;
Expand Down

0 comments on commit 85a1481

Please sign in to comment.