Uploaded image for project: 'OpenWebBeans'
  1. OpenWebBeans
  2. OWB-1388

ViolationMessageBuilder has System.getProperty call as instance variable rather than static variable

    XMLWordPrintableJSON

Details

    Description

      Problem: Repeated instantiation of ViolationMessageBuilder.java causes thread to block at java.util.Hashtable.

      Class :  https://github.com/apache/openwebbeans/blob/master/webbeans-impl/src/main/java/org/apache/webbeans/exception/helper/ViolationMessageBuilder.java

      Current field :  

       private final String lineSeparator = System.getProperty("line.separator");

      Currently it is getting initialized every time ViolationMessageBuilder is instantiated by the code.

       

      Fix :

       Change  it to static variable : 

      private static final String lineSeparator = System.getProperty("line.separator");

       This will prevent java.util.HashTable (System.getProperty("line.separator")  being called every time ViolationMessageBuilder  instantiated.

       

      Sample thread block noticed at high concurrency

      java.lang.Thread.State: BLOCKED (on object monitor)

                     at java.util.Hashtable.get(Ljava/lang/Object;)Ljava/lang/Object;(Hashtable.java:363)

                     - waiting to lock <0x000000069a4fc6e0> (a java.util.Properties)

                     at java.util.Properties.getProperty(Ljava/lang/String;)Ljava/lang/String;(Properties.java:1093)

                     at java.lang.System.getProperty(Ljava/lang/String;)Ljava/lang/String;(System.java:732)

                     at org.apache.webbeans.exception.helper.ViolationMessageBuilder.<init>()V(ViolationMessageBuilder.java:25)

                     at org.apache.webbeans.exception.helper.ViolationMessageBuilder.newViolation([Ljava/lang/String;)Lorg/apache/webbeans/exception/helper/ViolationMessageBuilder;(ViolationMessageBuilder.java:34)

                     at org.apache.webbeans.util.InjectionExceptionUtil.throwUnsatisfiedResolutionException(Ljava/lang/Class;Ljavax/enterprise/inject/spi/InjectionPoint;[Ljava/lang/annotation/Annotation;)V(InjectionExceptionUtil.java:51)

                     at org.apache.webbeans.container.InjectionResolver.getInjectionPointBean(Ljavax/enterprise/inject/spi/InjectionPoint;)Ljavax/enterprise/inject/spi/Bean;(InjectionResolver.java:293)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              raghunandan_h Raghunandan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: