-
Notifications
You must be signed in to change notification settings - Fork 21
DO NOT MERGE Gemini "fix" for MCHANGES-467 #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,13 +18,15 @@ | |
| */ | ||
| package org.apache.maven.plugins.changes; | ||
|
|
||
| import java.io.BufferedOutputStream; | ||
| import java.io.IOException; | ||
| import java.io.Writer; | ||
| import java.text.DateFormat; | ||
| import java.text.ParseException; | ||
| import java.util.ArrayList; | ||
| import java.util.Date; | ||
| import java.util.List; | ||
| import java.io.OutputStream; | ||
| import java.util.Locale; | ||
| import java.util.ResourceBundle; | ||
|
|
||
|
|
@@ -161,27 +163,50 @@ public List<String> getSupportedFeedTypes() { | |
| } | ||
|
|
||
| /** | ||
| * Extract a feed and export it to a Writer. | ||
| * Extract a feed and export it to a Writer. This method is deprecated, use | ||
| * {@link #export(List, String, OutputStream)} instead. | ||
| * | ||
| * @param releases the List of Releases. Only the last release is used in the feed. | ||
| * @param feedType The type of the feed to generate. See {@link #isSupportedFeedType(java.lang.String)} for | ||
| * supported values. | ||
| * @param writer a Writer. Note that this is not flushed nor closed upon exit. | ||
| * @throws IOException if an error occurs during export | ||
| * @deprecated Use {@link #export(List, String, OutputStream)} instead. | ||
| */ | ||
| @Deprecated | ||
| public void export(final List<Release> releases, final String feedType, final Writer writer) throws IOException { | ||
| export(releases, feedType, new BufferedOutputStream(new WriterOutputStream(writer))); | ||
| } | ||
|
|
||
| /** | ||
| * Extract a feed and export it to an OutputStream. | ||
| * | ||
| * @param releases the List of Releases. Only the last release is used in the feed. | ||
| * @param feedType The type of the feed to generate. See {@link #isSupportedFeedType(java.lang.String)} for | ||
| * supported values. | ||
| * @param outputStream an OutputStream. Note that this is not flushed nor closed upon exit. | ||
| * @throws IOException if an error occurs during export | ||
| * @since 1.3 | ||
| */ | ||
| public void export(final List<Release> releases, final String feedType, final OutputStream outputStream) | ||
| throws IOException { | ||
| feed.setFeedType(feedType); | ||
| feed.setTitle(title); | ||
| feed.setAuthor(author); | ||
| feed.setPublishedDate(new Date()); | ||
| exportInternal(releases, outputStream); | ||
| } | ||
|
|
||
| private void exportInternal(final List<Release> releases, final OutputStream outputStream) throws IOException { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This implementation probably shouldn't be shared. |
||
|
|
||
| feed.setLink(link); | ||
| feed.setDescription(rbundle.getString("report.changes.text.rssfeed.description")); | ||
| feed.setLanguage(rbundle.getLocale().getLanguage()); | ||
| feed.setEntries(getEntries(releases)); | ||
|
|
||
| try { | ||
| new SyndFeedOutput().output(feed, writer); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. writer variable does not exist. This does not compile. |
||
| } catch (FeedException ex) { | ||
| } catch (FeedException ex) { //NOPMD | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. delete comment |
||
| throw new IOException(ex.getMessage(), ex); | ||
| } | ||
| } | ||
|
|
@@ -235,4 +260,35 @@ private static Date getDate(final String dateRelease, final DateFormat dateForma | |
| return new Date(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Simple {@link OutputStream} implementation that writes to a {@link Writer}. | ||
| * | ||
| * @since 1.3 | ||
| */ | ||
| private static class WriterOutputStream extends OutputStream { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This class is insane. Who would create something this broken? |
||
| private final Writer writer; | ||
|
|
||
| WriterOutputStream(final Writer writer) { | ||
| this.writer = writer; | ||
| } | ||
|
|
||
| @Override | ||
| public void write(final int b) throws IOException { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This all depends on the platform dependent default encoding. |
||
| writer.write(b); | ||
| } | ||
|
|
||
| @Override | ||
| public void write(final byte[] b) throws IOException { | ||
| writer.write(new String(b)); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only works in ASCII and 8859-1 |
||
| } | ||
|
|
||
| @Override | ||
| public void write(final byte[] b, final int off, final int len) throws IOException { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. avoid single letter and abbreviated variable names |
||
| writer.write(new String(b, off, len)); | ||
| } | ||
|
|
||
| } | ||
|
|
||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never sets encoding, which is the point of the bug