Skip to content

Revert "[enhancement](jni)append exception check for jni code."#43497

Closed
hubgeter wants to merge 2 commits intoapache:masterfrom
hubgeter:revert-42507-jni_check_exception
Closed

Revert "[enhancement](jni)append exception check for jni code."#43497
hubgeter wants to merge 2 commits intoapache:masterfrom
hubgeter:revert-42507-jni_check_exception

Conversation

@hubgeter
Copy link
Copy Markdown
Contributor

@hubgeter hubgeter commented Nov 8, 2024

Reverts #42507

@doris-robot
Copy link
Copy Markdown

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@hubgeter
Copy link
Copy Markdown
Contributor Author

hubgeter commented Nov 8, 2024

run buildall

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

GetMethodID(_threadInfoClass, "getThreadState", "()Ljava/lang/Thread$State;"));

RETURN_IF_ERROR(JniUtil::GetGlobalClassRef(env, "java/lang/Thread$State", &_threadStateClass));
void JvmStats::init(JNIEnv* ENV) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: function 'init' exceeds recommended size/complexity thresholds [readability-function-size]

void JvmStats::init(JNIEnv* ENV) {
               ^
Additional context

be/src/util/jvm_metrics.cpp:184: 125 lines including whitespace and comments (threshold 80)

void JvmStats::init(JNIEnv* ENV) {
               ^

Comment on lines +309 to 310
return;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: redundant return statement at the end of a function with a void return type [readability-redundant-control-flow]

Suggested change
return;
}
}

}

