-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
debuggability improvements to the CDK #37746
debuggability improvements to the CDK #37746
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @stephane-airbyte and the rest of your teammates on |
5b62126
to
997351f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple nitpicks and some questions to make sure I understand what's going on. Slightly spooky PR but I don't see a better way to do it so 🤷
.../java/airbyte-cdk/core/src/main/kotlin/io/airbyte/cdk/integrations/base/IntegrationRunner.kt
Outdated
Show resolved
Hide resolved
.../java/airbyte-cdk/core/src/main/kotlin/io/airbyte/cdk/integrations/base/IntegrationRunner.kt
Outdated
Show resolved
Hide resolved
...res/kotlin/io/airbyte/cdk/integrations/standardtest/destination/DestinationAcceptanceTest.kt
Show resolved
Hide resolved
...e-cdk/core/src/testFixtures/kotlin/io/airbyte/cdk/extensions/LoggingInvocationInterceptor.kt
Show resolved
Hide resolved
"Junit starting {} with timeout of {}", | ||
logLineSuffix, | ||
DurationFormatUtils.formatDurationWords(timeout.toMillis(), true, true) | ||
) | ||
Timer("TimeoutTimer-" + currentThread.name, true) | ||
.schedule(timeoutTask, timeout.toMillis()) | ||
var timer = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this var referenced anywhere? doesn't seem to be the case
|
||
class TestContext { | ||
companion object { | ||
val CURRENT_TEST_NAME: ThreadLocal<String?> = ThreadLocal() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convention in kotlin is to reserve upper-case snake case to const val
s. I'm surprised your IDE didn't hint about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from the kotlin guide:
Names of constants (properties marked with const, or top-level or object val properties with no custom get function that hold deeply immutable data) should use uppercase underscore-separated (screaming snake case) names
I think this is what we're supposed to do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL! Thanks
build.gradle
Outdated
@@ -139,6 +139,9 @@ allprojects { | |||
// This is also required, to prevent stderr spam starting with | |||
// "OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader cl..." | |||
jvmArgs "-Xshare:off" | |||
// This is required for our dangling thread checks at the end of a connector run. | |||
// see IntegrationRunner.stopOrphanedThreads |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at this function and I'm none the wiser as to why this --add-opens
flag is required. This might be out of scope of this PR but if you do know why please take this opportunity to add some more detailed explanations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's because we use introspection to change the access of the ThreadLocal.get(Thread)
ThreadLocal::class.java.getDeclaredMethod("get", Thread::class.java) | ||
init { | ||
getMethod.isAccessible = true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fyi you can also do
private val getMethod: Method = ThreadLocal::class.java.getDeclaredMethod("get", Thread::class.java).also { isAccessible = true }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with the changes in IntegrationRunner
so this is good to go as far as I'm concerned. If it works, it works.
961d513
to
55bf52e
Compare
55bf52e
to
41beb7a
Compare
/publish-java-cdk
|
// opened method | ||
private val getMethod: Method = | ||
ThreadLocal::class.java.getDeclaredMethod("get", Thread::class.java).also { | ||
it.isAccessible = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting an error here, not sure if I'm doing something silly or if there was a bug introduced here?
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make private java.lang.Object java.lang.ThreadLocal.get(java.lang.Thread) accessible: module java.base does not "opens java.lang" to unnamed module @5f058f00
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how you're executing this. I've tested this when running tests from intelliJ and airbyte-ci, as well as when running a connector through the docker image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephane-airbyte try running this main method through Intellij IDE:
With the following parameters:
- Java 21 SDK
- Cli arguments
--write --config /<my_path>/config.json --catalog /<my_path>/configured_catalog.json
- Click
Modify options
->Redirect input
and then add example input message<my_path>/message.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need an additional JVM parameters, --add-opens=java.base/java.lang=ALL-UNNAMED
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Roger -- thanks!
A few changes to improve debuggability:
Another change that was initially in there but has been removed and might be worth thinking about:
Today, only Write checks for live threads on shutdown. We might want to do that for other operations as well