Polish contribution

See gh-22383
This commit is contained in:
Sam Brannen 2019-06-11 17:44:49 +03:00
parent b51e553f55
commit 44a00b58c8
3 changed files with 4 additions and 4 deletions

View File

@ -28,6 +28,7 @@ import java.util.Set;
* Marshaller to write {@link CandidateComponentsMetadata} as properties. * Marshaller to write {@link CandidateComponentsMetadata} as properties.
* *
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Vedran Pavic
* @since 5.0 * @since 5.0
*/ */
abstract class PropertiesMarshaller { abstract class PropertiesMarshaller {
@ -35,7 +36,7 @@ abstract class PropertiesMarshaller {
public static void write(CandidateComponentsMetadata metadata, OutputStream out) throws IOException { public static void write(CandidateComponentsMetadata metadata, OutputStream out) throws IOException {
Properties props = new SortedProperties(true); Properties props = new SortedProperties(true);
metadata.getItems().forEach(m -> props.put(m.getType(), String.join(",", m.getStereotypes()))); metadata.getItems().forEach(m -> props.put(m.getType(), String.join(",", m.getStereotypes())));
props.store(out, ""); props.store(out, null);
} }
public static CandidateComponentsMetadata read(InputStream in) throws IOException { public static CandidateComponentsMetadata read(InputStream in) throws IOException {

View File

@ -93,7 +93,7 @@ class SortedProperties extends Properties {
super.store(baos, (this.omitComments ? null : comments)); super.store(baos, (this.omitComments ? null : comments));
String contents = new String(baos.toByteArray(), StandardCharsets.ISO_8859_1); String contents = new String(baos.toByteArray(), StandardCharsets.ISO_8859_1);
for (String line : contents.split(EOL)) { for (String line : contents.split(EOL)) {
if (!this.omitComments || !line.startsWith("#")) { if (!(this.omitComments && line.startsWith("#"))) {
out.write((line + EOL).getBytes(StandardCharsets.ISO_8859_1)); out.write((line + EOL).getBytes(StandardCharsets.ISO_8859_1));
} }
} }
@ -105,7 +105,7 @@ class SortedProperties extends Properties {
super.store(stringWriter, (this.omitComments ? null : comments)); super.store(stringWriter, (this.omitComments ? null : comments));
String contents = stringWriter.toString(); String contents = stringWriter.toString();
for (String line : contents.split(EOL)) { for (String line : contents.split(EOL)) {
if (!this.omitComments || !line.startsWith("#")) { if (!(this.omitComments && line.startsWith("#"))) {
writer.write(line + EOL); writer.write(line + EOL);
} }
} }

View File

@ -27,7 +27,6 @@ import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
/** /**
* Tests for {@link PropertiesMarshaller}. * Tests for {@link PropertiesMarshaller}.
* *