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


##########
tika-core/src/test/java/org/apache/tika/metadata/TestMetadata.java:
##########
@@ -461,6 +465,121 @@ public void testToStringWithSingleEntry() {
         assertEquals("key=value1", m.toString());
     }
 
+    /**
+     * Two Metadata instances that differ only in a value under the same key
+     * must not be equal, so value-distinct metadata are never collapsed.
+     */
+    @Test
+    public void testValueDistinctMetadataNotEqual() {
+        Metadata m1 = new Metadata();
+        m1.add("k1", "v1");
+        Metadata m2 = new Metadata();
+        m2.add("k1", "v2");
+        assertNotEquals(m1, m2);
+    }
+
+    /**
+     * Writing to reserved keys must throw an exception.
+     */
+    @Test
+    public void testReservedKeyBlockedOnUntrustedMetadata() {
+        String reservedKey = TikaCoreProperties.TIKA_META_PREFIX + "reserved";
+        Metadata m = new Metadata();
+        assertThrows(IllegalArgumentException.class, () -> m.add(reservedKey, 
"value"));
+    }

Review Comment:
   PR description says reserved `tk:` keys written via the String API on an 
untrusted Metadata are "dropped" and mentions `setTrusted(true)`, but 
`Metadata#add(String,String)` actually throws `IllegalArgumentException` for 
reserved keys and the trusted bypass is 
`addTrusted`/`setTrusted(String,String)` (as this test asserts). Please update 
the PR description to match the actual contract/API so reviewers/users aren’t 
misled.



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