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

fix: Now showing integration errors when verbose is on #1630

Merged
merged 2 commits into from
Sep 30, 2023

Conversation

quintesse
Copy link
Contributor

No description provided.

@quintesse quintesse requested a review from maxandersen June 7, 2023 16:12
@maxandersen
Copy link
Collaborator

Using the self classloader so scripts can be their own integration? That's...not sure - either crazy or brilliant :)

@quintesse
Copy link
Contributor Author

Using the self classloader so scripts can be their own integration? That's...not sure - either crazy or brilliant :)

🙂

But why not? You might want to achieve something that you just can't do with regular code. I mean, the alternative is really hard: you would first need to turn the integration into a dependency published on Maven central before being able to use it.

Also, we support //SOURCES that are URLs, so you could imagine some kind of nice integration that you just include in your script and it automagically does something useful.

But the real reason is that I was looking for an easy way to test integrations 😉

@quintesse quintesse changed the title Improved integration handling fix: Now showing integration errors when verbose is on Jun 8, 2023
@quintesse
Copy link
Contributor Author

Ok, split PR in two, this one should now be a no-brainer to merge, it simply fixes #1499 and makes it possible to run external integrations when running inside an IDE, great for debugging,

@maxandersen
Copy link
Collaborator

very weird issue ...first time I ran with this --verbose resulted in the final output to not be shown.

jbang init -t qcli t.java
jbang --verbose t.java

shows all the output but didn't actually run or at least not printed "Hello World!!"

but I can't reliably reproduce it.

wondering if there are a possible race condition on out put streams?

@@ -267,6 +278,7 @@ public static void main(String... args) {
IntegrationInput input = parser.fromJson(new InputStreamReader(System.in), IntegrationInput.class);
ClassLoader old = Thread.currentThread().getContextClassLoader();
PrintStream oldout = System.out;
Util.setVerbose(input.verbose);
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't this not be reversed afterwards?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, in the case JBang itself is running the code this line is a no-op (it will be setting it to its current value) while in the case of external code the app will exit afterwards anyway.

@maxandersen
Copy link
Collaborator

also - i dont notice a difference.. got example to test with?

@quintesse
Copy link
Contributor Author

quintesse commented Jun 10, 2023

also - i dont notice a difference.. got example to test with?

Something has to go wrong, that's the only thing that should change. So instead of swallowing errors you should now be able to see them.

Edit: Btw, that was the thing that the other PR was for: to be able to test this stuff 😉

@quintesse
Copy link
Contributor Author

wondering if there are a possible race condition on out put streams?

Perhaps, I haven't ever seen it myself. But there's nothing in this PR that fools around with streams, so it might be an existing issue.

@maxandersen
Copy link
Collaborator

needs rebasing

Before the class loader would not be set up correctly
because it expects to be running from an uber JAR with
all the dependencies available. Now we specifically
add the path to the Gson library in those cases.
The user won't notice but it makes life easier for
developers.
@quintesse
Copy link
Contributor Author

Done

@maxandersen maxandersen merged commit d8b8bb4 into jbangdev:main Sep 30, 2023
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