Skip to content

Commit

Permalink
Fix compatibility with TeamCity 2024.03: bundled XStream was updated …
Browse files Browse the repository at this point in the history
…and now requires explicit allowlist

Also, XStreamException should not lead to BeanCreationException — plugin unavailability to load.
Context: https://youtrack.jetbrains.com/issue/TW-86787/The-artifactory-plugin-is-incompatible-with-the-latest-TeamCity-version
  • Loading branch information
VladRassokhin committed Mar 12, 2024
1 parent c15f10d commit 8865514
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.google.common.collect.Lists;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.XStreamException;
import jetbrains.buildServer.log.Loggers;
import jetbrains.buildServer.serverSide.SProject;
import jetbrains.buildServer.serverSide.SProjectFeatureDescriptor;
Expand Down Expand Up @@ -60,6 +61,7 @@ public ServerConfigPersistenceManager(@NotNull ServerPaths serverPaths) {
xStream = new XStream();
xStream.setClassLoader(SerializableServers.class.getClassLoader());
xStream.processAnnotations(new Class[]{SerializableServer.class, SerializableServers.class});
xStream.allowTypes(new Class[]{SerializableServers.class, SerializableServer.class, SerializableCredentials.class});

configFile = new File(serverPaths.getConfigDir(), CONFIG_FILE_NAME);
loadSettings();
Expand Down Expand Up @@ -121,7 +123,7 @@ private void loadSettings() {
} catch (NumberFormatException ignored) {}
}
}
} catch (FileNotFoundException e) {
} catch (XStreamException | FileNotFoundException e) {
Loggers.SERVER.error("Failed to load Artifactory config file: " + configFile, e);
} finally {
IOUtils.closeQuietly(inputStream);
Expand Down Expand Up @@ -228,7 +230,7 @@ public synchronized void persist() {
configs.addConfiguredServer(serializableServer);
}
xStream.toXML(configs, outputStream);
} catch (FileNotFoundException e) {
} catch (XStreamException | FileNotFoundException e) {
Loggers.SERVER.error("Failed to save Artifactory config file: " + configFile, e);
} finally {
IOUtils.closeQuietly(outputStream);
Expand Down

0 comments on commit 8865514

Please sign in to comment.