Fix apache compress deprecations

- Use org.apache.commons.io.IOUtils instead of org.apache.commons.compress.utils.IOUtils
- Use TarArchiveInputStream#getNextEntry instead of getNextTarEntry
This commit is contained in:
Aurora Lahtela 2024-03-09 14:09:55 +02:00
parent a862fcb31a
commit 990123080f
5 changed files with 9 additions and 9 deletions

View File

@ -26,7 +26,7 @@ import com.maxmind.geoip2.model.CountryResponse;
import com.maxmind.geoip2.record.Country;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.io.IOUtils;
import javax.inject.Inject;
import javax.inject.Singleton;
@ -119,7 +119,7 @@ public class GeoLite2Geolocator implements Geolocator {
private void findAndCopyFromTar(TarArchiveInputStream tarIn, FileOutputStream fos) throws IOException {
// Breadth first search
Queue<TarArchiveEntry> entries = new ArrayDeque<>();
entries.add(tarIn.getNextTarEntry());
entries.add(tarIn.getNextEntry());
while (!entries.isEmpty()) {
TarArchiveEntry entry = entries.poll();
if (entry.isDirectory()) {
@ -132,7 +132,7 @@ public class GeoLite2Geolocator implements Geolocator {
break; // Found it
}
TarArchiveEntry next = tarIn.getNextTarEntry();
TarArchiveEntry next = tarIn.getNextEntry();
if (next != null) entries.add(next);
}
}

View File

@ -16,7 +16,7 @@
*/
package com.djrapitops.plan.storage.file;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.io.IOUtils;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;

View File

@ -33,7 +33,7 @@ import com.djrapitops.plan.storage.database.transactions.commands.StoreWebUserTr
import com.djrapitops.plan.utilities.PassEncryptUtil;
import com.google.gson.Gson;
import extension.FullSystemExtension;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;

View File

@ -31,7 +31,7 @@ import com.djrapitops.plan.storage.database.transactions.commands.StoreWebUserTr
import com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction;
import com.djrapitops.plan.storage.database.transactions.webuser.StoreWebGroupTransaction;
import com.djrapitops.plan.utilities.PassEncryptUtil;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;

View File

@ -17,7 +17,7 @@
package com.djrapitops.plan.delivery.webserver;
import com.djrapitops.plan.delivery.webserver.http.WebServer;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Test;
import utilities.HTTPConnector;
@ -73,13 +73,13 @@ interface HttpsServerTest {
default -> throw new IllegalStateException(address + "| Wrong response code " + responseCode);
}
} finally {
connection.disconnect();
if (connection != null) connection.disconnect();
}
}
default String login(String address) throws IOException, KeyManagementException, NoSuchAlgorithmException {
HttpURLConnection connection = null;
String cookie = "";
String cookie;
try {
connection = connector.getConnection("POST", address + "/auth/login");
connection.setDoOutput(true);