Open nadment opened 3 months ago
Duplicate #1949
Something has gone wrong with this
java.lang.NullPointerException: Cannot invoke "org.apache.hop.core.logging.LogLevel.ordinal()" because "loglevel" is null
at org.apache.hop.pipeline.transforms.writetolog.WriteToLog.setLog(WriteToLog.java:130)
at org.apache.hop.pipeline.transforms.writetolog.WriteToLog.processRow(WriteToLog.java:116)
at org.apache.hop.pipeline.transform.RunThread.run(RunThread.java:54)
at java.base/java.lang.Thread.run(Thread.java:840)
Sorry, I trusted the Junit tests blindly !
The transform Log level property in XML:
<loglevel>
log_level_basic</loglevel>
<loglevel>
Basic</loglevel>
The WriteToLog action also uses <loglevel>
Basic</loglevel>
I think we should keep the current form of storage.
We can renforce code, if it's null we use Basic as default. We can also add a patch to deserialize Hop's value from 1.0 to 2.9 or agree to reset it to Basic by default ?
Yes I did I think something like that in the past accept all of the values but only save the correct ones
I have a fix for the NPE but for the moment it's not backwards compatible and I haven't found a way in LogLevel or XmlMetadataUtil to use an alias.
public static LogLevel lookupCode(final String code) {
// Try alias for WriteToLog transform compatibility version before 2.10
LogLevel alias = IEnumHasCode.lookupCode(LogLevel.class, "log_level_" + code, null);
if (alias != null) {
return alias;
}
return IEnumHasCode.lookupCode(LogLevel.class, code, LogLevel.BASIC);
}
I can't find a way except to add a method to the IEnumHasCode interface and use it in XmlMetadataUtil.
public interface IEnumHasCode {
String getCode();
/** Returns a list of code aliases, useful for backward compatibility. */
default List<String> getAlias() {
return List.of();
}
}
Someone might have a better idea?
What needs to happen?
Cleanup XML of transform WriteToLog
Issue Priority
Priority: 3
Issue Component
Component: Metadata, Component: Transforms