We are running with Java 11 and as Modernizer correctly points out, we
can use direct charset variant which was introduced with Java 10. This
cuts down a tiny bit of dead code.
Change-Id: I7c42984bc1e05e94f5266f26e13aaab650ae4f70
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
02215a58e5c9ebe4624e6ca2103b00a796fcd5f7)
<artifactId>sal-akka-segmented-journal</artifactId>
<packaging>bundle</packaging>
- <properties>
- <!-- FIXME: Remove this -->
- <odlparent.modernizer.enforce>false</odlparent.modernizer.enforce>
- </properties>
-
<dependencies>
<!-- Akka -->
<dependency>
import io.atomix.storage.StorageLevel;
import io.atomix.storage.journal.SegmentedJournal;
import java.io.File;
-import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
}
private ActorRef createHandler(final String persistenceId) {
- final String directoryName = encode(persistenceId);
+ final String directoryName = URLEncoder.encode(persistenceId, StandardCharsets.UTF_8);
final File directory = new File(rootDir, directoryName);
LOG.debug("Creating handler for {} in directory {}", persistenceId, directory);
return message.promise.future();
}
- private static String encode(final String str) {
- try {
- return URLEncoder.encode(str, StandardCharsets.UTF_8.name());
- } catch (UnsupportedEncodingException e) {
- // Shouldn't happen
- LOG.warn("Error encoding {}", str, e);
- return str;
- }
- }
-
private static int getBytes(final Config config, final String path, final int defaultValue) {
if (!config.hasPath(path)) {
return defaultValue;
<artifactId>sal-clustering-commons</artifactId>
<packaging>bundle</packaging>
- <properties>
- <!-- FIXME: Remove this -->
- <odlparent.modernizer.enforce>false</odlparent.modernizer.enforce>
- </properties>
-
<dependencies>
<!-- Java -->
<dependency>
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
private final File snapshotDir;
public LocalSnapshotStore(final Config config) {
- this.executionContext = context().system().dispatchers().lookup(config.getString("stream-dispatcher"));
+ executionContext = context().system().dispatchers().lookup(config.getString("stream-dispatcher"));
snapshotDir = new File(config.getString("dir"));
final int localMaxLoadAttempts = config.getInt("max-load-attempts");
}
private static String encode(final String str) {
- try {
- return URLEncoder.encode(str, StandardCharsets.UTF_8.name());
- } catch (UnsupportedEncodingException e) {
- // Shouldn't happen
- LOG.warn("Error encoding {}", str, e);
- return str;
- }
+ return URLEncoder.encode(str, StandardCharsets.UTF_8);
}
private static String decode(final String str) {
- try {
- return URLDecoder.decode(str, StandardCharsets.UTF_8.name());
- } catch (final UnsupportedEncodingException e) {
- // Shouldn't happen
- LOG.warn("Error decoding {}", str, e);
- return str;
- }
+ return URLDecoder.decode(str, StandardCharsets.UTF_8);
}
@VisibleForTesting
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import org.apache.commons.io.FileUtils;
}
}
- private static String toSnapshotName(final String persistenceId, final int seqNr, final int timestamp)
- throws UnsupportedEncodingException {
- final String encodedPersistenceId = URLEncoder.encode(persistenceId, StandardCharsets.UTF_8.name());
- return "snapshot-" + encodedPersistenceId + "-" + seqNr + "-" + timestamp;
+ private static String toSnapshotName(final String persistenceId, final int seqNr, final int timestamp) {
+ return "snapshot-" + URLEncoder.encode(persistenceId, StandardCharsets.UTF_8) + "-" + seqNr + "-" + timestamp;
}
}