dcapwell commented on code in PR #3827:
URL: https://github.com/apache/cassandra/pull/3827#discussion_r1929038884
##########
src/java/org/apache/cassandra/tools/FieldUtil.java:
##########
@@ -27,19 +28,44 @@ public static void setInstanceUnsafe(Class<?> klass, Object
v, String fieldName)
{
try
{
- Field field = klass.getDeclaredField(fieldName);
- field.setAccessible(true);
+ setInstanceUnsafeThrowing(klass, v, fieldName);
+ }
+ catch (Throwable e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
- Field modifiersField = Field.class.getDeclaredField("modifiers");
- modifiersField.setAccessible(true);
- modifiersField.setInt(field, field.getModifiers() &
~Modifier.FINAL);
+ private static void setInstanceUnsafeThrowing(Class<?> klass, Object v,
String fieldName) throws Throwable
+ {
+ Field field = klass.getDeclaredField(fieldName);
+ field.setAccessible(true);
- field.set(null, v);
+ try
+ {
+ Field modifiers = Field.class.getDeclaredField("modifiers");
Review Comment:
this pattern was fixed awhile back, can we use
`org.apache.cassandra.utils.ReflectionUtils#getModifiersField` rather than do
our own thing?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]