recover jetbrains protocol args

This commit is contained in:
Konstantin Bulenkov
2016-01-13 16:08:38 +01:00
parent b079c088de
commit a738a08074
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
*/
package com.intellij.idea;
import com.intellij.openapi.application.JetBrainsProtocolHandler;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.io.FileUtil;
@@ -189,6 +190,7 @@ public final class SocketLock {
@NotNull
private static ActivateStatus tryActivate(int portNumber, @NotNull Collection<String> paths, @NotNull String[] args) {
log("trying: port=%s", portNumber);
args = checkForJetBrainsProtocolCommand(args);
try {
Socket socket = new Socket(NetUtils.getLoopbackAddress(), portNumber);
try {
@@ -245,6 +247,14 @@ public final class SocketLock {
return ActivateStatus.NO_INSTANCE;
}
private static String[] checkForJetBrainsProtocolCommand(String[] args) {
final String jbUrl = System.getProperty(JetBrainsProtocolHandler.class.getName());
if (jbUrl != null) {
return new String[]{jbUrl};
}
return args;
}
private static class MyChannelInboundHandler extends MessageDecoder {
private enum State {HEADER, CONTENT}