Skip to content

Commit

Permalink
Add Android-specific exception message
Browse files Browse the repository at this point in the history
  • Loading branch information
ShellWen committed Aug 18, 2024
1 parent 16b3078 commit b50fff3
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.function.Supplier;

import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.OsUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.functors.UnaryEquator;

Expand All @@ -53,10 +54,19 @@ public final class PathUtils {
private static final AtomicReference<Supplier<? extends Path>> USER_HOME_RESOLVER_HOLDER = new AtomicReference<>();

private static final class LazyDefaultUserHomeFolderHolder {
private static final Path PATH
= Paths.get(ValidateUtils.checkNotNullAndNotEmpty(System.getProperty("user.home"), "No user home"))
.toAbsolutePath()
.normalize();
private static final Path PATH;

static {
String exceptionMessage = OsUtils.isAndroid()
? "No user home folder available. You should call " +
"org.apache.sshd.common.util.io.PathUtils.setUserHomeFolderResolver() " +
"method to set user home folder as there is no home folder on Android"
: "No user home folder available";
PATH = Paths
.get(ValidateUtils.checkNotNullAndNotEmpty(System.getProperty("user.home"), exceptionMessage))
.toAbsolutePath()
.normalize();
}

private LazyDefaultUserHomeFolderHolder() {
throw new UnsupportedOperationException("No instance allowed");
Expand Down

0 comments on commit b50fff3

Please sign in to comment.