diff --git a/platform/platform-impl/src/com/intellij/remote/RemoteSdkFactoryImpl.java b/platform/platform-impl/src/com/intellij/remote/RemoteSdkFactoryImpl.java index 4c146757bf57..92d2c221ce39 100644 --- a/platform/platform-impl/src/com/intellij/remote/RemoteSdkFactoryImpl.java +++ b/platform/platform-impl/src/com/intellij/remote/RemoteSdkFactoryImpl.java @@ -4,6 +4,7 @@ package com.intellij.remote; import com.intellij.ide.IdeBundle; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.projectRoots.SdkModificator; @@ -16,6 +17,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Collection; public abstract class RemoteSdkFactoryImpl implements RemoteSdkFactory { + private static final Logger LOG = Logger.getInstance(RemoteSdkFactoryImpl.class); @Override public Sdk createRemoteSdk(@Nullable Project project, @NotNull T data, @Nullable String sdkName, Collection existingSdks) throws RemoteSdkException { @@ -35,6 +37,14 @@ public abstract class RemoteSdkFactoryImpl im SdkModificator sdkModificator = sdk.getSdkModificator(); sdkModificator.setVersionString(sdkVersion); + + var modifiableAdditionalData = sdkModificator.getSdkAdditionalData(); + if (!(modifiableAdditionalData instanceof RemoteSdkAdditionalData remoteSdkAdditionalData)) { + LOG.error("Expected remote additional data, got " + modifiableAdditionalData + " in " + sdk); + throw new RemoteSdkException("Internal error"); + } + remoteSdkAdditionalData.setValid(true); + Application application = ApplicationManager.getApplication(); Runnable runnable = () -> sdkModificator.commitChanges(); if (application.isDispatchThread()) { @@ -43,8 +53,6 @@ public abstract class RemoteSdkFactoryImpl im application.invokeAndWait(() -> application.runWriteAction(runnable)); } - data.setValid(true); - return sdk; } diff --git a/platform/platform-impl/src/com/intellij/remote/SshConfigCredentialsHolder.java b/platform/platform-impl/src/com/intellij/remote/SshConfigCredentialsHolder.java index 432a06909926..f2a330492f2a 100644 --- a/platform/platform-impl/src/com/intellij/remote/SshConfigCredentialsHolder.java +++ b/platform/platform-impl/src/com/intellij/remote/SshConfigCredentialsHolder.java @@ -7,6 +7,8 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Objects; + public final class SshConfigCredentialsHolder { private static final @NonNls String SSH_CREDENTIALS_ID = "SSH_CREDENTIALS_ID"; @@ -69,4 +71,19 @@ public final class SshConfigCredentialsHolder { myCredentialsId = credentials.myCredentialsId; mySshId = credentials.mySshId == null ? null : credentials.mySshId.clone(); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof SshConfigCredentialsHolder holder)) return false; + + return myCredentialsId.equals(holder.myCredentialsId) && Objects.equals(mySshId, holder.mySshId); + } + + @Override + public int hashCode() { + int result = myCredentialsId.hashCode(); + result = 31 * result + Objects.hashCode(mySshId); + return result; + } }