Skip to content

Commit

Permalink
CB-5127 web application instance id fix (#2603)
Browse files Browse the repository at this point in the history
Co-authored-by: DenisSinelnikov <[email protected]>
  • Loading branch information
yagudin10 and DenisSinelnikov authored May 14, 2024
1 parent b40646e commit 6061ec3
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
import org.jkiss.dbeaver.model.auth.SMCredentialsProvider;
import org.jkiss.dbeaver.model.auth.SMSessionContext;
import org.jkiss.dbeaver.model.data.json.JSONUtils;
import org.jkiss.dbeaver.model.impl.app.ApplicationRegistry;
import org.jkiss.dbeaver.model.rm.RMController;
import org.jkiss.dbeaver.model.rm.RMProject;
import org.jkiss.dbeaver.model.secret.DBSSecretController;
import org.jkiss.dbeaver.model.websocket.event.WSEventController;
import org.jkiss.dbeaver.registry.BaseApplicationImpl;
import org.jkiss.dbeaver.registry.BaseWorkspaceImpl;
import org.jkiss.dbeaver.runtime.IVariableResolver;
import org.jkiss.dbeaver.utils.GeneralUtils;
import org.jkiss.dbeaver.utils.RuntimeUtils;
Expand All @@ -64,6 +64,8 @@ public abstract class BaseWebApplication extends BaseApplicationImpl implements

private static final Log log = Log.getLog(BaseWebApplication.class);

private String instanceId;

@NotNull
@Override
public DBPWorkspace createWorkspace(@NotNull DBPPlatform platform, @NotNull IWorkspace eclipseWorkspace) {
Expand Down Expand Up @@ -242,14 +244,17 @@ public Object start(IApplicationContext context) {
protected abstract void startServer() throws DBException;

@Override
public String getApplicationInstanceId() throws DBException {
try {
byte[] macAddress = RuntimeUtils.getLocalMacAddress();
String appId = ApplicationRegistry.getInstance().getApplication().getId();
return appId + "_" + CommonUtils.toHexString(macAddress) + getServerPort();
} catch (Exception e) {
throw new DBException("Error during generation instance id generation", e);
public synchronized String getApplicationInstanceId() throws DBException {
if (instanceId == null) {
try {
byte[] macAddress = RuntimeUtils.getLocalMacAddress();
// workspace id from is read from property file
instanceId = BaseWorkspaceImpl.readWorkspaceIdProperty() + "_" + CommonUtils.toHexString(macAddress);
} catch (Exception e) {
throw new DBException("Error during generation instance id generation", e);
}
}
return instanceId;
}

public String getApplicationId() {
Expand Down

0 comments on commit 6061ec3

Please sign in to comment.