theonedev/onedev · error · org.apache.wicket.util.string.StringValueConversionException

Character value was null

Error message

Character value was null

What it means

Strings.toChar(CharSequence) throws StringValueConversionException('Character value was null') when the input string is null (the empty-string case is handled separately upstream). The conversion API refuses to guess a default character, so callers must ensure the value is present before conversion.

Source

Thrown at server-core/src/main/java/org/apache/wicket/util/string/Strings.java:1012

	 * @throws StringValueConversionException
	 *             when the string is longer or shorter than 1 character, or <code>null</code>.
	 */
	public static char toChar(final String s) throws StringValueConversionException
	{
		if (s != null)
		{
			if (s.length() == 1)
			{
				return s.charAt(0);
			}
			else
			{
				throw new StringValueConversionException("Expected single character, not \"" + s +
					"\"");
			}
		}

		throw new StringValueConversionException("Character value was null");
	}

	/**
	 * Converts unicodes to encoded &#92;uxxxx.
	 * 
	 * @param unicodeString
	 *            The unicode string
	 * @return The escaped unicode string, like '\u4F60\u597D'.
	 */
	public static String toEscapedUnicode(final String unicodeString)
	{
		if ((unicodeString == null) || (unicodeString.length() == 0))
		{
			return unicodeString;
		}
		int len = unicodeString.length();
		int bufLen = len * 2;
		StringBuilder outBuffer = new StringBuilder(bufLen);

View on GitHub (pinned to d44925c47c)

Solutions

  1. Check Strings.isEmpty(value) and supply a default character before calling toChar
  2. Provide a fallback in the caller: value == null ? DEFAULT : Strings.toChar(value)
  3. Ensure the config entry or parameter is actually set when the conversion is required

Example fix

// before
char sep = Strings.toChar(props.get("separator")); // null -> throw
// after
String v = props.get("separator");
char sep = Strings.isEmpty(v) ? ';' : Strings.toChar(v);
Defensive patterns

Strategy: validation

Validate before calling

// Java
if (Strings.isEmpty(s)) {
    s = DEFAULT_SEPARATOR_STRING; // or skip conversion
}
char c = Strings.toChar(s);

Try / catch

try {
    c = Strings.toChar(value);
} catch (StringValueConversionException e) {
    if (value == null) log.warn("Character value missing, using default");
    c = DEFAULT;
}

Prevention

When it happens

Trigger: Calling Strings.toChar(null), or toChar(value) where value comes from an absent property/parameter resolving to null.

Common situations: Missing entries in properties/config files; optional request parameters that were never supplied; defaults not being applied before conversion.

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/886780b3a0f89965. Report an issue: GitHub.