Author: ffang
Date: Thu Jun 21 00:38:15 2012
New Revision: 1352376
URL: http://svn.apache.org/viewvc?rev=1352376&view=rev
Log:
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.6.x-fixes/ (props changed)
cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/common/util/Compiler.java
cxf/branches/2.6.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxWsDynamicClientTest.java
Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/common/util/Compiler.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/common/util/Compiler.java?rev=1352376&r1=1352375&r2=1352376&view=diff
==============================================================================
---
cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/common/util/Compiler.java
(original)
+++
cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/common/util/Compiler.java
Thu Jun 21 00:38:15 2012
@@ -40,6 +40,7 @@ public class Compiler {
private String classPath;
private String encoding;
private boolean forceFork = Boolean.getBoolean(Compiler.class.getName() +
"-fork");
+ private File classpathTmpFile;
public Compiler() {
}
@@ -152,7 +153,6 @@ public class Compiler {
javacstr = SystemPropertyAction.getProperty("java.home") + fsep +
".." + fsep + "bin" + fsep
+ platformjavacname;
}
-
list.add(javacstr);
// End of honoring java.home for used javac
@@ -165,7 +165,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));
@@ -272,6 +274,9 @@ public class Compiler {
if (tmpFile != null && tmpFile.exists()) {
FileUtils.delete(tmpFile);
}
+ if (classpathTmpFile != null && classpathTmpFile.exists()) {
+ FileUtils.delete(classpathTmpFile);
+ }
}
return false;
@@ -284,6 +289,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");
+ }
+ }
+ }
public void setEncoding(String string) {
encoding = string;
Modified:
cxf/branches/2.6.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxWsDynamicClientTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxWsDynamicClientTest.java?rev=1352376&r1=1352375&r2=1352376&view=diff
==============================================================================
---
cxf/branches/2.6.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxWsDynamicClientTest.java
(original)
+++
cxf/branches/2.6.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxWsDynamicClientTest.java
Thu Jun 21 00:38:15 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);
+ }
+
}