SlideShare a Scribd company logo
Axis2 client memory leak
Outline
• Issue & diagnosis
• Postmortem from technique point
  – Axis2 1.4/1.4.1/1.5.6 client
  – Implement & design issue
Issue




CServer exhaust 8G memory -> memory leak
diagnosis
      jmap –histo               pid

num     #instances         #bytes class name
----------------------------------------------
   1:       1001744      246906600 [C //char array
   2:       2855952      137085696 edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap$Segment
   3:        282338      115692192 [I // int array
   4:        677362      102508648 [Ljava.util.HashMap$Entry;
   5:        192117       99164392 [B // byte array
   6:       2856122       91732120 [Ledu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap$HashEntry;
   7:       2855952       91390464 edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantLock$NonfairSync
   8:       1337498       53499920 java.lang.String
   9:        433634       43130120 [Ljava.lang.Object;
  10:        597908       38266112 java.util.HashMap




      From the histogram, the memory leak is caused by Axis2.
       1) The main change in this release is using web service client (axis2 1.4.1)
       2) char[] / edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap
       3) Google ‘axis2 1.4.1 concurrentHashMap memory leak‘
diagnosis
 jmap –dump:file=cdump pid

• We got a 2.39G memory heap dump
  – Very fast, less than 30 seconds (because 8G
    memory in production)
• Problem : too big to open in dev box
  – Need enough physical memory
  – (May) need 64 bit OS
  – Try Jhat/Jprofile/YJP/Jmat eclipse plugin
    (windows/2G)
                             Open by Jmat standalone application
diagnosis




AxisConfiguration retain 540.9m heap
diagnosis




Hashtable allEndPoints holds more than 2k axis2 endpoint instances
diagnosis




All of the endpoint instances are about FavoriteService
1) Confirm in the code, only FavoriteService related did not call cleanup
Axis2 1.4 memory leak
• Reproduce

for( int i=0;i<count; i++) {
    VersionStub stub = new VersionStub(configContext,null);
    GetVersion request = new GetVersion();
    stub.getVersion(request);
}
Axis2 1.4 memory leak
 • Informal Model (OO design)



AxisConfiguration

Map allServices = new Hashtable();
Map allEndpoints = new Hashtable();
Axis2 1.4 memory leak
• Cause : Stub Initiation, add into AxisConfiguration




   //Init, Add
   allServices.put(serviceName, axisService);
   ..
   allEndpoints.put(serviceName + "." + endpointName, axisService);
Axis2 1.4 memory leak
• Cause : Stub Finalize
  //Stub
  protected void finalize() throws Throwable {
          super.finalize();
          cleanup();
  }

  public void cleanup() throws AxisFault {
          _service.getAxisConfiguration().removeService(_service.getName());
  }



 //AsixConiguration
 public synchronized void removeService(String name) throws AxisFault {
         AxisService service = (AxisService) allServices.remove(name);
         if (service != null) {
             AxisServiceGroup serviceGroup = service.getAxisServiceGroup();
             serviceGroup.removeService(name);
             log.debug(Messages.getMessage("serviceremoved", name));
         }
     }
Axis2 1.4 memory leak
• Cause : Client Finalize
  //ServiceClient
  protected void finalize() throws Throwable {
          super.finalize();
          cleanup();
  }

  public void cleanup() throws AxisFault {
    …
          axisConfiguration.removeServiceGroup(serviceGroupName);
    …
  }



 //AsixConiguration
 public AxisServiceGroup removeServiceGroup(String serviceGroupName) throws AxisFault {
            …
            Iterator services = axisServiceGroup.getServices();
            while (services.hasNext()) {
                          AxisService axisService = (AxisService) services.next();
                          allServices.remove(axisService.getName());
                          …
            }
            …
Axis2 1.4 memory leak
• Cause
  //Init, Add
  allServices.put(serviceName, axisService);
  ..
  allEndpoints.put(serviceName + "." + endpointName, axisService);




  //Cleanup(Finalize), Remove
  allServices.put(serviceName, axisService);




• Memory Leak :             allEndpoints
Axis2 1.4.1 fix
• Fix the bug AXIS2-3870
//AsixConiguration.removeServiceGroup

//removes the endpoints to this service
String serviceName = axisService.getName();
String key = null;
for (Iterator iter = axisService.getEndpoints().keySet().iterator(); iter.hasNext();){
   key = serviceName + "." + (String)iter.next();
   this.allEndpoints.remove(key);
}
Axis2 1.4.1 memory leak
• Reproduce

for( int i=0;i<count; i++) {
    VersionStub stub = new VersionStub(configContext,null);
    GetVersion request = new GetVersion();
    stub.getVersion(request);
    stub.cleanup();
}



   Programmer: 1.4 has memory leak issue, so call cleanup
Axis2 1.4.1 memory leak
• Cause : Stub Finalize (no change)
  //Stub
  protected void finalize() throws Throwable {
          super.finalize();
          cleanup();
  }

  public void cleanup() throws AxisFault {
          _service.getAxisConfiguration().removeService(_service.getName());
  }



 //AsixConiguration
 public synchronized void removeService(String name) throws AxisFault {
         AxisService service = (AxisService) allServices.remove(name);
         if (service != null) {
             AxisServiceGroup serviceGroup = service.getAxisServiceGroup();
             serviceGroup.removeService(name);
             log.debug(Messages.getMessage("serviceremoved", name));
         }
     }
Axis2 1.4.1 memory leak
• Cause: Client Finalize (no change)
  //ServiceClient
  protected void finalize() throws Throwable {
          super.finalize();
          cleanup();
  }

  public void cleanup() throws AxisFault {
    …
          axisConfiguration.removeServiceGroup(serviceGroupName);
    …
  }
Axis2 1.4.1 memory leak
• Cause: Client Finalize (no change)
//AsixConiguration
public AxisServiceGroup removeServiceGroup(String serviceGroupName) throws AxisFault {
           …
           Iterator services = axisServiceGroup.getServices();
           while (services.hasNext()) {
                         AxisService axisService = (AxisService) services.next();
                         allServices.remove(axisService.getName());

                   …
                   for (Iterator iter = axisService.getEndpoints().keySet().iterator(); iter.
                          key = serviceName + "." + (String)iter.next();
                          this.allEndpoints.remove(key);
                   }
                   …

          }

                  Servce are already removed from ServiceGroup in Stub cleanup
          …
}
                  The while loop would never enter
Axis2 1.4.1 memory leak
• Cause
  – Stub cleanup and ServiceClient cleanup have
    dependency
  – Can not call in below order

      Stub.cleanup
      ServiceClient.cleanup



• Two are two memory leak bugs in 1.4, 1.4.1 only
  fix 1 bug
Axis2 1.5(.6) fix
• Fix the bug AXIS2-4007 AXIS2-4163
  //Stub
  protected void finalize() throws Throwable {
          super.finalize();
          cleanup();
  }

  public void cleanup() throws AxisFault {
          // _service.getAxisConfiguration().removeService(_service.getName());
          _serviceClient.cleanup();
  }
Implement issue
• Forget to cleanup
  – Container object: add only, no remove
  – Resource object: apply only, no return/close


• Cleanup dependency
  – One object cleanup depend on other objects
  – Two object cleanup/two method has order
    dependency
Design Issue
• AxisConfiguration   is a global shared object
  – Usually only 1 instance even in client side.


• Purpose for put service/endpoint map in this
  global object AxisConfiguration ?
Design Issue
• Message Dispatch in server side
// RequestURIBasedServiceDispatcher
public AxisService findService(MessageContext messageContext) throws AxisFault {

          AxisConfiguration registry = configurationContext.getAxisConfiguration();

           AxisService axisService = registry.getService(values[0]);

           // If the axisService is not null we get the binding that the request came to add
           // add it as a property to the messageContext
           if (axisService != null) {
                 Map endpoints = axisService.getEndpoints();
                 if (endpoints != null) {
                     if (endpoints.size() == 1) {
                            messageContext.setProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME,
                           endpoints.get(axisService.getEndpointName()));
                     } else {
                         String endpointName = values[0].substring(values[0].indexOf(".") + 1);
                         messageContext.setProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME,
                         endpoints.get(endpointName));
                     }
                 }
            }

           return axisService;
}
Design Issue
• Service is ‘singleton’ in server side
   // AxisConfiguration
   public AxisService getService(String name) throws AxisFault {
           AxisService axisService = (AxisService) allServices.get(name);
           if (axisService != null) {
               if (axisService.isActive()) {
                    return axisService;
               } else {
                    throw new AxisFault(Messages
                             .getMessage("serviceinactive", name));
               }
           } else {
               axisService = (AxisService) allEndpoints.get(name);
               if (axisService != null) {
                    if (axisService.isActive()) {
                        return axisService;
                    } else {
                        throw new AxisFault(Messages
                                 .getMessage("serviceinactive", name));
                    }
               }
           }
           return null;
       }
Design Issue
• Client side
  – (Usually) New instance every method invocation
  – No need for message routing
     • Why still register in Axi2Configuration ?

      axisConfig = configContext.getAxisConfiguration();
      if (axisService == null) {
          axisService = createAnonymousService();
      }
      this.axisService = axisService;
      if (axisConfig.getService(axisService.getName()) == null) {
          axisService.setClientSide(true);
          axisConfig.addService(axisService);
      } else {
          …
      }

       …

More Related Content

PDF
A1-6 DMARC 対応とフィッシング対策としての効果 (楽天グループ株式会社 財津氏 )
PDF
IIJmio meeting 19 IIJ フルMVNO徹底解説
PDF
Fronthaul technologies kwang_submit_to_slideshare
PDF
A1-2-Keynote/ 1. Email Authentication Standards
PPTX
MPLS (Multi-Protocol Label Switching)
PDF
Python で OAuth2 をつかってみよう!
PPT
Program dan Kegiatan Subsektor Drainase, Bidang Pengembangan Penyehatan Lingk...
PPTX
ネットワークシミュレータで手軽にネットワークのお勉強(GNS3編)
A1-6 DMARC 対応とフィッシング対策としての効果 (楽天グループ株式会社 財津氏 )
IIJmio meeting 19 IIJ フルMVNO徹底解説
Fronthaul technologies kwang_submit_to_slideshare
A1-2-Keynote/ 1. Email Authentication Standards
MPLS (Multi-Protocol Label Switching)
Python で OAuth2 をつかってみよう!
Program dan Kegiatan Subsektor Drainase, Bidang Pengembangan Penyehatan Lingk...
ネットワークシミュレータで手軽にネットワークのお勉強(GNS3編)

What's hot (20)

PDF
IIJmio高速モバイル/Dについて
PPTX
PSoCまつり「PSoCの美味しい料理法」
PPTX
Diameter Presentation
PDF
Neighbor Discovery Deep Dive – IPv6-Networking-Referat
PDF
What Makes Software Green?
PDF
ルータコンフィグのGit管理のススメ 〜Git管理以外を自動化してみた〜
PDF
IIJmio meeting #2 IIJmioとIPv6の話
PPTX
Apache Spark on Kubernetes入門(Open Source Conference 2021 Online Hiroshima 発表資料)
PPT
BGP Communities: A Guide for Service Provider Networks
PDF
パケットキャプチャの勘どころ Ssmjp 201501
PDF
B1-5 メール技術のいま
PPTX
3GPP TS 38.300-100まとめ
PDF
Lte call flows_att_best_practices_lte_pe
PDF
IIJmio meeting 27 5G NSAについて
PDF
3GPP 5G NSA Detailed explanation 1(EN-DC SgNB Addition Call Flow)
PDF
IIJmio meeting 21 MVNO用語集(MVNO・通信規格)
PPTX
Kibana + Winlogbeatで実現:Windowsのログ分析入門
PPTX
545人のインフラを支えたNOCチーム!
PDF
3GPP SON Series: SON in 3GPP Release-8 – Self-configuration
PDF
Layer 3 redundancy hsrp
IIJmio高速モバイル/Dについて
PSoCまつり「PSoCの美味しい料理法」
Diameter Presentation
Neighbor Discovery Deep Dive – IPv6-Networking-Referat
What Makes Software Green?
ルータコンフィグのGit管理のススメ 〜Git管理以外を自動化してみた〜
IIJmio meeting #2 IIJmioとIPv6の話
Apache Spark on Kubernetes入門(Open Source Conference 2021 Online Hiroshima 発表資料)
BGP Communities: A Guide for Service Provider Networks
パケットキャプチャの勘どころ Ssmjp 201501
B1-5 メール技術のいま
3GPP TS 38.300-100まとめ
Lte call flows_att_best_practices_lte_pe
IIJmio meeting 27 5G NSAについて
3GPP 5G NSA Detailed explanation 1(EN-DC SgNB Addition Call Flow)
IIJmio meeting 21 MVNO用語集(MVNO・通信規格)
Kibana + Winlogbeatで実現:Windowsのログ分析入門
545人のインフラを支えたNOCチーム!
3GPP SON Series: SON in 3GPP Release-8 – Self-configuration
Layer 3 redundancy hsrp
Ad

Similar to Axis2 client memory leak (20)

PDF
Programming Sideways: Asynchronous Techniques for Android
PDF
Think Async: Asynchronous Patterns in NodeJS
PPTX
Avoiding Callback Hell with Async.js
KEY
DjangoCon 2010 Scaling Disqus
PDF
Aplicações Assíncronas no Android com Coroutines e Jetpack
PDF
Seastar @ NYCC++UG
PDF
Futures e abstração - QCon São Paulo 2015
PPTX
ES6 Overview
PDF
Scala @ TechMeetup Edinburgh
PPTX
Grand Central Dispatch
PDF
Celery - A Distributed Task Queue
PDF
Node.js: Continuation-Local-Storage and the Magic of AsyncListener
PDF
MongoDB World 2019: Life In Stitch-es
PPTX
[NDC 2019] Enterprise-Grade Serverless
PPTX
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
PDF
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
PDF
FaaS by Microsoft: Azure Functions and Azure Durable Functions
PDF
An Introduction to Celery
PDF
Seastar @ SF/BA C++UG
PPTX
Anti patterns
Programming Sideways: Asynchronous Techniques for Android
Think Async: Asynchronous Patterns in NodeJS
Avoiding Callback Hell with Async.js
DjangoCon 2010 Scaling Disqus
Aplicações Assíncronas no Android com Coroutines e Jetpack
Seastar @ NYCC++UG
Futures e abstração - QCon São Paulo 2015
ES6 Overview
Scala @ TechMeetup Edinburgh
Grand Central Dispatch
Celery - A Distributed Task Queue
Node.js: Continuation-Local-Storage and the Magic of AsyncListener
MongoDB World 2019: Life In Stitch-es
[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
FaaS by Microsoft: Azure Functions and Azure Durable Functions
An Introduction to Celery
Seastar @ SF/BA C++UG
Anti patterns
Ad

More from feng lee (6)

PPTX
Guice in athena
PDF
Bloom filter
PDF
Hadoop 安装
PPTX
Mysql story in poi dedup
PPTX
Effective java - concurrency
PPTX
Maven
Guice in athena
Bloom filter
Hadoop 安装
Mysql story in poi dedup
Effective java - concurrency
Maven

Recently uploaded (20)

PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Spectroscopy.pptx food analysis technology
PDF
Encapsulation theory and applications.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Machine learning based COVID-19 study performance prediction
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Understanding_Digital_Forensics_Presentation.pptx
Review of recent advances in non-invasive hemoglobin estimation
Spectroscopy.pptx food analysis technology
Encapsulation theory and applications.pdf
Unlocking AI with Model Context Protocol (MCP)
Machine learning based COVID-19 study performance prediction
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Big Data Technologies - Introduction.pptx
Chapter 3 Spatial Domain Image Processing.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
sap open course for s4hana steps from ECC to s4
Digital-Transformation-Roadmap-for-Companies.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
MIND Revenue Release Quarter 2 2025 Press Release
Programs and apps: productivity, graphics, security and other tools
Diabetes mellitus diagnosis method based random forest with bat algorithm
Per capita expenditure prediction using model stacking based on satellite ima...

Axis2 client memory leak

  • 2. Outline • Issue & diagnosis • Postmortem from technique point – Axis2 1.4/1.4.1/1.5.6 client – Implement & design issue
  • 3. Issue CServer exhaust 8G memory -> memory leak
  • 4. diagnosis jmap –histo pid num #instances #bytes class name ---------------------------------------------- 1: 1001744 246906600 [C //char array 2: 2855952 137085696 edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap$Segment 3: 282338 115692192 [I // int array 4: 677362 102508648 [Ljava.util.HashMap$Entry; 5: 192117 99164392 [B // byte array 6: 2856122 91732120 [Ledu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap$HashEntry; 7: 2855952 91390464 edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantLock$NonfairSync 8: 1337498 53499920 java.lang.String 9: 433634 43130120 [Ljava.lang.Object; 10: 597908 38266112 java.util.HashMap From the histogram, the memory leak is caused by Axis2. 1) The main change in this release is using web service client (axis2 1.4.1) 2) char[] / edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap 3) Google ‘axis2 1.4.1 concurrentHashMap memory leak‘
  • 5. diagnosis jmap –dump:file=cdump pid • We got a 2.39G memory heap dump – Very fast, less than 30 seconds (because 8G memory in production) • Problem : too big to open in dev box – Need enough physical memory – (May) need 64 bit OS – Try Jhat/Jprofile/YJP/Jmat eclipse plugin (windows/2G) Open by Jmat standalone application
  • 7. diagnosis Hashtable allEndPoints holds more than 2k axis2 endpoint instances
  • 8. diagnosis All of the endpoint instances are about FavoriteService 1) Confirm in the code, only FavoriteService related did not call cleanup
  • 9. Axis2 1.4 memory leak • Reproduce for( int i=0;i<count; i++) { VersionStub stub = new VersionStub(configContext,null); GetVersion request = new GetVersion(); stub.getVersion(request); }
  • 10. Axis2 1.4 memory leak • Informal Model (OO design) AxisConfiguration Map allServices = new Hashtable(); Map allEndpoints = new Hashtable();
  • 11. Axis2 1.4 memory leak • Cause : Stub Initiation, add into AxisConfiguration //Init, Add allServices.put(serviceName, axisService); .. allEndpoints.put(serviceName + "." + endpointName, axisService);
  • 12. Axis2 1.4 memory leak • Cause : Stub Finalize //Stub protected void finalize() throws Throwable { super.finalize(); cleanup(); } public void cleanup() throws AxisFault { _service.getAxisConfiguration().removeService(_service.getName()); } //AsixConiguration public synchronized void removeService(String name) throws AxisFault { AxisService service = (AxisService) allServices.remove(name); if (service != null) { AxisServiceGroup serviceGroup = service.getAxisServiceGroup(); serviceGroup.removeService(name); log.debug(Messages.getMessage("serviceremoved", name)); } }
  • 13. Axis2 1.4 memory leak • Cause : Client Finalize //ServiceClient protected void finalize() throws Throwable { super.finalize(); cleanup(); } public void cleanup() throws AxisFault { … axisConfiguration.removeServiceGroup(serviceGroupName); … } //AsixConiguration public AxisServiceGroup removeServiceGroup(String serviceGroupName) throws AxisFault { … Iterator services = axisServiceGroup.getServices(); while (services.hasNext()) { AxisService axisService = (AxisService) services.next(); allServices.remove(axisService.getName()); … } …
  • 14. Axis2 1.4 memory leak • Cause //Init, Add allServices.put(serviceName, axisService); .. allEndpoints.put(serviceName + "." + endpointName, axisService); //Cleanup(Finalize), Remove allServices.put(serviceName, axisService); • Memory Leak : allEndpoints
  • 15. Axis2 1.4.1 fix • Fix the bug AXIS2-3870 //AsixConiguration.removeServiceGroup //removes the endpoints to this service String serviceName = axisService.getName(); String key = null; for (Iterator iter = axisService.getEndpoints().keySet().iterator(); iter.hasNext();){ key = serviceName + "." + (String)iter.next(); this.allEndpoints.remove(key); }
  • 16. Axis2 1.4.1 memory leak • Reproduce for( int i=0;i<count; i++) { VersionStub stub = new VersionStub(configContext,null); GetVersion request = new GetVersion(); stub.getVersion(request); stub.cleanup(); } Programmer: 1.4 has memory leak issue, so call cleanup
  • 17. Axis2 1.4.1 memory leak • Cause : Stub Finalize (no change) //Stub protected void finalize() throws Throwable { super.finalize(); cleanup(); } public void cleanup() throws AxisFault { _service.getAxisConfiguration().removeService(_service.getName()); } //AsixConiguration public synchronized void removeService(String name) throws AxisFault { AxisService service = (AxisService) allServices.remove(name); if (service != null) { AxisServiceGroup serviceGroup = service.getAxisServiceGroup(); serviceGroup.removeService(name); log.debug(Messages.getMessage("serviceremoved", name)); } }
  • 18. Axis2 1.4.1 memory leak • Cause: Client Finalize (no change) //ServiceClient protected void finalize() throws Throwable { super.finalize(); cleanup(); } public void cleanup() throws AxisFault { … axisConfiguration.removeServiceGroup(serviceGroupName); … }
  • 19. Axis2 1.4.1 memory leak • Cause: Client Finalize (no change) //AsixConiguration public AxisServiceGroup removeServiceGroup(String serviceGroupName) throws AxisFault { … Iterator services = axisServiceGroup.getServices(); while (services.hasNext()) { AxisService axisService = (AxisService) services.next(); allServices.remove(axisService.getName()); … for (Iterator iter = axisService.getEndpoints().keySet().iterator(); iter. key = serviceName + "." + (String)iter.next(); this.allEndpoints.remove(key); } … } Servce are already removed from ServiceGroup in Stub cleanup … } The while loop would never enter
  • 20. Axis2 1.4.1 memory leak • Cause – Stub cleanup and ServiceClient cleanup have dependency – Can not call in below order Stub.cleanup ServiceClient.cleanup • Two are two memory leak bugs in 1.4, 1.4.1 only fix 1 bug
  • 21. Axis2 1.5(.6) fix • Fix the bug AXIS2-4007 AXIS2-4163 //Stub protected void finalize() throws Throwable { super.finalize(); cleanup(); } public void cleanup() throws AxisFault { // _service.getAxisConfiguration().removeService(_service.getName()); _serviceClient.cleanup(); }
  • 22. Implement issue • Forget to cleanup – Container object: add only, no remove – Resource object: apply only, no return/close • Cleanup dependency – One object cleanup depend on other objects – Two object cleanup/two method has order dependency
  • 23. Design Issue • AxisConfiguration is a global shared object – Usually only 1 instance even in client side. • Purpose for put service/endpoint map in this global object AxisConfiguration ?
  • 24. Design Issue • Message Dispatch in server side // RequestURIBasedServiceDispatcher public AxisService findService(MessageContext messageContext) throws AxisFault { AxisConfiguration registry = configurationContext.getAxisConfiguration(); AxisService axisService = registry.getService(values[0]); // If the axisService is not null we get the binding that the request came to add // add it as a property to the messageContext if (axisService != null) { Map endpoints = axisService.getEndpoints(); if (endpoints != null) { if (endpoints.size() == 1) { messageContext.setProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME, endpoints.get(axisService.getEndpointName())); } else { String endpointName = values[0].substring(values[0].indexOf(".") + 1); messageContext.setProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME, endpoints.get(endpointName)); } } } return axisService; }
  • 25. Design Issue • Service is ‘singleton’ in server side // AxisConfiguration public AxisService getService(String name) throws AxisFault { AxisService axisService = (AxisService) allServices.get(name); if (axisService != null) { if (axisService.isActive()) { return axisService; } else { throw new AxisFault(Messages .getMessage("serviceinactive", name)); } } else { axisService = (AxisService) allEndpoints.get(name); if (axisService != null) { if (axisService.isActive()) { return axisService; } else { throw new AxisFault(Messages .getMessage("serviceinactive", name)); } } } return null; }
  • 26. Design Issue • Client side – (Usually) New instance every method invocation – No need for message routing • Why still register in Axi2Configuration ? axisConfig = configContext.getAxisConfiguration(); if (axisService == null) { axisService = createAnonymousService(); } this.axisService = axisService; if (axisConfig.getService(axisService.getName()) == null) { axisService.setClientSide(true); axisConfig.addService(axisService); } else { … } …