From 8865514eeab7bf2e1c1f7522b7f1c6541194f078 Mon Sep 17 00:00:00 2001 From: Vladislav Rassokhin Date: Tue, 12 Mar 2024 11:44:49 +0100 Subject: [PATCH] Fix compatibility with TeamCity 2024.03: bundled XStream was updated and now requires explicit allowlist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../server/global/ServerConfigPersistenceManager.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/jfrog/teamcity/server/global/ServerConfigPersistenceManager.java b/server/src/main/java/org/jfrog/teamcity/server/global/ServerConfigPersistenceManager.java index 59743ca..77ab5f8 100644 --- a/server/src/main/java/org/jfrog/teamcity/server/global/ServerConfigPersistenceManager.java +++ b/server/src/main/java/org/jfrog/teamcity/server/global/ServerConfigPersistenceManager.java @@ -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; @@ -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(); @@ -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); @@ -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);