Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
* @since 2.0.1
*/
public class ByteChannelWrapper implements ByteChannel {

private final ByteChannel socket;

public ByteChannelWrapper(ByteChannel socket) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ void ensureInitialized() throws IOException {
}

SocketChannel createClient() throws IOException {
String familyProp = System.getProperty(IpcServer.SYSTEM_PROP_FAMILY, IpcServer.DEFAULT_FAMILY);
SocketFamily family = familyProp != null ? SocketFamily.valueOf(familyProp) : SocketFamily.inet;
SocketFamily family =
SocketFamily.valueOf(System.getProperty(IpcServer.SYSTEM_PROP_FAMILY, IpcServer.DEFAULT_FAMILY));

Path lockPath = this.lockPath.toAbsolutePath().normalize();
Path lockFile =
Expand Down Expand Up @@ -414,7 +414,7 @@ void unlock(String contextId) {
*/
void stopServer() {
try {
List<String> response = send(Arrays.asList(REQUEST_STOP), Long.MAX_VALUE, TimeUnit.MILLISECONDS);
List<String> response = send(List.of(REQUEST_STOP), Long.MAX_VALUE, TimeUnit.MILLISECONDS);
if (response.size() != 1 || !RESPONSE_STOP.equals(response.get(0))) {
throw new IOException("Unexpected response: " + response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
* @since 2.0.1
*/
public class IpcMessages {

public static final String REQUEST_CONTEXT = "request-context";
public static final String REQUEST_ACQUIRE = "request-acquire";
public static final String REQUEST_CLOSE = "request-close";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,5 @@ public void doUnlock() {
}
}

private static final class Ctx {
private final boolean acted;
private final String contextId;
private final boolean shared;

private Ctx(boolean acted, String contextId, boolean shared) {
this.acted = acted;
this.contextId = contextId;
this.shared = shared;
}
}
private record Ctx(boolean acted, String contextId, boolean shared) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public IpcNamedLockFactory(Path ipcHome) {
requireNonNull(ipcHome);
Path repository = ipcHome.resolve("repository");
Path logPath = ipcHome.resolve("log");
Path syncPath = null;
this.client = new IpcClient(repository, logPath, syncPath);
this.client = new IpcClient(repository, logPath, null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ private void client(SocketChannel socket) {
}
break;
case IpcMessages.REQUEST_ACQUIRE:
if (request.size() < 1) {
if (request.isEmpty()) {
throw new IOException(
"Expected at least one argument for " + command + " but got " + request);
}
Expand Down Expand Up @@ -321,7 +321,7 @@ private void client(SocketChannel socket) {
}
break;
case IpcMessages.REQUEST_STOP:
if (request.size() != 0) {
if (!request.isEmpty()) {
throw new IOException("Expected zero argument for " + command + " but got " + request);
}
synchronized (output) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,11 @@ public enum SocketFamily {
unix;

public ServerSocketChannel openServerSocket() throws IOException {
switch (this) {
case inet:
return ServerSocketChannel.open().bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0);
case unix:
return ServerSocketChannel.open(StandardProtocolFamily.UNIX).bind(null, 0);
default:
throw new IllegalStateException();
}
return switch (this) {
case inet -> ServerSocketChannel.open().bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0);
case unix -> ServerSocketChannel.open(StandardProtocolFamily.UNIX).bind(null, 0);
default -> throw new IllegalStateException();
};
}

public static SocketAddress fromString(String str) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void sharedAccess() throws InterruptedException {
}

@Test
@Timeout(15)
@Timeout(25)
public void exclusiveAccess() throws InterruptedException {
CountDownLatch winners = new CountDownLatch(1); // we expect 1 winner
CountDownLatch losers = new CountDownLatch(1); // we expect 1 loser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void sharedAccess(TestInfo testInfo) throws InterruptedException {
}

@Test
@Timeout(15)
@Timeout(25)
public void exclusiveAccess(TestInfo testInfo) throws InterruptedException {
final Collection<NamedLockKey> keys = Collections.singleton(NamedLockKey.of(testInfo.getDisplayName()));
CountDownLatch winners = new CountDownLatch(1); // we expect 1 winner
Expand Down
Loading