curcuru     01/12/20 10:29:26

  Modified:    test/java/src/org/apache/qetest/xsl XHTFileCheckService.java
  Log:
  Minor hack to avoid rare spurious bug with file contention;
  although it's more inefficient it won't harm anything and avoids
  a wierd and rare JDK problem on Windows
  
  Revision  Changes    Path
  1.12      +22 -4     
xml-xalan/test/java/src/org/apache/qetest/xsl/XHTFileCheckService.java
  
  Index: XHTFileCheckService.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/test/java/src/org/apache/qetest/xsl/XHTFileCheckService.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- XHTFileCheckService.java  2001/12/19 17:39:02     1.11
  +++ XHTFileCheckService.java  2001/12/20 18:29:26     1.12
  @@ -77,7 +77,7 @@
    * Uses an XML/HTML/Text diff comparator to check or diff two files.
    * @see #check(Logger logger, Object actual, Object reference, String msg, 
String id)
    * @author [EMAIL PROTECTED]
  - * @version $Id: XHTFileCheckService.java,v 1.11 2001/12/19 17:39:02 curcuru 
Exp $
  + * @version $Id: XHTFileCheckService.java,v 1.12 2001/12/20 18:29:26 curcuru 
Exp $
    */
   public class XHTFileCheckService implements CheckService
   {
  @@ -170,15 +170,33 @@
               return Logger.AMBG_RESULT;
           }
   
  -        boolean warning[] = new boolean[1];  // TODO: should use this!
  +        boolean warning[] = new boolean[1];
           warning[0] = false;
           boolean isEqual = false;
   
  +        // Inefficient code to get around very rare spurious exception:
  +        // java.io.IOException: The process cannot access the file because 
it is being used by another process
  +         //    at java.io.Win32FileSystem.canonicalize(Native Method)
  +         //    at java.io.File.getCanonicalPath(File.java:442)
  +         //    at 
org.apache.qetest.xsl.XHTFileCheckService.check(XHTFileCheckService.java:181)
  +        // So get filenames first separately, then call comparator
  +        String referenceFileName = referenceFile.getAbsolutePath();
  +        String actualFileName = actualFile.getAbsolutePath();
           try
           {
  +            referenceFileName = referenceFile.getCanonicalPath();
  +            // Occasional spurious exception happens here, perhaps 
  +            //  because sometimes the previous transform or whatever 
  +            //  hasn't quite closed the actualFile yet
  +            actualFileName = actualFile.getCanonicalPath();
  +        } 
  +        catch (Exception e) { /* no-op, ignore */ }
  +        
  +        try
  +        {
               // Note calling order (gold, act) is different than checkFiles()
  -            isEqual = comparator.compare(referenceFile.getCanonicalPath(),
  -                                         actualFile.getCanonicalPath(), pw,
  +            isEqual = comparator.compare(referenceFileName,
  +                                         actualFileName, pw,
                                            warning, attributes);
               // Side effect: fills in pw/sw with info about the comparison
           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to