Skip to content

Conversation

@Allan-QLB
Copy link
Contributor

由于ObjectPropertyAccessor会优先尝试调用字段的get方法或read方法(例如名称为hasXXX的方法),有时候这些方法并不会直接返回字段值,导致无法查看对象的某些字段,例如org.apache.kafka.clients.consumer.internals.Fetcher,查看字段completedFetches返回的是一个boolean类型

public class Fetcher<K, V> implements Closeable {
   
    private final int maxPollRecords;
    private final boolean checkCrcs;
    private final String clientRackId;
    private final ConsumerMetadata metadata;
    private final FetchManagerMetrics sensors;
    private final SubscriptionState subscriptions;
    private final ConcurrentLinkedQueue<CompletedFetch> completedFetches;
   
    private final ApiVersions apiVersions;

    private PartitionRecords nextInLineRecords = null;

  
    public boolean hasCompletedFetches() {
        return !completedFetches.isEmpty();
    }
}

image
企业微信截图_17327018456771

@heroPeak
Copy link

由于ObjectPropertyAccessor会优先尝试调用字段的get方法或read方法(例如名称为hasXXX的方法),有时候这些方法并不会直接返回字段值,导致无法查看对象的某些字段,例如org.apache.kafka.clients.consumer.internals.Fetcher,查看字段completedFetches返回的是一个boolean类型

public class Fetcher<K, V> implements Closeable {
   
    private final int maxPollRecords;
    private final boolean checkCrcs;
    private final String clientRackId;
    private final ConsumerMetadata metadata;
    private final FetchManagerMetrics sensors;
    private final SubscriptionState subscriptions;
    private final ConcurrentLinkedQueue<CompletedFetch> completedFetches;
   
    private final ApiVersions apiVersions;

    private PartitionRecords nextInLineRecords = null;

  
    public boolean hasCompletedFetches() {
        return !completedFetches.isEmpty();
    }
}

image 企业微信截图_17327018456771

请问这个问题在哪个版本修复了啊?我也遇到这个问题了

@Allan-QLB
Copy link
Contributor Author

请问这个问题在哪个版本修复了啊?我也遇到这个问题了

目前还没

@hengyunabc
Copy link
Collaborator

这个可以加些测试不?

@Allan-QLB
Copy link
Contributor Author

这个可以加些测试不?

已加

public Object getPossibleProperty(Map context, Object target, String name) throws OgnlException {
Object result;
try {
result = OgnlRuntime.getFieldValue((OgnlContext) context, target, name, true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个修复貌似不合理。原始的 ognl是支持对 getter 函数用 . 去访问的。比如有一个 getName,可以用 xxx.name 去获取。 这个修改会导致原来的 OgnlRuntime.getMethodValue 的尝试没有了。

另外,直接用 OgnlRuntime.getFieldValue 可能在高版本的 jdk 会有问题。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我在ognl上针对这个问题也做了改动,orphan-oss/ognl#313
在ognlcontext中增加了忽略readmethod的参数,这样还是会尝试getter方法,用这个改动是否可以,如果可以的话就可以考虑升级ognl

另外这个问题在ognl已经修复#2954
orphan-oss/ognl#337

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

之前升级 ognl 出现了几个问题,不得不把 ognl 降级了。如果要再升级ognl版本,要仔细测试下😂。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants