butek       2002/06/07 06:14:35

  Modified:    java/src/org/apache/axis/client Stub.java
               java/src/org/apache/axis/wsdl/toJava JavaStubWriter.java
  Log:
  The multithread test sometimes failed on JDK 1.4.  dims provided this fix.
  We've added a synchronized block in generated stubs and, since it's only
  called within this block, removed the synchronization in Stub.firstCall().
  
  With this fix I'll close bugzilla 8631:
  http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8631
  
  Revision  Changes    Path
  1.10      +6 -8      xml-axis/java/src/org/apache/axis/client/Stub.java
  
  Index: Stub.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Stub.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Stub.java 13 May 2002 14:49:01 -0000      1.9
  +++ Stub.java 7 Jun 2002 13:14:34 -0000       1.10
  @@ -91,19 +91,17 @@
       protected Integer    cachedTimeout      = null;
   
       // Flag to determine whether this is the first call to register type mappings.
  -    // firstCallLock is used to access this in a thread-safe manner.
  -    private boolean firstCall     = true;
  -    private Object  firstCallLock = new Object();
  +    // This need not be synchronized because firstCall is ONLY called from within
  +    // a synchronized block in the generated stub code.
  +    private boolean firstCall = true;
   
       /**
        * Is this the first time the type mappings are being registered?
        */
       protected boolean firstCall() {
  -        synchronized (firstCallLock) {
  -            boolean ret = firstCall;
  -            firstCall = false;
  -            return ret;
  -        }
  +        boolean ret = firstCall;
  +        firstCall = false;
  +        return ret;
       } // firstCall
   
       /**
  
  
  
  1.67      +15 -13    
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java
  
  Index: JavaStubWriter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java,v
  retrieving revision 1.66
  retrieving revision 1.67
  diff -u -r1.66 -r1.67
  --- JavaStubWriter.java       7 Jun 2002 12:45:08 -0000       1.66
  +++ JavaStubWriter.java       7 Jun 2002 13:14:34 -0000       1.67
  @@ -208,27 +208,29 @@
               pw.println("            // " + JavaUtils.getMessage("typeMap02"));
               pw.println("            // " + JavaUtils.getMessage("typeMap03"));
               pw.println("            // " + JavaUtils.getMessage("typeMap04"));
  -            pw.println("            if (firstCall()) {");
  +            pw.println("            synchronized (this) {");
  +            pw.println("                if (firstCall()) {");
               
               // Hack alert - we need to establish the encoding style before we 
register type mappings due
               // to the fact that TypeMappings key off of encoding style
  -            pw.println("                // "
  +            pw.println("                    // "
                       + JavaUtils.getMessage("mustSetStyle"));
               if (bEntry.hasLiteral()) {
  -                pw.println("                call.setEncodingStyle(null);");
  +                pw.println("                    call.setEncodingStyle(null);");
               } else {
  -                pw.println("                
call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC);");
  +                pw.println("                    
call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC);");
               }
               
  -            pw.println("                for (int i = 0; i < 
cachedSerFactories.size(); ++i) {");
  -            pw.println("                    Class cls = (Class) 
cachedSerClasses.get(i);");
  -            pw.println("                    javax.xml.rpc.namespace.QName qName =");
  -            pw.println("                            (javax.xml.rpc.namespace.QName) 
cachedSerQNames.get(i);");
  -            pw.println("                    Class sf = (Class)");
  -            pw.println("                             cachedSerFactories.get(i);");
  -            pw.println("                    Class df = (Class)");
  -            pw.println("                             cachedDeserFactories.get(i);");
  -            pw.println("                    call.registerTypeMapping(cls, qName, 
sf, df, false);");
  +            pw.println("                    for (int i = 0; i < 
cachedSerFactories.size(); ++i) {");
  +            pw.println("                        Class cls = (Class) 
cachedSerClasses.get(i);");
  +            pw.println("                        javax.xml.rpc.namespace.QName qName 
=");
  +            pw.println("                                
(javax.xml.rpc.namespace.QName) cachedSerQNames.get(i);");
  +            pw.println("                        Class sf = (Class)");
  +            pw.println("                                 
cachedSerFactories.get(i);");
  +            pw.println("                        Class df = (Class)");
  +            pw.println("                                 
cachedDeserFactories.get(i);");
  +            pw.println("                        call.registerTypeMapping(cls, 
qName, sf, df, false);");
  +            pw.println("                    }");
               pw.println("                }");
               pw.println("            }");
           }
  
  
  


Reply via email to