Content-Length: 351546 | pFad | http://github.com/utPLSQL/utPLSQL-cli/pull/171/commits/eca111507a2760d64941e33b56d7d1da4c53374e

7A Bugfix/Locale-Info and Nullpointer by pesse · Pull Request #171 · utPLSQL/utPLSQL-cli · GitHub
Skip to content

Bugfix/Locale-Info and Nullpointer #171

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

Merged
merged 6 commits into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Move Locale-Initialization to Run-Action
Also configure Logger not before Run-Action and log it when we change
the locale based on LC_ALL environment variable
  • Loading branch information
pesse committed Dec 10, 2019
commit eca111507a2760d64941e33b56d7d1da4c53374e
3 changes: 0 additions & 3 deletions src/main/java/org/utplsql/cli/Cli.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ public static void main(String[] args) {

static int runPicocliWithExitCode(String[] args) {

LoggerConfiguration.configure(LoggerConfiguration.ConfigLevel.NONE);
LocaleInitializer.initLocale();

CommandLine commandLine = new CommandLine(UtplsqlPicocliCommand.class);
commandLine.setTrimQuotes(true);

Expand Down
10 changes: 9 additions & 1 deletion src/main/java/org/utplsql/cli/LocaleInitializer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.utplsql.cli;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.utplsql.api.EnvironmentVariableUtil;

import java.util.Locale;
Expand All @@ -18,6 +20,8 @@
*/
class LocaleInitializer {

private static final Logger logger = LoggerFactory.getLogger(RunAction.class);

private static final Pattern REGEX_LOCALE = Pattern.compile("^([a-zA-Z]+)[_-]([a-zA-Z]+)"); // We only need the very first part and are pretty forgiving in parsing

/**
Expand All @@ -27,7 +31,10 @@ static void initLocale() {

boolean localeChanged = setDefaultLocale(EnvironmentVariableUtil.getEnvValue("LC_ALL"));
if (!localeChanged) {
setDefaultLocale(EnvironmentVariableUtil.getEnvValue("LANG"));
localeChanged = setDefaultLocale(EnvironmentVariableUtil.getEnvValue("LANG"));
}
if ( !localeChanged ) {
logger.debug("Java Locale not changed from LC_ALL or LANG environment variable");
}
}

Expand All @@ -54,6 +61,7 @@ private static boolean setDefaultLocale(String localeString) {
Locale l = new Locale.Builder().setLanguageTag(sb.toString()).build();
if (l != null) {
Locale.setDefault(l);
logger.debug("Java Locale changed to {}", l);
return true;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/utplsql/cli/RunAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public RunAction(RunCommandConfig config) {

void init() {
LoggerConfiguration.configure(config.getLogConfigLevel());
LocaleInitializer.initLocale();
}

public RunCommandConfig getConfig() {
Expand Down








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/utPLSQL/utPLSQL-cli/pull/171/commits/eca111507a2760d64941e33b56d7d1da4c53374e

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy