Skip to content

Commit

Permalink
Merge pull request #484 from basil/stax
Browse files Browse the repository at this point in the history
Switch from XML Pull Parser v3 to Streaming API for XML (StAX) on newer cores
  • Loading branch information
jtnord authored Sep 22, 2023
2 parents d78ad6c + f081d47 commit 50ac1f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.xml.XppDriver;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
Expand Down Expand Up @@ -541,7 +540,7 @@ public HttpResponse doCreateDomain(StaplerRequest req) throws ServletException,
}

Domain domain = (Domain)
Items.XSTREAM.unmarshal(new XppDriver().createReader(new StringReader(out.toString())));
Items.XSTREAM.unmarshal(XStream2.getDefaultDriver().createReader(new StringReader(out.toString())));
if (getStore().addDomain(domain)) {
return HttpResponses.ok();
} else {
Expand Down Expand Up @@ -804,7 +803,7 @@ public HttpResponse doCreateCredentials(StaplerRequest req) throws ServletExcept
}

Credentials credentials = (Credentials)
Items.XSTREAM.unmarshal(new XppDriver().createReader(new StringReader(out.toString())));
Items.XSTREAM.unmarshal(XStream2.getDefaultDriver().createReader(new StringReader(out.toString())));
if (getStore().addCredentials(domain, credentials)) {
return HttpResponses.ok();
} else {
Expand Down Expand Up @@ -998,7 +997,7 @@ public void updateByXml(Source source) throws IOException {
}

Domain replacement = (Domain)
Items.XSTREAM.unmarshal(new XppDriver().createReader(new StringReader(out.toString())));
Items.XSTREAM.unmarshal(XStream2.getDefaultDriver().createReader(new StringReader(out.toString())));
getStore().updateDomain(domain, replacement);
}

Expand Down Expand Up @@ -1505,7 +1504,7 @@ public void updateByXml(Source source) throws IOException {
}

Credentials credentials = (Credentials)
Items.XSTREAM.unmarshal(new XppDriver().createReader(new StringReader(out.toString())));
Items.XSTREAM.unmarshal(XStream2.getDefaultDriver().createReader(new StringReader(out.toString())));
getStore().updateCredentials(domain.getDomain(), this.credentials, credentials);
}

Expand Down Expand Up @@ -1561,4 +1560,5 @@ public String getDisplayName() {
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.cloudbees.plugins.credentials.common.IdCredentials;
import com.cloudbees.plugins.credentials.domains.Domain;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.xml.XppDriver;
import hudson.cli.CLICommand;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -42,6 +41,7 @@
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

import hudson.util.XStream2;
import jenkins.util.xml.XMLUtils;
import org.apache.commons.lang.StringUtils;
import org.xml.sax.SAXException;
Expand Down Expand Up @@ -103,7 +103,7 @@ protected static HierarchicalStreamReader safeXmlStreamReader(Source source) thr
} catch (TransformerException | SAXException e) {
throw new IOException("Failed to parse", e);
}
return new XppDriver().createReader(new StringReader(out.toString()));
return XStream2.getDefaultDriver().createReader(new StringReader(out.toString()));

}
}

0 comments on commit 50ac1f0

Please sign in to comment.