Skip to content

Commit 48a2706

Browse files
author
Vincent Potucek
committed
Test unused stream in DefaultPluginXmlFactory#write
1 parent e68ec7d commit 48a2706

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultPluginXmlFactory.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,47 +59,46 @@ public PluginDescriptor read(@Nonnull XmlReaderRequest request) throws XmlReader
5959
if (inputStream == null && reader == null && path == null && url == null) {
6060
throw new IllegalArgumentException("path, url, reader or inputStream must be non null");
6161
}
62-
return read(request, inputStream, reader, path, url);
62+
return read(request.isAddDefaultEntities(), request.isStrict(), inputStream, reader, path, url);
6363
}
6464

6565
private static PluginDescriptor read(
66-
XmlReaderRequest request, InputStream inputStream, Reader reader, Path path, URL url) {
66+
boolean addDefaultEntities, boolean strict, InputStream inputStream, Reader reader, Path path, URL url) {
6767
try {
6868
PluginDescriptorStaxReader xml = new PluginDescriptorStaxReader();
69-
xml.setAddDefaultEntities(request.isAddDefaultEntities());
69+
xml.setAddDefaultEntities(addDefaultEntities);
7070
if (inputStream != null) {
71-
return read(request, xml, inputStream);
71+
return read(xml, inputStream, strict);
7272
} else if (reader != null) {
73-
return xml.read(reader, request.isStrict());
73+
return xml.read(reader, strict);
7474
} else if (path != null) {
7575
try (InputStream is = Files.newInputStream(path)) {
76-
return read(request, xml, is);
76+
return read(xml, is, strict);
7777
}
7878
}
7979
try (InputStream is = url.openStream()) {
80-
return read(request, xml, is);
80+
return read(xml, is, strict);
8181
}
8282
} catch (IOException | XMLStreamException e) {
8383
throw new XmlReaderException("Unable to read plugin: " + getMessage(e), getLocation(e), e);
8484
}
8585
}
8686

87-
private static PluginDescriptor read(XmlReaderRequest request, PluginDescriptorStaxReader xml, InputStream is)
87+
private static PluginDescriptor read(PluginDescriptorStaxReader xml, InputStream is, boolean strict)
8888
throws XMLStreamException {
89-
return xml.read(is, request.isStrict());
89+
return xml.read(is, strict);
9090
}
9191

9292
@Override
9393
public void write(XmlWriterRequest<PluginDescriptor> request) throws XmlWriterException {
9494
nonNull(request, "request");
95-
PluginDescriptor content = nonNull(request.getContent(), "content");
9695
Path path = request.getPath();
9796
OutputStream outputStream = request.getOutputStream();
9897
Writer writer = request.getWriter();
9998
if (writer == null && outputStream == null && path == null) {
10099
throw new IllegalArgumentException("writer, output stream, or path must be non null");
101100
}
102-
write(writer, content, outputStream, path);
101+
write(writer, request.getContent(), outputStream, path);
103102
}
104103

105104
private static void write(Writer writer, PluginDescriptor content, OutputStream outputStream, Path path) {

0 commit comments

Comments
 (0)