You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by GitBox <gi...@apache.org> on 2022/03/31 23:42:26 UTC

[GitHub] [thrift] Jimexist opened a new pull request #2552: add type parameter to java lib field metadata

Jimexist opened a new pull request #2552:
URL: https://github.com/apache/thrift/pull/2552


   <!-- Explain the changes in the pull request below: -->
     
   add type parameter to java lib field metadata
   
   <!-- We recommend you review the checklist/tips before submitting a pull request. -->
   
   - [ ] Did you create an [Apache Jira](https://issues.apache.org/jira/projects/THRIFT/issues/) ticket?  (not required for trivial changes)
   - [ ] If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
   - [ ] Did you squash your changes to a single commit?  (not required, but preferred)
   - [ ] Did you do your best to avoid breaking changes?  If one was needed, did you label the Jira ticket with "Breaking-Change"?
   - [ ] If your change does not involve any code, include `[skip ci]` anywhere in the commit message to free up build resources.
   
   <!--
     The Contributing Guide at:
     https://github.com/apache/thrift/blob/master/CONTRIBUTING.md
     has more details and tips for committing properly.
   -->
   


-- 
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: dev-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [thrift] Jimexist commented on a change in pull request #2552: add type parameter to java lib field metadata

Posted by GitBox <gi...@apache.org>.
Jimexist commented on a change in pull request #2552:
URL: https://github.com/apache/thrift/pull/2552#discussion_r840109944



##########
File path: 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:
       `T.newInstance()` is deprecated since Java 9.




-- 
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: notifications-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org