Copilot commented on code in PR #3142:
URL: https://github.com/apache/tika/pull/3142#discussion_r3958772182


##########
tika-core/src/main/java/org/apache/tika/io/FilenameUtils.java:
##########
@@ -400,7 +400,7 @@ public static String calculateExtension(Metadata metadata, 
String defaultValue)
         if (ext != null) {
             return ext;
         }
-        return ".bin";
+        return defaultValue;

Review Comment:
   This is a behavior change: callers that previously relied on the implicit 
`.bin` fallback for unknown MIME types will now get their provided 
`defaultValue` (or possibly `null` if they passed null). If backward 
compatibility matters, consider either (a) keeping `.bin` as the fallback when 
`defaultValue` is null/blank, or (b) updating method/Javadoc to explicitly 
document how `defaultValue == null` is handled and adding a small guard to 
preserve a stable default.



##########
tika-core/src/test/java/org/apache/tika/io/FilenameUtilsTest.java:
##########
@@ -245,6 +245,12 @@ public void testEmbeddedFilePaths() throws Exception {
 
     }
 
+@Test
+public void testCalculateExtensionUnknownValue() {
+    assertEquals(".pdf", FilenameUtils.calculateExtension(
+            getMetadata("the quick brown fox", "application/x-tika-unknown"), 
".pdf"));
+}

Review Comment:
   The test is missing the indentation used by surrounding methods in this 
class (the `@Test` annotation and method start at column 0). Please align 
formatting/indentation with the rest of the file to keep the test class 
consistent.



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