Raghunandan created OWB-1388: -------------------------------- Summary: ViolationMessageBuilder has System.getProperty call as instance variable rather than static variable Key: OWB-1388 URL: https://issues.apache.org/jira/browse/OWB-1388 Project: OpenWebBeans Issue Type: Bug Components: Enterprise Web Beans, Simple Web Beans Reporter: Raghunandan
*Problem*: Repeated instantiation of [ViolationMessageBuilder.java|https://github.com/apache/openwebbeans/blob/master/webbeans-impl/src/main/java/org/apache/webbeans/exception/helper/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 instantiated every time *{color:#FF0000}ViolationMessageBuilder{color}* is instantiated by the code._ *_Fix :_* Change it to static variable : _private {color:#FF0000}static{color} final String lineSeparator = System.getProperty("line.separator");_ This will prevent java.util.HashTable (_System.getProperty("line.separator")_ being called every time {color:#FF0000}ViolationMessageBuilder{color} 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.*{color:#FF0000}ViolationMessageBuilder{color}*{color:#FF0000}.<init>{color}()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) -- This message was sent by Atlassian Jira (v8.3.4#803005)