axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r562648 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util: PrettyPrinter.java XMLPrettyPrinter.java
Date Sat, 04 Aug 2007 03:18:59 GMT
Author: dims
Date: Fri Aug  3 20:18:59 2007
New Revision: 562648

URL: http://svn.apache.org/viewvc?view=rev&rev=562648
Log:
Fix problem with prettifying bad xsd's (where there are wrongly encoded characters, the file
length becomes zero). Jalopy's javadoc parser is not upto snuff, barfs on jaxbri generated
code, so just don't parse javadocs. Both problems were found when fixing AXIS2-3064

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PrettyPrinter.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PrettyPrinter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PrettyPrinter.java?view=diff&rev=562648&r1=562647&r2=562648
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PrettyPrinter.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PrettyPrinter.java
Fri Aug  3 20:18:59 2007
@@ -79,15 +79,9 @@
             Object settings = instance.invoke(null, new Object[]{});
 
             Class clazz3 = Loader.loadClass("de.hunsicker.jalopy.storage.ConventionKeys");
-            Field field = clazz3.getField("COMMENT_JAVADOC_PARSE");
+            Field field = clazz3.getField("COMMENT_FORMAT_MULTI_LINE");
             Object key = field.get(null);
-
             Method put = clazz2.getMethod("put", new Class[]{key.getClass(), String.class});
-            put.invoke(settings, new Object[]{key, "true"});
-
-            field = clazz3.getField("COMMENT_FORMAT_MULTI_LINE");
-            key = field.get(null);
-            put = clazz2.getMethod("put", new Class[]{key.getClass(), String.class});
             put.invoke(settings, new Object[]{key, "true"});
 
             // format and overwrite the given input file

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java?view=diff&rev=562648&r1=562647&r2=562648
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java
Fri Aug  3 20:18:59 2007
@@ -38,6 +38,7 @@
 import java.io.OutputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayInputStream;
+import java.io.IOException;
 
 /**
  * An XML pretty printer based on xsl stylesheets
@@ -52,10 +53,13 @@
      * @param file
      */
     public static void prettify(final File file) {
+        InputStream inputStream = null;
+        FileOutputStream outputStream = null;
+        byte[] byteArray = null;
         try {
-            InputStream inputStream = new ByteArrayInputStream(IOUtils.getStreamAsByteArray(new
FileInputStream(file)));
-
-            FileOutputStream outputStream = new FileOutputStream(file);
+            byteArray = IOUtils.getStreamAsByteArray(new FileInputStream(file));
+            inputStream = new ByteArrayInputStream(byteArray);
+            outputStream = new FileOutputStream(file);
 
             Source stylesheetSource = new StreamSource(new ByteArrayInputStream(prettyPrintStylesheet.getBytes()));
             Source xmlSource = new StreamSource(inputStream);
@@ -81,12 +85,32 @@
             inputStream.close();
             outputStream.close();
             log.debug("Pretty printed file : " + file);
-        } catch (Exception e) {
-            log.warn("Exception occurred while trying to pretty print file " + file, e);
         } catch (Throwable t) {
             log.debug("Exception occurred while trying to pretty print file " + file, t);
+            try {
+                if (byteArray != null) {
+                    outputStream = new FileOutputStream(file);
+                    outputStream.write(byteArray);
+                }
+            } catch (IOException e) {
+                log.debug(e.getMessage(), e);
+            }
+        } finally {
+            if (inputStream != null) {
+                try {
+                    inputStream.close();
+                } catch (IOException e) {
+                    log.debug(e.getMessage(), e);
+                }
+            }
+            if (outputStream != null) {
+                try {
+                    outputStream.close();
+                } catch (IOException e) {
+                    log.debug(e.getMessage(), e);
+                }
+            }
         }
-
     }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message