Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add desensitization extension #433

Merged
merged 2 commits into from
Apr 12, 2021

Conversation

xzchaoo
Copy link
Contributor

@xzchaoo xzchaoo commented Apr 12, 2021

Motivation:

data security

Modification:

add desensitization extension

Result:

* 封装一个定时重置的计数器用于降低某些非必要操作的频率(比如某些预期内的错误日志).
* 具有如下特征:
* <ul>
* <li>计数器的值永远不超过times</li>
Copy link
Member

Choose a reason for hiding this comment

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

The comment cloud be English

@codecov
Copy link

codecov bot commented Apr 12, 2021

Codecov Report

Merging #433 (37778c5) into master (7e6da9d) will decrease coverage by 0.31%.
The diff coverage is 78.12%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #433      +/-   ##
============================================
- Coverage     44.78%   44.47%   -0.32%     
+ Complexity      224      219       -5     
============================================
  Files           287      289       +2     
  Lines          9480     9539      +59     
  Branches        936      947      +11     
============================================
- Hits           4246     4242       -4     
- Misses         4754     4811      +57     
- Partials        480      486       +6     
Impacted Files Coverage Δ Complexity Δ
...ipay/common/tracer/util/DesensitizationHelper.java 56.25% <56.25%> (ø) 0.00 <0.00> (?)
...ipay/common/tracer/core/appender/self/SelfLog.java 78.18% <100.00%> (-1.82%) 0.00 <0.00> (ø)
...er/core/configuration/SofaTracerConfiguration.java 77.46% <100.00%> (+0.65%) 0.00 <0.00> (ø)
...e/middleware/parent/AbstractDigestSpanEncoder.java 97.77% <100.00%> (ø) 0.00 <0.00> (ø)
...n/java/com/alipay/common/tracer/util/CoolDown.java 100.00% <100.00%> (ø) 0.00 <0.00> (?)
...s/spring/redis/encoder/RedisDigestJsonEncoder.java 20.00% <0.00%> (-80.00%) 1.00% <0.00%> (-1.00%)
...racer/plugins/springmvc/SpringMvcStatReporter.java 11.11% <0.00%> (-72.23%) 0.00% <0.00%> (ø%)
...acer/plugins/springmvc/SpringMvcDigestEncoder.java 0.00% <0.00%> (-66.67%) 0.00% <0.00%> (ø%)
...sofa/tracer/plugins/springmvc/SpringMvcTracer.java 76.00% <0.00%> (-16.00%) 0.00% <0.00%> (ø%)
...a/tracer/plugin/flexible/FlexibleStatReporter.java 0.00% <0.00%> (-14.29%) 0.00% <0.00%> (-1.00%)
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7e6da9d...37778c5. Read the comment docs.


final AtomicInteger counter = new AtomicInteger();
long start = System.currentTimeMillis();
// 在 1000ms 和 2000ms 时刻 会重置
Copy link
Member

Choose a reason for hiding this comment

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

English comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

while (true) {
int c = counter.get();
if (c < times) {
if (counter.compareAndSet(c, c + 1)) {
Copy link
Member

Choose a reason for hiding this comment

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

When can‘t get the CAS lock would be retry ,why not return false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like

  1. java.util.concurrent.atomic.AtomicInteger#getAndIncrement
  2. sun.misc.Unsafe#getAndAddInt

Every time, at least one thread will success.

@xzchaoo xzchaoo force-pushed the feature_desensitization3x branch 2 times, most recently from cfbc5b5 to 0c62634 Compare April 12, 2021 03:08
@sofastack-bot sofastack-bot bot added size/L and removed size/XL labels Apr 12, 2021
Copy link
Contributor

@glmapper glmapper left a comment

Choose a reason for hiding this comment

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

LGTM

@glmapper glmapper merged commit 1d23aad into sofastack:master Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants