Improve the error message when additional build-info prop has null value
Closes gh-6724
This commit is contained in:
@@ -22,6 +22,7 @@ import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
@@ -119,9 +120,21 @@ public final class BuildPropertiesWriter {
|
||||
this.artifact = artifact;
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
validateAdditionalProperties(additionalProperties);
|
||||
this.additionalProperties = additionalProperties;
|
||||
}
|
||||
|
||||
private static void validateAdditionalProperties(
|
||||
Map<String, String> additionalProperties) {
|
||||
if (additionalProperties != null) {
|
||||
for (Entry<String, String> property : additionalProperties.entrySet()) {
|
||||
if (property.getValue() == null) {
|
||||
throw new NullAdditionalPropertyValueException(property.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getGroup() {
|
||||
return this.group;
|
||||
}
|
||||
@@ -143,4 +156,16 @@ public final class BuildPropertiesWriter {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception thrown when an additional property with a null value is encountered.
|
||||
*/
|
||||
public static class NullAdditionalPropertyValueException
|
||||
extends IllegalArgumentException {
|
||||
|
||||
public NullAdditionalPropertyValueException(String name) {
|
||||
super("Additional property '" + name + "' is illegal as its value is null");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user