mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-11 11:06:25 +00:00
Making nullOut behavior opt-in, so limiting to AbstractItem and View (and in particular not Jenkins).
This commit is contained in:
5 files changed
+60
-18
No files matched your search
@@ -159,10 +159,25 @@ public final class XmlFile {
|
||||
* if the XML representation is completely new.
|
||||
*/
|
||||
public Object unmarshal( Object o ) throws IOException {
|
||||
return unmarshal(o, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Variant of {@link #unmarshal(Object)} applying {@link XStream2#unmarshal(HierarchicalStreamReader, Object, DataHolder, boolean)}.
|
||||
* @since FIXME
|
||||
*/
|
||||
public Object unmarshalNullingOut(Object o) throws IOException {
|
||||
return unmarshal(o, true);
|
||||
}
|
||||
|
||||
private Object unmarshal(Object o, boolean nullOut) throws IOException {
|
||||
try (InputStream in = new BufferedInputStream(Files.newInputStream(file.toPath()))) {
|
||||
// TODO: expose XStream the driver from XStream
|
||||
return xs.unmarshal(DEFAULT_DRIVER.createReader(in), o);
|
||||
if (nullOut) {
|
||||
return ((XStream2) xs).unmarshal(DEFAULT_DRIVER.createReader(in), o, null, true);
|
||||
} else {
|
||||
return xs.unmarshal(DEFAULT_DRIVER.createReader(in), o);
|
||||
}
|
||||
} catch (RuntimeException | Error e) {
|
||||
throw new IOException("Unable to read "+file,e);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user