maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r1054373 - /maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/AbstractJiraDownloader.java
Date Sun, 02 Jan 2011 09:57:58 GMT
Author: hboutemy
Date: Sun Jan  2 09:57:58 2011
New Revision: 1054373

URL: http://svn.apache.org/viewvc?rev=1054373&view=rev
Log:
[MCHANGES-144] get and store Jira response body in its direct byte form to avoid encoding
issues (both when reading the content and when writing it to a file using platform encoding)
and as a stream to avoid storing the full result in memory

Modified:
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/AbstractJiraDownloader.java

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/AbstractJiraDownloader.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/AbstractJiraDownloader.java?rev=1054373&r1=1054372&r2=1054373&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/AbstractJiraDownloader.java
(original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/AbstractJiraDownloader.java
Sun Jan  2 09:57:58 2011
@@ -36,12 +36,14 @@ import org.apache.maven.project.MavenPro
 import org.apache.maven.settings.Proxy;
 import org.apache.maven.settings.Settings;
 import org.apache.maven.wagon.proxy.ProxyInfo;
+import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.PrintWriter;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.net.URLEncoder;
 import java.util.HashMap;
 import java.util.Locale;
@@ -681,19 +683,25 @@ public abstract class AbstractJiraDownlo
 
             if ( gm.getStatusCode() == HttpStatus.SC_OK )
             {
-                final String strGetResponseBody = gm.getResponseBodyAsString();
+                final InputStream responseBodyStream = gm.getResponseBodyAsStream();
 
                 if ( !output.getParentFile().exists() )
                 {
                     output.getParentFile().mkdirs();
                 }
 
-                // write the reponse to file
-                PrintWriter pw = new PrintWriter( new FileWriter( output ) );
-
-                pw.print( strGetResponseBody );
-
-                pw.close();
+                // write the response to file
+                OutputStream out = null;
+                try
+                {
+                    out = new FileOutputStream( output );
+                    IOUtil.copy( responseBodyStream, out );
+                }
+                finally
+                {
+                    IOUtil.close( out );
+                    IOUtil.close( responseBodyStream );
+                }
 
                 getLog().debug( "Downloading from JIRA was successful" );
             }



Mime
View raw message