Uploaded image for project: 'JBoss Enterprise Application Platform 4 and 5'
  1. JBoss Enterprise Application Platform 4 and 5
  2. JBPAPP-4852

Performance issue: 5 String concatenation in log.trace() on ProxyObjectFactory.getReferenceAddresses()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • EAP_EWP 5.1.1
    • EAP_EWP 5.1.0_CR2
    • EJB
    • None
    • Not Required

      Typical logging issue, String concatenation in ProxyObjectFactory in jboss-ejb3-proxy-impl project.

      We should rather be using isTraceEnabled before doing such expensive operation.

      http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/tags/jboss-ejb3-proxy-impl-1.0.10/src/main/java/org/jboss/ejb3/proxy/impl/objectfactory/ProxyObjectFactory.java

      85763 ALRubinger private Map<String, List<String>> getReferenceAddresses(Reference ref)
      85763 ALRubinger {
      85763 ALRubinger
      85763 ALRubinger // Initialize and instanciate a more reasonable object for handling Reference Addresses
      85763 ALRubinger Map<String, List<String>> referenceAddresses = new HashMap<String, List<String>>();
      85763 ALRubinger
      85763 ALRubinger // For all Reference Addresses
      85763 ALRubinger int count = 0;
      85763 ALRubinger Enumeration<RefAddr> refAddrs = ref.getAll();
      85763 ALRubinger while (refAddrs.hasMoreElements())
      85763 ALRubinger {
      85763 ALRubinger // Get the current Reference Address information
      85763 ALRubinger RefAddr refAddr = refAddrs.nextElement();
      85763 ALRubinger String type = refAddr.getType();
      85763 ALRubinger Class<?> expectedContentsType = String.class;
      85763 ALRubinger Object refAddrContent = refAddr.getContent();
      85763 ALRubinger assert (refAddrContent != null) : "Encountered Reference Address of type " + type + " but with null Content";
      85763 ALRubinger assert (expectedContentsType.isAssignableFrom(refAddrContent.getClass())) : "Content of Reference Address of type \""
      85763 ALRubinger + type + "\" at index " + count + " was not of expected Java type " + expectedContentsType.getName();
      85763 ALRubinger String content = (String) refAddr.getContent();
      85763 ALRubinger
      85763 ALRubinger // If our map doesn't yet contain an entry for this type
      85763 ALRubinger if (!referenceAddresses.containsKey(type))
      85763 ALRubinger

      { 85763 ALRubinger // Create an entry in the Map to hold the reference addresses 85763 ALRubinger referenceAddresses.put(type, new ArrayList<String>()); 85763 ALRubinger }

      85763 ALRubinger
      85763 ALRubinger // Place an entry for the contents at index "type"
      85763 ALRubinger referenceAddresses.get(type).add(content);
      85763 ALRubinger log.trace("Found reference type \"" + type + "\" with content \"" + content + "\"");
      85763 ALRubinger

              arubinge@redhat.com Andrew Rubinger (Inactive)
              rhn-engineering-rhusar Radoslav Husar
              Elspeth Thorne Elspeth Thorne (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: