ahanikel commented on PR #2795:
URL: https://github.com/apache/jackrabbit-oak/pull/2795#issuecomment-4039546467
@thomasmueller How often do you expect these warnings to occur? As this is
quite performance critical, can we perhaps move the warning and log generation
in the exception handler, doing it only if `readString?` fails?
E.g. as in:
```
String value;
try {
value = reader.readString(id);
} catch (IllegalStateException e) {
// OAK-12133: Detect when trying to read a binary property as a
string
if (e.getMessage() != null &&
e.getMessage().contains("possibly trying to read a BLOB
using getString")) {
Type<?> actualType = getType();
if (actualType.isArray()) {
actualType = actualType.getBaseType();
}
if (actualType == BINARY) {
String message = String.format(
"Attempting to read binary property '%s' as %s. " +
"This can fail if the binary is stored externally. " +
"Binary properties should be checked before getValue()
is called.",
name, type);
if (!LOG_SILENCER.silence(name)) {
LOG.warn(message, e);
}
throw new IllegalStateException(message, e);
}
}
throw e;
}
```
--
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]