Skip to content

Commit

Permalink
Change return type of KiwiEnvironment#tryGetCurrentPid to OptionalLong
Browse files Browse the repository at this point in the history
Closes #640
  • Loading branch information
sleberknight committed Dec 8, 2021
1 parent 4402698 commit 581b376
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/main/java/org/kiwiproject/base/DefaultEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.Date;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalLong;
import java.util.Properties;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -130,12 +131,12 @@ public long currentPid() {
}

@Override
public Optional<Long> tryGetCurrentPid() {
public OptionalLong tryGetCurrentPid() {
try {
return Optional.of(currentPid());
return OptionalLong.of(currentPid());
} catch (Exception e) {
LOG.trace("Unable to get current process ID", e);
return Optional.empty();
return OptionalLong.empty();
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/kiwiproject/base/KiwiEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.Date;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalLong;
import java.util.Properties;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -180,7 +181,7 @@ public interface KiwiEnvironment {
* @see ProcessHandle#current()
* @see ProcessHandle#pid()
*/
Optional<Long> tryGetCurrentPid();
OptionalLong tryGetCurrentPid();

/**
* Returns the process ID of the currently executing JVM. This method does not perform any error checking. Use
Expand Down

0 comments on commit 581b376

Please sign in to comment.