Skip to content

Commit

Permalink
Merge pull request #16497 from iterate-ch/bugfix/GH-16489
Browse files Browse the repository at this point in the history
Revert default hostname configurator as no-op
  • Loading branch information
dkocher authored Nov 7, 2024
2 parents 1656d8f + 8dc4c2e commit d9de9fa
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 18 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/ch/cyberduck/core/AbstractProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ public <T> T getFeature(final Class<T> type) {
return (T) new DefaultComparisonService(this);
}
if(type == HostnameConfigurator.class) {
return (T) new HostnameConfigurator.DefaultHostnameConfigurator(this);
return (T) HostnameConfigurator.DISABLED;
}
if(type == CredentialsConfigurator.class) {
return (T) CredentialsConfigurator.DISABLED;
Expand Down
19 changes: 4 additions & 15 deletions core/src/main/java/ch/cyberduck/core/HostnameConfigurator.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/


import org.apache.commons.lang3.StringUtils;

/**
* Configurator for resolving hostname from alias
*/
Expand All @@ -42,29 +40,20 @@ public interface HostnameConfigurator {

HostnameConfigurator reload();

class DefaultHostnameConfigurator implements HostnameConfigurator {
private final AbstractProtocol protocol;

public DefaultHostnameConfigurator(final AbstractProtocol protocol) {
this.protocol = protocol;
}

HostnameConfigurator DISABLED = new HostnameConfigurator() {
@Override
public String getHostname(final String alias) {
if(StringUtils.isBlank(protocol.getDefaultHostname())) {
return alias;
}
return protocol.getDefaultHostname();
return alias;
}

@Override
public int getPort(final String alias) {
return protocol.getDefaultPort();
return -1;
}

@Override
public HostnameConfigurator reload() {
return this;
}
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ public void hostFieldDidChange(final NSNotification sender) {
}
else {
bookmark.setHostname(input);
bookmark.setPort(HostnameConfiguratorFactory.get(bookmark.getProtocol()).getPort(input));
bookmark.setCredentials(CredentialsConfiguratorFactory.get(bookmark.getProtocol()).configure(bookmark));
}
this.update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ internal void View_ChangedServerEvent()
else
{
_host.setHostname(input);
_host.setPort(HostnameConfiguratorFactory.get(_host.getProtocol()).getPort(input));
_host.setCredentials(CredentialsConfiguratorFactory.get(_host.getProtocol()).configure(_host));
}

Expand Down

0 comments on commit d9de9fa

Please sign in to comment.