Skip to content

Check whether stdout is a real console#79882

Merged
tvernum merged 4 commits intoelastic:masterfrom
tvernum:classload-ansi-console
Oct 28, 2021
Merged

Check whether stdout is a real console#79882
tvernum merged 4 commits intoelastic:masterfrom
tvernum:classload-ansi-console

Conversation

@tvernum
Copy link
Copy Markdown
Contributor

@tvernum tvernum commented Oct 27, 2021

Adds a new "ConsoleLoader" that uses jANSI in a separate classloader
to determine whether standard output is a real console (that is, not
redirected to a file or /dev/null, etc)

Adds a new "ConsoleLoader" that uses jANSI in a separate classloader
to determine whether standard output is a real console (that is, not
redirected to a file or /dev/null, etc)
@tvernum tvernum added >enhancement :Core/Infra/Core Core issues without another label v8.0.0 labels Oct 27, 2021
@tvernum tvernum requested review from jkakavas and rjernst October 27, 2021 04:08
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Oct 27, 2021
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@tvernum
Copy link
Copy Markdown
Contributor Author

tvernum commented Oct 27, 2021

@rjernst I think this roughly what you had in mind in your comments here #79740 (review)

This implementation is a little rough (I'm not sure ansi-console really belongs in distribution/tools) and the classloading code simply copies from #77544, but I wanted to make sure this is the direction you were looking for.

Copy link
Copy Markdown
Contributor

@jkakavas jkakavas left a comment

Choose a reason for hiding this comment

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

LGTM, I verified the intended behavior manually too

Copy link
Copy Markdown
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

LGTM.

public static void init(PrintStream originalStandardOut) {
BootstrapInfo.originalStandardOut = originalStandardOut;
public static void init() {
BootstrapInfo.consoleOutput = new SetOnce<>();
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.

I would just construct the SetOnce at the declaration of consoleOutput. Then it can be final.

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.

Thanks.
I'm not sure how I ended leaving it like that - a rush to prove the prototype, I guess.

@tvernum tvernum added the v8.1.0 label Oct 28, 2021
@tvernum tvernum merged commit 71c7022 into elastic:master Oct 28, 2021
tvernum added a commit to tvernum/elasticsearch that referenced this pull request Oct 28, 2021
Adds a new "ConsoleLoader" that uses jANSI in a separate classloader
to determine whether standard output is a real console (that is, not
redirected to a file or /dev/null, etc)

Also updates security auto-configuration to only print out credentials
when there is a console.

Backport of: elastic#79882
elasticsearchmachine pushed a commit that referenced this pull request Oct 28, 2021
Adds a new "ConsoleLoader" that uses jANSI in a separate classloader
to determine whether standard output is a real console (that is, not
redirected to a file or /dev/null, etc)

Also updates security auto-configuration to only print out credentials
when there is a console.

Backport of: #79882

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
weizijun added a commit to weizijun/elasticsearch that referenced this pull request Oct 28, 2021
…formance

* upstream/master: (153 commits)
  [ML] update truncation default & adding field output when input is truncated (elastic#79942)
  [ML] stop using isAllowedByLicense for model license checks (elastic#79908)
  [ML] Retain built-in ML roles granting Kibana privileges (elastic#80014)
  [Transform] remove old mixed cluster BWC layers, not required for 8x (elastic#79927)
  Increase test timeout for CoordinatorTests testAllSearchesExecuted
  [Transform] add rolling upgrade tests for upgrade endpoint (elastic#79721)
  [ML] Update trained model docs for truncate parameter for bert tokenization (elastic#79652)
  `CoordinatorTests` sometimes needs three term bumps (elastic#79574)
  [ML] Account for service being triggered twice in tests (elastic#80000)
  SearchContext: remove unused variable (elastic#79917)
  Revert "Deprecate resolution loss on date field (elastic#78921)" (elastic#79914)
  Re-enable GeoIpDownloaderIT#testStartWithNoDatabases() (elastic#79907)
  Fix SnapshotBasedIndexRecoveryIT#testSeqNoBasedRecoveryIsUsedAfterPrimaryFailOver (elastic#79469)
  Fix RecoverySourceHandlerTests (elastic#79546)
  SQL: stabilize SqlSearchPageTimeoutIT (elastic#79928)
  Wait 3 seconds for the server to reload trust (elastic#79778)
  Skip automatically preserved request headers when rewriting (elastic#79973)
  Check whether stdout is a real console (elastic#79882)
  Convert remote license checker to use LicensedFeature (elastic#79876)
  Miscellaneous fixes for LDAP SDK v6 upgrade (elastic#79891)
  ...

# Conflicts:
#	libs/x-content/src/main/java/org/elasticsearch/xcontent/support/filtering/FilterPath.java
#	libs/x-content/src/test/java/org/elasticsearch/xcontent/support/filtering/FilterPathGeneratorFilteringTests.java
#	libs/x-content/src/test/java/org/elasticsearch/xcontent/support/filtering/FilterPathTests.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Core/Infra/Core Core issues without another label >enhancement Team:Core/Infra Meta label for core/infra team v8.0.0-beta1 v8.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants