You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "wengyingjian (via GitHub)" <gi...@apache.org> on 2024/05/31 07:01:56 UTC
[PR] Fix to Ensure All Rules Satisfy not isInterface [skywalking-java]
wengyingjian opened a new pull request, #695:
URL: https://github.com/apache/skywalking-java/pull/695
### Fix <bug description or the bug issue number or bug issue link>
- [x] Add a unit test to verify that the fix works.
- [x] Explain briefly why the bug exists and how to fix it.
According to the code principles of `net.bytebuddy.matcher.ElementMatcher.Junction`:
In the current code, the running effect can only ensure that the first `NamedMatch` satisfies `not isInterface`:
` (((NamedMatch) and (not(isInterface))) or IndirectMatch) or...IndirectMatch.`
After moving `not isInterface` to the end, the running effect can ensure that all rules satisfy `not isInterface`:
` (((NamedMatch) or (IndirectMatch)) or...IndirectMatch) and not(isInterface).`
- [x] If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #<issue number>.
- [x] Update the [`CHANGES` log](https://github.com/apache/skywalking-java/blob/main/CHANGES.md).
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix to Ensure All Rules Satisfy not isInterface [skywalking-java]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #695:
URL: https://github.com/apache/skywalking-java/pull/695#discussion_r1623718128
##########
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/PluginFinder.java:
##########
@@ -95,13 +95,13 @@ public boolean matches(NamedElement target) {
return nameMatchDefine.containsKey(target.getActualName());
}
};
- judge = judge.and(not(isInterface()));
for (AbstractClassEnhancePluginDefine define : signatureMatchDefine) {
ClassMatch match = define.enhanceClass();
if (match instanceof IndirectMatch) {
judge = judge.or(((IndirectMatch) match).buildJunction());
}
}
+ judge = judge.and(not(isInterface()));
Review Comment:
```suggestion
// Filter out all matchers returns to exclude pure interface types.
judge = not(isInterface()).and(judge);
```
I think this should be the way you propose. The result will be the same as your wrote, but the logic is more clear.
`not an interface` and `all other pre-built checker`.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix to Ensure All Rules Satisfy not isInterface [skywalking-java]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #695:
URL: https://github.com/apache/skywalking-java/pull/695#issuecomment-2144175430
> > In the current code, the running effect can only ensure that the first NamedMatch satisfies not isInterface
>
> @wengyingjian I think the current `Junction` expression is
>
> ```
> (A and not(isInterface())) or (B and not(isInterface())) or ...
> ```
>
> Is my understanding right?
I think the logic error is, that the `is not interface` could be overridden by the `or` from the 2nd condition, as it is flat.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix to Ensure All Rules Satisfy not isInterface [skywalking-java]
Posted by "wengyingjian (via GitHub)" <gi...@apache.org>.
wengyingjian commented on PR #695:
URL: https://github.com/apache/skywalking-java/pull/695#issuecomment-2144145868
Yes, because I didn't find a place that required modifying the bytecode for interfaces, I think all matching rules should be non-interface based.
If that's the case, adding and (not isInterface) in the for loop is indeed a safer approach.
Additionally, I've noticed that some custom IndirectMatch instances include not interface, while some do not.
I'm not sure if this means there is already a place that requires modifying the interface bytecode, or if it's just to maintain flexibility, allowing subclasses to implement it themselves.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix to Ensure All Rules Satisfy not isInterface [skywalking-java]
Posted by "CodePrometheus (via GitHub)" <gi...@apache.org>.
CodePrometheus commented on PR #695:
URL: https://github.com/apache/skywalking-java/pull/695#issuecomment-2141567773
> In the current code, the running effect can only ensure that the first NamedMatch satisfies not isInterface
@wengyingjian I think the current `Junction` expression is
~~~
(A and not(isInterface())) or (B and not(isInterface())) or ...
~~~
Is my understanding right?
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix to Ensure All Rules Satisfy not isInterface [skywalking-java]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #695:
URL: https://github.com/apache/skywalking-java/pull/695#issuecomment-2143201710
I think original request is all things should be not an interface.
First or last are not accurate.
It should use and with all other condition or before all other checks run.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix to Ensure All Rules Satisfy not isInterface [skywalking-java]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #695:
URL: https://github.com/apache/skywalking-java/pull/695#issuecomment-2144156098
In theory, there is no point to intrument an interface, especially we require to add new field to the target.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix to Ensure All Rules Satisfy not isInterface [skywalking-java]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #695:
URL: https://github.com/apache/skywalking-java/pull/695#issuecomment-2144163348
> I've noticed that some custom IndirectMatch instances include not interface, while some do not.
I think those are not necessary, but as the bug you are fixing, they may be added as it is.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix to Ensure All Rules Satisfy not isInterface [skywalking-java]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng merged PR #695:
URL: https://github.com/apache/skywalking-java/pull/695
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org