Status JvmStats::refresh(JvmMetrics* jvm_metrics) const {
void JvmStats::refresh(JvmMetrics* jvm_metrics) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: function 'refresh' has cognitive complexity of 66 (threshold 50) [readability-function-cognitive-complexity]

void JvmStats::refresh(JvmMetrics* jvm_metrics) {
               ^
Additional context

be/src/util/jvm_metrics.cpp:312: +1, including nesting penalty of 0, nesting level increased to 1

    if (!_init_complete) {
    ^

be/src/util/jvm_metrics.cpp:317: +1, including nesting penalty of 0, nesting level increased to 1

    if (!st.ok()) {
    ^

be/src/util/jvm_metrics.cpp:332: +1, including nesting penalty of 0, nesting level increased to 1

    jvm_metrics->jvm_heap_size_bytes_used->set_value(heapMemoryUsed < 0 ? 0 : heapMemoryUsed);
                                                                        ^

be/src/util/jvm_metrics.cpp:334: +1, including nesting penalty of 0, nesting level increased to 1

            heapMemoryCommitted < 0 ? 0 : heapMemoryCommitted);
                                    ^

be/src/util/jvm_metrics.cpp:335: +1, including nesting penalty of 0, nesting level increased to 1

    jvm_metrics->jvm_heap_size_bytes_max->set_value(heapMemoryMax < 0 ? 0 : heapMemoryMax);
                                                                      ^

be/src/util/jvm_metrics.cpp:345: +1, including nesting penalty of 0, nesting level increased to 1

            nonHeapMemoryCommitted < 0 ? 0 : nonHeapMemoryCommitted);
                                       ^

be/src/util/jvm_metrics.cpp:346: +1, including nesting penalty of 0, nesting level increased to 1

    jvm_metrics->jvm_non_heap_size_bytes_used->set_value(nonHeapMemoryUsed < 0 ? 0
                                                                               ^

be/src/util/jvm_metrics.cpp:354: +1, including nesting penalty of 0, nesting level increased to 1

    for (int i = 0; i < size; ++i) {
    ^

be/src/util/jvm_metrics.cpp:371: +2, including nesting penalty of 1, nesting level increased to 2

        if (nameStr != nullptr) {
        ^

be/src/util/jvm_metrics.cpp:373: +3, including nesting penalty of 2, nesting level increased to 3

            if (it == _memoryPoolName.end()) {
            ^

be/src/util/jvm_metrics.cpp:376: +3, including nesting penalty of 2, nesting level increased to 3

            if (it->second == memoryPoolNameEnum::YOUNG) {
            ^

be/src/util/jvm_metrics.cpp:377: +4, including nesting penalty of 3, nesting level increased to 4

                jvm_metrics->jvm_young_size_bytes_used->set_value(used < 0 ? 0 : used);
                                                                           ^

be/src/util/jvm_metrics.cpp:378: +4, including nesting penalty of 3, nesting level increased to 4

                jvm_metrics->jvm_young_size_bytes_peak_used->set_value(peakUsed < 0 ? 0 : peakUsed);
                                                                                    ^

be/src/util/jvm_metrics.cpp:379: +4, including nesting penalty of 3, nesting level increased to 4

                jvm_metrics->jvm_young_size_bytes_max->set_value(max < 0 ? 0 : max);
                                                                         ^

be/src/util/jvm_metrics.cpp:381: +1, nesting level increased to 3

            } else if (it->second == memoryPoolNameEnum::OLD) {
                   ^

be/src/util/jvm_metrics.cpp:382: +4, including nesting penalty of 3, nesting level increased to 4

                jvm_metrics->jvm_old_size_bytes_used->set_value(used < 0 ? 0 : used);
                                                                         ^

be/src/util/jvm_metrics.cpp:383: +4, including nesting penalty of 3, nesting level increased to 4

                jvm_metrics->jvm_old_size_bytes_peak_used->set_value(peakUsed < 0 ? 0 : peakUsed);
                                                                                  ^

be/src/util/jvm_metrics.cpp:384: +4, including nesting penalty of 3, nesting level increased to 4

                jvm_metrics->jvm_old_size_bytes_max->set_value(max < 0 ? 0 : max);
                                                                       ^

be/src/util/jvm_metrics.cpp:407: +1, including nesting penalty of 0, nesting level increased to 1

    jvm_metrics->jvm_thread_peak_count->set_value(peakThreadCount < 0 ? 0 : peakThreadCount);
                                                                      ^

be/src/util/jvm_metrics.cpp:408: +1, including nesting penalty of 0, nesting level increased to 1

    jvm_metrics->jvm_thread_count->set_value(threadCount < 0 ? 0 : threadCount);
                                                             ^

be/src/util/jvm_metrics.cpp:410: +1, including nesting penalty of 0, nesting level increased to 1

    for (int i = 0; i < threadCount; i++) {
    ^

be/src/util/jvm_metrics.cpp:412: +2, including nesting penalty of 1, nesting level increased to 2

        if (threadInfo == nullptr) {
        ^

be/src/util/jvm_metrics.cpp:417: +2, including nesting penalty of 1, nesting level increased to 2

        if (env->IsSameObject(threadState, _newThreadStateObj)) {
        ^

be/src/util/jvm_metrics.cpp:419: +1, nesting level increased to 2

        } else if (env->IsSameObject(threadState, _runnableThreadStateObj)) {
               ^

be/src/util/jvm_metrics.cpp:421: +1, nesting level increased to 2

        } else if (env->IsSameObject(threadState, _blockedThreadStateObj)) {
               ^

be/src/util/jvm_metrics.cpp:423: +1, nesting level increased to 2

        } else if (env->IsSameObject(threadState, _waitingThreadStateObj)) {
               ^

be/src/util/jvm_metrics.cpp:425: +1, nesting level increased to 2

        } else if (env->IsSameObject(threadState, _timedWaitingThreadStateObj)) {
               ^

be/src/util/jvm_metrics.cpp:427: +1, nesting level increased to 2

        } else if (env->IsSameObject(threadState, _terminatedThreadStateObj)) {
               ^

be/src/util/jvm_metrics.cpp:434: +1, including nesting penalty of 0, nesting level increased to 1

    jvm_metrics->jvm_thread_new_count->set_value(threadsNew < 0 ? 0 : threadsNew);
                                                                ^

be/src/util/jvm_metrics.cpp:435: +1, including nesting penalty of 0, nesting level increased to 1

    jvm_metrics->jvm_thread_runnable_count->set_value(threadsRunnable < 0 ? 0 : threadsRunnable);
                                                                          ^

be/src/util/jvm_metrics.cpp:436: +1, including nesting penalty of 0, nesting level increased to 1

    jvm_metrics->jvm_thread_blocked_count->set_value(threadsBlocked < 0 ? 0 : threadsBlocked);
                                                                        ^

be/src/util/jvm_metrics.cpp:437: +1, including nesting penalty of 0, nesting level increased to 1

    jvm_metrics->jvm_thread_waiting_count->set_value(threadsWaiting < 0 ? 0 : threadsWaiting);
                                                                        ^

be/src/util/jvm_metrics.cpp:439: +1, including nesting penalty of 0, nesting level increased to 1

            threadsTimedWaiting < 0 ? 0 : threadsTimedWaiting);
                                    ^

be/src/util/jvm_metrics.cpp:440: +1, including nesting penalty of 0, nesting level increased to 1

    jvm_metrics->jvm_thread_terminated_count->set_value(threadsTerminated < 0 ? 0
                                                                              ^

be/src/util/jvm_metrics.cpp:448: +1, including nesting penalty of 0, nesting level increased to 1

    for (int i = 0; i < numCollectors; i++) {
    ^

be/src/util/jvm_metrics.cpp:455: +2, including nesting penalty of 1, nesting level increased to 2

        if (gcNameStr != nullptr) {
        ^

be/src/util/jvm_metrics.cpp:456: +3, including nesting penalty of 2, nesting level increased to 3

            if (strcmp(gcNameStr, "G1 Young Generation") == 0) {
            ^

be/src/util/jvm_metrics.cpp:460: +1, nesting level increased to 3

            } else {
              ^

}

Status JvmStats::refresh(JvmMetrics* jvm_metrics) const {
void JvmStats::refresh(JvmMetrics* jvm_metrics) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: function 'refresh' exceeds recommended size/complexity thresholds [readability-function-size]

void JvmStats::refresh(JvmMetrics* jvm_metrics) {
               ^
Additional context

be/src/util/jvm_metrics.cpp:311: 164 lines including whitespace and comments (threshold 80)

void JvmStats::refresh(JvmMetrics* jvm_metrics) {
               ^

}

Status JvmStats::refresh(JvmMetrics* jvm_metrics) const {
void JvmStats::refresh(JvmMetrics* jvm_metrics) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: method 'refresh' can be made const [readability-make-member-function-const]

be/src/util/jvm_metrics.h:102:

-     void refresh(JvmMetrics* jvm_metrics);
+     void refresh(JvmMetrics* jvm_metrics) const;
Suggested change
void JvmStats::refresh(JvmMetrics* jvm_metrics) {
void JvmStats::refresh(JvmMetrics* jvm_metrics) const {

@doris-robot
Copy link
Copy Markdown

TeamCity be ut coverage result:
Function Coverage: 37.90% (9864/26027)
Line Coverage: 29.10% (82262/282692)
Region Coverage: 28.35% (42342/149337)
Branch Coverage: 24.82% (21433/86344)
Coverage Report: http://coverage.selectdb-in.cc/coverage/7a921a38a58f049c72a13872cff68b927a8cf40f_7a921a38a58f049c72a13872cff68b927a8cf40f/report/index.html

@hubgeter
Copy link
Copy Markdown
Contributor Author

run buildall

@hubgeter hubgeter closed this Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants