mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
auto expressions spec: init duplication check
This commit is contained in:
@@ -29,6 +29,7 @@ import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import io.netty.channel.socket.oio.OioSocketChannel;
|
||||
import io.netty.handler.codec.http.HttpObjectAggregator;
|
||||
import io.netty.handler.codec.http.HttpServerCodec;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.ide.PooledThreadExecutor;
|
||||
|
||||
@@ -109,7 +110,7 @@ public final class NettyUtil {
|
||||
}
|
||||
|
||||
// applicable only in case of ClientBootstrap&OioClientSocketChannelFactory
|
||||
public static void closeAndReleaseFactory(Channel channel) {
|
||||
public static void closeAndReleaseFactory(@NotNull Channel channel) {
|
||||
EventLoop channelFactory = channel.eventLoop();
|
||||
try {
|
||||
channel.close().awaitUninterruptibly();
|
||||
|
||||
+10
-4
@@ -11,7 +11,7 @@ import org.jetbrains.jsonProtocol.Request;
|
||||
import org.jetbrains.rpc.MessageHandler;
|
||||
import org.jetbrains.rpc.MessageWriter;
|
||||
|
||||
public final class StandaloneVmHelper extends MessageWriter {
|
||||
public class StandaloneVmHelper extends MessageWriter {
|
||||
private volatile Channel channel;
|
||||
|
||||
private final VmEx vm;
|
||||
@@ -61,10 +61,11 @@ public final class StandaloneVmHelper extends MessageWriter {
|
||||
return channel != null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ActionCallback detach() {
|
||||
final Channel currentChannel = channel;
|
||||
if (currentChannel == null) {
|
||||
return new ActionCallback.Done();
|
||||
return ActionCallback.DONE;
|
||||
}
|
||||
|
||||
vm.getCommandProcessor().cancelWaitingRequests();
|
||||
@@ -73,8 +74,7 @@ public final class StandaloneVmHelper extends MessageWriter {
|
||||
if (disconnectRequest == null) {
|
||||
vm.getCommandProcessor().closed();
|
||||
channel = null;
|
||||
NettyUtil.closeAndReleaseFactory(currentChannel);
|
||||
return ActionCallback.DONE;
|
||||
return closeChannel(currentChannel);
|
||||
}
|
||||
|
||||
ActionCallback callback = vm.getCommandProcessor().send(disconnectRequest);
|
||||
@@ -95,4 +95,10 @@ public final class StandaloneVmHelper extends MessageWriter {
|
||||
});
|
||||
return subCallback;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected ActionCallback closeChannel(@NotNull Channel channel) {
|
||||
NettyUtil.closeAndReleaseFactory(channel);
|
||||
return ActionCallback.DONE;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -13,7 +13,7 @@ public interface BrowserConnection {
|
||||
|
||||
void addListener(@NotNull SocketConnectionListener listener, @NotNull Disposable parentDisposable);
|
||||
|
||||
void executeOnStart(@NotNull Runnable Runnable);
|
||||
void executeOnStart(@NotNull Runnable runnable);
|
||||
|
||||
@Nullable
|
||||
WebBrowser getBrowser();
|
||||
|
||||
+18
-9
@@ -23,7 +23,7 @@ public abstract class VmConnection<T extends Vm> implements Disposable, BrowserC
|
||||
|
||||
protected volatile T vm;
|
||||
|
||||
private final ActionCallback started = new ActionCallback();
|
||||
private final ActionCallback opened = new ActionCallback();
|
||||
|
||||
private final AtomicBoolean closed = new AtomicBoolean();
|
||||
|
||||
@@ -41,9 +41,14 @@ public abstract class VmConnection<T extends Vm> implements Disposable, BrowserC
|
||||
dispatcher.addListener(listener, parentDisposable);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ActionCallback opened() {
|
||||
return opened;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeOnStart(@NotNull Runnable runnable) {
|
||||
started.doWhenDone(runnable);
|
||||
opened.doWhenDone(runnable);
|
||||
}
|
||||
|
||||
protected void setState(@NotNull ConnectionStatus status, @Nullable String message) {
|
||||
@@ -51,8 +56,12 @@ public abstract class VmConnection<T extends Vm> implements Disposable, BrowserC
|
||||
}
|
||||
|
||||
protected void setState(@NotNull ConnectionStatus status, @Nullable String message, @Nullable HyperlinkListener messageLinkListener) {
|
||||
ConnectionState oldState = state.getAndSet(new ConnectionState(status, message, messageLinkListener));
|
||||
ConnectionState newState = new ConnectionState(status, message, messageLinkListener);
|
||||
ConnectionState oldState = state.getAndSet(newState);
|
||||
if (oldState == null || oldState.getStatus() != status) {
|
||||
if (status == ConnectionStatus.CONNECTION_FAILED) {
|
||||
opened.reject(newState.getMessage());
|
||||
}
|
||||
connectionDispatcher.getMulticaster().statusChanged(status);
|
||||
}
|
||||
}
|
||||
@@ -67,7 +76,7 @@ public abstract class VmConnection<T extends Vm> implements Disposable, BrowserC
|
||||
}
|
||||
|
||||
protected void startProcessing() {
|
||||
started.setDone();
|
||||
opened.setDone();
|
||||
}
|
||||
|
||||
public final void close(@Nullable String message, @NotNull ConnectionStatus status) {
|
||||
@@ -75,9 +84,8 @@ public abstract class VmConnection<T extends Vm> implements Disposable, BrowserC
|
||||
return;
|
||||
}
|
||||
|
||||
vm = null;
|
||||
if (!started.isProcessed()) {
|
||||
started.setRejected();
|
||||
if (!opened.isProcessed()) {
|
||||
opened.setRejected();
|
||||
}
|
||||
setState(status, message);
|
||||
Disposer.dispose(this, false);
|
||||
@@ -85,11 +93,12 @@ public abstract class VmConnection<T extends Vm> implements Disposable, BrowserC
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
vm = null;
|
||||
}
|
||||
|
||||
public ActionCallback detachAndClose() {
|
||||
if (!started.isProcessed()) {
|
||||
started.setRejected();
|
||||
if (!opened.isProcessed()) {
|
||||
opened.setRejected();
|
||||
}
|
||||
|
||||
Vm currentVm = vm;
|
||||
|
||||
+1
@@ -294,6 +294,7 @@ public abstract class OutMessage {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public final CharSequence toJson() {
|
||||
return stringWriter.getBuffer();
|
||||
|
||||
+3
@@ -1,6 +1,9 @@
|
||||
package org.jetbrains.jsonProtocol;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface Request {
|
||||
@NotNull
|
||||
CharSequence toJson();
|
||||
|
||||
String getMethodName();
|
||||
|
||||
Reference in New Issue
Block a user