thomasmueller commented on code in PR #2795:
URL: https://github.com/apache/jackrabbit-oak/pull/2795#discussion_r2941132427


##########
oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentPropertyState.java:
##########
@@ -190,7 +197,33 @@ private <T> T getValue(RecordId id, Type<T> type) {
             return (T) reader.readBlob(id); // load binaries lazily
         }
 
-        String value = reader.readString(id);
+        // OAK-12133: Detect when trying to read a binary property as a string
+        Type<?> actualType = getType();
+        if (actualType.isArray()) {
+            actualType = actualType.getBaseType();
+        }
+        String message = null;
+        if (actualType == BINARY && type != BINARY) {
+            message = String.format(

Review Comment:
   Ah right! Now I understand. 
   
   But "actualType == BINARY" doesn't always evaluate to true or false.
   
   We could simplify this to "if (actualType == BINARY) { " - that would work, 
UNTIL someone removes the earlier lines
   
           if (type == BINARY) {
               return (T) reader.readBlob(id); // load binaries lazily
           }
   
   ... and then it would no longer be correct... 



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