ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgl...@apache.org
Subject svn commit: r1222724 - in /ant/core/trunk: ./ src/main/org/apache/tools/ant/taskdefs/optional/ src/main/org/apache/tools/ant/taskdefs/optional/junit/ src/tests/junit/org/apache/tools/ant/taskdefs/optional/
Date Fri, 23 Dec 2011 16:21:27 GMT
Author: jglick
Date: Fri Dec 23 16:21:26 2011
New Revision: 1222724

URL: http://svn.apache.org/viewvc?rev=1222724&view=rev
Log:
#52382: <xslt> with redirect broken on JDK 7 when a SecurityManager is set.

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1222724&r1=1222723&r2=1222724&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Dec 23 16:21:26 2011
@@ -17,7 +17,8 @@ Fixed bugs:
    Bugzilla Report 51049.
 
  * <junitreport> did not work in embedded environments on JDK 7.
-   Bugzilla Report 51668.
+   Nor did <xslt> when using Xalan redirects.
+   Bugzilla Report 51668, 52382.
 
  * Encoding of unicode escape sequences by the property file task
    Bugzilla Report 50515.

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java?rev=1222724&r1=1222723&r2=1222724&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java Fri Dec
23 16:21:26 2011
@@ -419,12 +419,12 @@ public class TraXLiaison implements XSLT
             }
         }
 
-        if (Boolean.TRUE.equals(DISABLE_SECURE_PROCESSING.get())) {
-            try {
-                Field _isNotSecureProcessing = tfactory.getClass().getDeclaredField("_isNotSecureProcessing");
-                _isNotSecureProcessing.setAccessible(true);
-                _isNotSecureProcessing.set(tfactory, Boolean.TRUE);
-            } catch (Exception x) {
+        try { // #51668, #52382
+            Field _isNotSecureProcessing = tfactory.getClass().getDeclaredField("_isNotSecureProcessing");
+            _isNotSecureProcessing.setAccessible(true);
+            _isNotSecureProcessing.set(tfactory, Boolean.TRUE);
+        } catch (Exception x) {
+            if (project != null) {
                 project.log(x.toString(), Project.MSG_DEBUG);
             }
         }
@@ -443,11 +443,6 @@ public class TraXLiaison implements XSLT
         }
         return tfactory;
     }
-    /**
-     * Not part of any stable API.
-     * @see #51668
-     */
-    public static final ThreadLocal/*<Boolean>*/ DISABLE_SECURE_PROCESSING = new ThreadLocal();
 
 
     /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java?rev=1222724&r1=1222723&r2=1222724&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
Fri Dec 23 16:21:26 2011
@@ -261,13 +261,10 @@ public class AggregateTransformer {
         paramx.setName("output.dir");
         paramx.setExpression(toDir.getAbsolutePath());
         final long t0 = System.currentTimeMillis();
-        TraXLiaison.DISABLE_SECURE_PROCESSING.set(Boolean.TRUE);
         try {
             xsltTask.execute();
         } catch (Exception e) {
             throw new BuildException("Errors while applying transformations: " + e.getMessage(),
e);
-        } finally {
-            TraXLiaison.DISABLE_SECURE_PROCESSING.set(null);
         }
         final long dt = System.currentTimeMillis() - t0;
         task.log("Transform time: " + dt + "ms");

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java?rev=1222724&r1=1222723&r2=1222724&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
(original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
Fri Dec 23 16:21:26 2011
@@ -5,7 +5,10 @@ import org.apache.tools.ant.taskdefs.XSL
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.util.JAXPUtils;
 
+import java.io.ByteArrayInputStream;
 import java.io.File;
+import java.io.InputStream;
+import java.security.Permission;
 
 import junit.framework.AssertionFailedError;
 
@@ -65,11 +68,26 @@ public class TraXLiaisonTest extends Abs
         liaison.setStylesheet(xsl);
         File out = new File("xalan2-redirect-out-dummy.tmp");
         File in = getFile("/taskdefs/optional/xsltliaison-in.xsl");
+        ClassLoader orig = Thread.currentThread().getContextClassLoader();
         try {
             liaison.addParam("xalan-version", "2");
+            // Use the JRE's Xerces, not lib/optional/xerces.jar:
+            Thread.currentThread().setContextClassLoader(new ClassLoader(ClassLoader.getSystemClassLoader().getParent())
{
+                public InputStream getResourceAsStream(String name) {
+                    if (name.startsWith("META-INF/services/")) {
+                        // work around JAXP #6723276 in JDK 6
+                        return new ByteArrayInputStream(new byte[0]);
+                    }
+                    return super.getResourceAsStream(name);
+                }
+            });
+            // Tickle #52382:
+            System.setSecurityManager(new SecurityManager() {public void checkPermission(Permission
perm) {}});
             liaison.transform(in, out);
         } finally {
             out.delete();
+            Thread.currentThread().setContextClassLoader(orig);
+            System.setSecurityManager(null);
         }
     }
 



Mime
View raw message