junit-team/junit5 · error · IllegalArgumentException

Could not read color palette properties

Error message

Could not read color palette properties

What it means

ColorPalette.getProperties(Reader) loads a Properties instance from a Reader and wraps any IOException from Properties.load() (e.g. malformed Unicode escape, a '\u' followed by non-hex characters, or a reader already closed) as IllegalArgumentException. This is distinct from the file-open error (110): here the file was opened but its contents failed to parse as valid .properties.

Solutions

  1. Open the palette file and fix any malformed '\uXXXX' escapes — they must be exactly four hex digits.
  2. Validate the file with a Properties loader in a scratch program to surface the exact line, or run 'native2ascii' / an equivalent to confirm encoding.
  3. Avoid backslashes in values or escape them as '\\' per .properties rules.
  4. Re-save the file as UTF-8 if encoding corruption is suspected.

Example fix

# before (palette.properties) — malformed escape
SUCCESSFUL=\u001B[1m
# The '\u001B' is interpreted by Properties as a Unicode escape and fails.
# after — escape the backslash per .properties rules
SUCCESSFUL=\\u001B[1m  # or omit the ANSI prefix entirely; ColorPalette expects numeric ANSI codes, not raw ESC sequences
Defensive patterns

Strategy: validation

Validate before calling

// Validate the palette file parses cleanly as .properties before the launcher does.
import java.io.*; import java.util.*;
try (Reader r = new InputStreamReader(new FileInputStream(file), java.nio.charset.StandardCharsets.UTF_8)) {
  Properties p = new Properties();
  p.load(r); // throws on malformed \uXXXX
} catch (IOException e) {
  throw new IllegalArgumentException("Palette file " + file + " is not valid .properties: " + e.getMessage(), e);
}

Prevention

When it happens

Trigger: Supplying a color palette file (via --color-palette) whose content violates the .properties format — most commonly a malformed '\uXXXX' Unicode escape sequence in a value, which Properties.load() rejects with IllegalArgumentException/IOException.

Common situations: Editing a palette file and introducing a bad escape (e.g. '\u00' truncated, '\uZZZZ'); copy-pasting ANSI sequences with backslashes that Java Properties interprets as escapes; saving with an editor that mangled encoding.

Related errors


AI-assisted analysis of junit-team/junit5@f070c699a0 (2026-08-11). Data as JSON: /api/errors/0982fd0d51400e50. Report an issue: GitHub.

Appendix: source

Thrown at junit-platform-console/src/main/java/org/junit/platform/console/output/ColorPalette.java:112

		this.colorsToAnsiSequences = colorsToAnsiSequences;
		this.disableAnsiColors = disableAnsiColors;
	}

	private static Map<Style, String> toOverrideMap(Properties properties) {
		Map<String, String> upperCaseProperties = properties.entrySet().stream().collect(Collectors.toMap(
			entry -> ((String) entry.getKey()).toUpperCase(Locale.ROOT), entry -> (String) entry.getValue()));

		return Arrays.stream(Style.values()).filter(style -> upperCaseProperties.containsKey(style.name())).collect(
			Collectors.toMap(Function.identity(), style -> upperCaseProperties.get(style.name())));
	}

	private static Properties getProperties(Reader reader) {
		Properties properties = new Properties();
		try {
			properties.load(reader);
		}
		catch (IOException e) {
			throw new IllegalArgumentException("Could not read color palette properties", e);
		}
		return properties;
	}

	private static Properties getProperties(Path path) {
		try (FileReader fileReader = new FileReader(path.toFile(), StandardCharsets.UTF_8)) {
			return getProperties(fileReader);
		}
		catch (IOException e) {
			throw new IllegalArgumentException("Could not open color palette properties file", e);
		}
	}

	public String paint(Style style, String text) {
		return this.disableAnsiColors || style == Style.NONE ? text
				: getAnsiFormatter(style) + text + getAnsiFormatter(Style.NONE);
	}

View on GitHub (pinned to f070c699a0)