Skip to content

Commit 9556942

Browse files
author
Vincent Potucek
committed
fix spelling leveraging Oxford comma
1 parent 00c0d7d commit 9556942

2 files changed

Lines changed: 13 additions & 324 deletions

File tree

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

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
*/
1919
package org.apache.maven.impl;
2020

21-
import javax.xml.stream.XMLStreamException;
22-
23-
import java.io.IOException;
2421
import java.io.InputStream;
2522
import java.io.OutputStream;
2623
import java.io.Reader;
@@ -48,71 +45,58 @@
4845
@Named
4946
@Singleton
5047
public class DefaultPluginXmlFactory implements PluginXmlFactory {
51-
5248
@Override
5349
public PluginDescriptor read(@Nonnull XmlReaderRequest request) throws XmlReaderException {
5450
nonNull(request, "request");
5551
Path path = request.getPath();
5652
URL url = request.getURL();
5753
Reader reader = request.getReader();
5854
InputStream inputStream = request.getInputStream();
59-
if (inputStream == null && reader == null && path == null && url == null) {
55+
if (path == null && url == null && reader == null && inputStream == null) {
6056
throw new IllegalArgumentException("path, url, reader or inputStream must be non null");
6157
}
62-
return read(request.isAddDefaultEntities(), request.isStrict(), inputStream, reader, path, url);
63-
}
64-
65-
private static PluginDescriptor read(
66-
boolean addDefaultEntities, boolean strict, InputStream inputStream, Reader reader, Path path, URL url) {
6758
try {
6859
PluginDescriptorStaxReader xml = new PluginDescriptorStaxReader();
69-
xml.setAddDefaultEntities(addDefaultEntities);
60+
xml.setAddDefaultEntities(request.isAddDefaultEntities());
7061
if (inputStream != null) {
71-
return read(xml, inputStream, strict);
62+
return xml.read(inputStream, request.isStrict());
7263
} else if (reader != null) {
73-
return xml.read(reader, strict);
64+
return xml.read(reader, request.isStrict());
7465
} else if (path != null) {
7566
try (InputStream is = Files.newInputStream(path)) {
76-
return read(xml, is, strict);
67+
return xml.read(is, request.isStrict());
68+
}
69+
} else {
70+
try (InputStream is = url.openStream()) {
71+
return xml.read(is, request.isStrict());
7772
}
7873
}
79-
try (InputStream is = url.openStream()) {
80-
return read(xml, is, strict);
81-
}
82-
} catch (IOException | XMLStreamException e) {
74+
} catch (Exception e) {
8375
throw new XmlReaderException("Unable to read plugin: " + getMessage(e), getLocation(e), e);
8476
}
8577
}
8678

87-
private static PluginDescriptor read(PluginDescriptorStaxReader xml, InputStream is, boolean strict)
88-
throws XMLStreamException {
89-
return xml.read(is, strict);
90-
}
91-
9279
@Override
9380
public void write(XmlWriterRequest<PluginDescriptor> request) throws XmlWriterException {
9481
nonNull(request, "request");
82+
PluginDescriptor content = nonNull(request.getContent(), "content");
9583
Path path = request.getPath();
9684
OutputStream outputStream = request.getOutputStream();
9785
Writer writer = request.getWriter();
9886
if (writer == null && outputStream == null && path == null) {
9987
throw new IllegalArgumentException("writer, output stream, or path must be non null");
10088
}
101-
write(writer, request.getContent(), outputStream, path);
102-
}
103-
104-
private static void write(Writer writer, PluginDescriptor content, OutputStream outputStream, Path path) {
10589
try {
10690
if (writer != null) {
10791
new PluginDescriptorStaxWriter().write(writer, content);
10892
} else if (outputStream != null) {
10993
new PluginDescriptorStaxWriter().write(outputStream, content);
11094
} else {
11195
try (OutputStream os = Files.newOutputStream(path)) {
112-
new PluginDescriptorStaxWriter().write(os, content);
96+
new PluginDescriptorStaxWriter().write(outputStream, content);
11397
}
11498
}
115-
} catch (IOException | XMLStreamException e) {
99+
} catch (Exception e) {
116100
throw new XmlWriterException("Unable to write plugin: " + getMessage(e), getLocation(e), e);
117101
}
118102
}

impl/maven-impl/src/test/java/org/apache/maven/impl/DefaultPluginXmlFactoryTest.java

Lines changed: 0 additions & 295 deletions
This file was deleted.

0 commit comments

Comments
 (0)