cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1352386 - in /cxf/branches/2.4.x-fixes: ./ common/common/src/main/java/org/apache/cxf/common/util/Compiler.java systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxWsDynamicClientTest.java
Date Thu, 21 Jun 2012 01:16:39 GMT
Author: ffang
Date: Thu Jun 21 01:16:38 2012
New Revision: 1352386

URL: http://svn.apache.org/viewvc?rev=1352386&view=rev
Log:
Merged revisions 1352383 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes

................
  r1352383 | ffang | 2012-06-21 09:07:34 +0800 (四, 21  6 2012) | 20 lines
  
  Merged revisions 1352376 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes
  
  ................
    r1352376 | ffang | 2012-06-21 08:38:15 +0800 (四, 21  6 2012) | 13 lines
    
    Merged revisions 1352369-1352374 via svnmerge from 
    https://svn.apache.org/repos/asf/cxf/trunk
    
    ........
      r1352369 | ffang | 2012-06-21 07:34:21 +0800 (四, 21  6 2012) | 1 line
      
      [CXF-4387]put long classpath in @argfiles to avoid javac command too long(windows has
limitation for command length)
    ........
      r1352374 | ffang | 2012-06-21 08:28:20 +0800 (四, 21  6 2012) | 1 line
      
      [[CXF-4387]]remove classpath temp file in finally block after javac
    ........
  ................
................

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java
    cxf/branches/2.4.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxWsDynamicClientTest.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java?rev=1352386&r1=1352385&r2=1352386&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java
(original)
+++ cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java
Thu Jun 21 01:16:38 2012
@@ -39,6 +39,7 @@ public class Compiler {
     private String outputDir;
     private String classPath;
     private boolean forceFork = Boolean.getBoolean(Compiler.class.getName() + "-fork");
+    private File classpathTmpFile;
     
     public Compiler() {
     }
@@ -147,7 +148,6 @@ public class Compiler {
             javacstr = System.getProperty("java.home") + fsep + ".." + fsep + "bin" + fsep
                        + platformjavacname;
         }
-
         list.add(javacstr);
         // End of honoring java.home for used javac
 
@@ -160,7 +160,9 @@ public class Compiler {
         list.add("-J-Xmx" + maxMemory);
 
         addArgs(list);
-        
+        int classpathIdx = list.indexOf("-classpath");
+        String classpath = list.get(classpathIdx + 1);
+        checkLongClasspath(classpath, list, classpathIdx);
         int idx = list.size();
         list.addAll(Arrays.asList(files));
 
@@ -252,7 +254,6 @@ public class Compiler {
                 StreamPrinter infoStreamPrinter = new StreamPrinter(p.getInputStream(), "[INFO]",
System.out);
                 infoStreamPrinter.start();
             }
-
             if (p != null) {
                 return p.waitFor() == 0 ? true : false;
             }
@@ -268,6 +269,9 @@ public class Compiler {
             if (tmpFile != null && tmpFile.exists()) {
                 FileUtils.delete(tmpFile);
             }
+            if (classpathTmpFile != null && classpathTmpFile.exists()) {
+                FileUtils.delete(classpathTmpFile);
+            }
         }
 
         return false;
@@ -280,6 +284,26 @@ public class Compiler {
         }
         return strBuffer.toString().length() > 4096 ? true : false;
     }
+    
+    private boolean isLongClasspath(String classpath) {
+        return classpath.length() > 2048 ? true : false;
+    }   
+    
+    private void checkLongClasspath(String classpath, List<String> list, int classpathIdx)
{
+        if (isLongClasspath(classpath)) {
+            PrintWriter out = null;
+            try {
+                classpathTmpFile = FileUtils.createTempFile("cxf-compiler-classpath", null);
+                out = new PrintWriter(new FileWriter(classpathTmpFile));
+                out.println(classpath);
+                out.flush();
+                out.close();
+                list.set(classpathIdx + 1, "@" + classpathTmpFile);
+            } catch (IOException e) {
+                System.err.print("[ERROR] can't write long classpath to @argfile");
+            }
+        } 
+    }
 
     
 }

Modified: cxf/branches/2.4.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxWsDynamicClientTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxWsDynamicClientTest.java?rev=1352386&r1=1352385&r2=1352386&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxWsDynamicClientTest.java
(original)
+++ cxf/branches/2.4.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxWsDynamicClientTest.java
Thu Jun 21 01:16:38 2012
@@ -105,4 +105,19 @@ public class JaxWsDynamicClientTest exte
         client.invoke("init", list);
     }
     
+    @Test
+    public void testArgfiles() throws Exception {
+        System.setProperty("org.apache.cxf.common.util.Compiler-fork", "true");
+        JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
+        Client client = dcf.createClient(new URL("http://localhost:"
+                                                 + PORT1 + "/ArrayService?wsdl"));
+
+        String[] values = new String[] {"foobar", "something" };
+        List<String> list = Arrays.asList(values);
+        
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.invoke("init", list);
+    }
+    
 }



Mime
View raw message