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 transform WriteToLog NPE #4145 #4186

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public static String[] getLogLevelDescriptions() {
/**
* @return An array of log level codes, sorted by level (0==Nothing, 6=Row Level)
*/
public static String[] logLogLevelCodes() {
public static String[] getLogLevelCodes() {
return IEnumHasCode.getCodes(LogLevel.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public boolean processRow() throws HopException {
}
}
data.fieldnr = data.fieldnrs.length;
data.logLevel = meta.getLogLevel();
data.logLevel = (meta.getLogLevel() == null) ? LogLevel.BASIC : meta.getLogLevel();
data.logMessage = Const.NVL(this.resolve(meta.getLogMessage()), "");
if (!Utils.isEmpty(data.logMessage)) {
data.logMessage += Const.CR + Const.CR;
Expand Down Expand Up @@ -128,35 +128,13 @@ public boolean processRow() throws HopException {
/** Output message to log */
private void setLog(final LogLevel loglevel, final StringBuilder msg) {
switch (loglevel) {
case ERROR:
// Log level = ERREUR
logError(msg.toString());
break;
case MINIMAL:
// Log level = MINIMAL
logMinimal(msg.toString());
break;
case BASIC:
// Log level = BASIC
logBasic(msg.toString());
break;
case DETAILED:
// Log level = DETAILED
logDetailed(msg.toString());
break;
case DEBUG:
// Log level = DEBUG
logDebug(msg.toString());
break;
case ROWLEVEL:
// Log level = ROW LEVEL
logRowlevel(msg.toString());
break;
case NOTHING:
// Log level = NOTHING
break;
default:
break;
case BASIC -> logBasic(msg.toString());
case ERROR -> logError(msg.toString());
case MINIMAL -> logMinimal(msg.toString());
case DETAILED -> logDetailed(msg.toString());
case DEBUG -> logDebug(msg.toString());
case ROWLEVEL -> logRowlevel(msg.toString());
case NOTHING -> {}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,11 @@ public void getData() {
wLimitRows.setSelection(input.isLimitRows());
wLimitRowsNumber.setText("" + input.getLimitRowsNumber());

if (input.getLogLevel() != null) {
wLoglevel.select(input.getLogLevel().getLevel());
LogLevel logLevel = input.getLogLevel();
if (logLevel == null) {
logLevel = LogLevel.BASIC;
}
wLoglevel.select(logLevel.getLevel());

if (input.getLogMessage() != null) {
wLogMessage.setText(input.getLogMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public void check(
if (prev == null || prev.size() == 0) {
cr =
new CheckResult(
CheckResult.TYPE_RESULT_WARNING,
ICheckResult.TYPE_RESULT_WARNING,
BaseMessages.getString(PKG, "WriteToLogMeta.CheckResult.NotReceivingFields"),
transformMeta);
remarks.add(cr);
Expand Down Expand Up @@ -209,7 +209,7 @@ public void check(
if (logFields.isEmpty()) {
cr =
new CheckResult(
CheckResult.TYPE_RESULT_WARNING,
ICheckResult.TYPE_RESULT_WARNING,
BaseMessages.getString(PKG, "WriteToLogMeta.CheckResult.NoFieldsEntered"),
transformMeta);

Expand Down
Loading