mosermw commented on code in PR #9793:
URL: https://github.com/apache/nifi/pull/9793#discussion_r2021580321


##########
nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/IdentifyMimeType.java:
##########
@@ -173,31 +174,23 @@ public void setup(final ProcessContext context) throws 
IOException {
             this.detector = config.getDetector();
             this.mimeTypes = config.getMimeRepository();
         } else {
-            setCustomMimeTypes(configStrategy, context);
-        }
-
-        this.encodingDetector = config.getEncodingDetector();
-    }
-
-    private void setCustomMimeTypes(String configStrategy, ProcessContext 
context) {

Review Comment:
   Since you have two places where the MimeTypesFactory.create() logic is 
duplicated (in customValidate() and setup() ), it seems like a perfect 
opportunity to keep that logic in a method.  Suggest something like:
   
   ```
       private MimeTypes setCustomMimeTypes(String configStrategy, 
PropertyContext context) throws MimeTypeException, IOException {
           try (final InputStream customInputStream = 
context.getProperty(CUSTOM_MIME_CONFIGURATION).asResource().read()) {
               if (configStrategy.equals(REPLACE.getValue())) {
                   return MimeTypesFactory.create(customInputStream);
               } else {
                   try (final InputStream nifiInputStream = 
getClass().getClassLoader().getResourceAsStream(CUSTOM_MIME_TYPES_FILENAME);
                        final InputStream tikaInputStream = 
MimeTypes.class.getClassLoader().getResourceAsStream(DEFAULT_MIME_TYPES_PATH)) {
                       return MimeTypesFactory.create(customInputStream, 
nifiInputStream, tikaInputStream);
                   }
               }
           }
       }
   ```



-- 
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