ctubbsii commented on code in PR #2552:
URL: https://github.com/apache/thrift/pull/2552#discussion_r850787983


##########
lib/java/src/org/apache/thrift/meta_data/FieldMetaData.java:
##########
@@ -68,21 +64,24 @@ public static void addStructMetaDataMap(Class<? extends 
TBase> sClass, Map<? ext
    *               {@link FieldMetaData#addStructMetaDataMap(Class, Map)} from 
a different
    *               thread during static initialization of the Thrift class is 
possible.
    */
-  public static Map<? extends TFieldIdEnum, FieldMetaData> 
getStructMetaDataMap(
-      Class<? extends TBase> sClass) {
+  public static <T extends TBase<T, F>, F extends TFieldIdEnum> Map<F, 
FieldMetaData> getStructMetaDataMap(
+      Class<T> sClass) {
     // Note: Do not use synchronized on this method declaration - it leads to 
a deadlock.
     // Similarly, do not trigger sClass.newInstance() while holding a lock on 
structMap,
     // it will lead to the same deadlock.
     // See: https://issues.apache.org/jira/browse/THRIFT-5430 for details.
-    if (!structMap.containsKey(sClass)){ // Load class if it hasn't been loaded
-      try{
-        sClass.newInstance();
-      } catch (InstantiationException e){
+    if (!structMap.containsKey(sClass)) { // Load class if it hasn't been 
loaded
+      try {
+        sClass.getDeclaredConstructor().newInstance();

Review Comment:
   Not the one from the constructor, only the one dangling off the class 
itself. The above should be fine.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to