Skip to content

[improve][test] Remove conscrypt exception stacktrace in Apple silicon - #18359

Merged
Technoboy- merged 5 commits into
apache:masterfrom
yaalsn:remove-conscrypt-exception-log
Nov 19, 2022
Merged

Technoboy- merged 5 commits into
apache:masterfrom
yaalsn:remove-conscrypt-exception-log

Conversation

@yaalsn

@yaalsn yaalsn commented Nov 7, 2022

Copy link
Copy Markdown
Contributor

Motivation

When running tests in Macos Apple silicon, there will be a long stacktrace like this

Caused by: java.lang.UnsatisfiedLinkError: no conscrypt_openjdk_jni-osx-aarch_64 in java.library.path: /Users/yaalsn/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:2429) ~[?:?]
	at java.lang.Runtime.loadLibrary0(Runtime.java:818) ~[?:?]
	at java.lang.System.loadLibrary(System.java:1989) ~[?:?]
	at org.conscrypt.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:54) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at org.conscrypt.NativeLibraryLoader$1.run(NativeLibraryLoader.java:297) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	at org.conscrypt.NativeLibraryLoader$1.run(NativeLibraryLoader.java:289) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	at java.security.AccessController.doPrivileged(AccessController.java:318) ~[?:?]
	at org.conscrypt.NativeLibraryLoader.loadLibraryFromHelperClassloader(NativeLibraryLoader.java:289) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	at org.conscrypt.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:262) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	at org.conscrypt.NativeLibraryLoader.load(NativeLibraryLoader.java:162) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	at org.conscrypt.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:106) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	at org.conscrypt.NativeCryptoJni.init(NativeCryptoJni.java:50) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	at org.conscrypt.NativeCrypto.<clinit>(NativeCrypto.java:64) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	at org.conscrypt.Conscrypt.checkAvailability(Conscrypt.java:119) ~[conscrypt-openjdk-uber-2.5.2.jar:2.5.2]
	... 41 more

...

There's no osx aarch_64 conscrypt, so we can filter this stacktrace by catching java.lang.UnsatisfiedLinkError.

Verifying this change

  • Make sure that the change passes the CI checks.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: https://github.com/yaalsn/pulsar/pull/16

@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Nov 7, 2022
conscryptClazz.getMethod("checkAvailability").invoke(null);
} catch (Throwable e) {
log.warn("Conscrypt isn't available. Using JDK default security provider.", e);
if (e.getCause() != null && e.getCause().getClass().getName().equals("java.lang.UnsatisfiedLinkError")) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we use debug instead of warn?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's better to use level warn because it is a exception — not a If - else or something needs to record. This warn means conscrypt is not supported which needs to remind.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If you want to avoid the too-long message, I suggest you just output the message and then add a debug log to print the stack trace.

@codelipenghui codelipenghui added this to the 2.12.0 milestone Nov 16, 2022
@codelipenghui codelipenghui added type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages type/flaky-tests area/test and removed type/flaky-tests labels Nov 16, 2022
@codelipenghui

Copy link
Copy Markdown
Contributor

/pulsarbot run-failure-checks

@codecov-commenter

codecov-commenter commented Nov 16, 2022 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.21%. Comparing base (67d9d63) to head (d96b604).
⚠️ Report is 3373 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #18359      +/-   ##
============================================
+ Coverage     40.29%   47.21%   +6.92%     
- Complexity     8685    10403    +1718     
============================================
  Files           687      692       +5     
  Lines         67441    67764     +323     
  Branches       7225     7259      +34     
============================================
+ Hits          27175    31995    +4820     
+ Misses        37257    32183    -5074     
- Partials       3009     3586     +577     
Flag Coverage Δ
unittests 47.21% <ø> (+6.92%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 211 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nodece
nodece requested a review from tisonkun November 16, 2022 08:40

@tisonkun tisonkun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. One code quality suggestion inline.

conscryptClazz.getMethod("checkAvailability").invoke(null);
} catch (Throwable e) {
log.warn("Conscrypt isn't available. Using JDK default security provider.", e);
if (e.getCause() instanceof UnsatisfiedLinkError) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@codelipenghui @nodece Do we have an exception util like Flink's findThrowable? I'm afraid that the error may be changed to differ wrap level.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No.

@yaalsn

yaalsn commented Nov 16, 2022

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@Technoboy-
Technoboy- merged commit 73ea9ff into apache:master Nov 19, 2022
lifepuzzlefun pushed a commit to lifepuzzlefun/pulsar that referenced this pull request Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/test doc-not-needed Your PR changes do not impact docs type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants