mocobeta commented on a change in pull request #654: LUCENE-8778: Define 
analyzer SPI names as static final fields and document the names
URL: https://github.com/apache/lucene-solr/pull/654#discussion_r280975702
 
 

 ##########
 File path: 
lucene/analysis/common/src/java/org/apache/lucene/analysis/util/AnalysisSPILoader.java
 ##########
 @@ -83,17 +74,22 @@ public synchronized void reload(ClassLoader classloader) {
     final SPIClassIterator<S> loader = SPIClassIterator.get(clazz, 
classloader);
     while (loader.hasNext()) {
       final Class<? extends S> service = loader.next();
-      final String clazzName = service.getSimpleName();
       String name = null;
-      for (String suffix : suffixes) {
-        if (clazzName.endsWith(suffix)) {
-          name = clazzName.substring(0, clazzName.length() - 
suffix.length()).toLowerCase(Locale.ROOT);
-          break;
+      Throwable cause = null;
+      try {
+        // Lookup "NAME" field with appropriate modifiers. Also it must be a 
String field.
+        final Field field = service.getField("NAME");
+        int modifier = field.getModifiers();
+        if (Modifier.isPublic(modifier) && Modifier.isStatic(modifier) && 
Modifier.isFinal(modifier) &&
 
 Review comment:
   OK, I will change the safety check in that manner. 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to