Skip to content

[camunda-bpm-data] Inconsistent handling of nulls #112

@FlorianCassayre

Description

@FlorianCassayre

Library Version

latest

Camunda Version

7.23 (Default)

Component

camunda-bpm-data

What happend?

When trying to upgrade this library from 1.2.8 to the latest 2025.06.1, we noticed some breaking changes and inconsistent handling of null values:

  1. nonNull doesn't seem to be behaving as expected, at least when used from a Java project it still allows null values
  2. List and other collection types are defined as non-null, making it impossible to have nullable such variables

Here is a test suite, that compares the behavior of the different versions:

import io.holunda.camunda.bpm.data.factory.VariableFactory;
import org.camunda.bpm.engine.variable.VariableMap;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import static io.holunda.camunda.bpm.data.CamundaBpmData.*;
import static org.junit.jupiter.api.Assertions.*;

public class BpmDataTest {
    private static final VariableFactory<String> STRING_VARIABLE = stringVariable("stringVariable");
    private static final VariableFactory<List<String>> LIST_STRING_VARIABLE = listVariable("listStringVariable", String.class);

    private static final String TEST_STRING = "test";

    private <T> T roundTrip(VariableFactory<T> variable, T value) {
        final VariableMap variableMap = builder().set(variable, value).build();
        return reader(variableMap).getOrNull(variable);
    }

    private <T> void assertRoundTrip(VariableFactory<T> variable, T value) {
        final T readValue = roundTrip(variable, value);
        assertEquals(value, readValue);
    }

    @Test
    void valueStringVariable() {
        assertRoundTrip(STRING_VARIABLE, TEST_STRING);
    }

    /**
     * Fails on: =1.4.0
     */
    @Test
    void nullStringVariable() {
        assertRoundTrip(STRING_VARIABLE, null);
    }

    /**
     * Not applicable to: <1.4.0
     * Fails on: >=1.5.0
     */
    @Test
    void nullRequiredStringVariable() {
        assertThrows(NullPointerException.class, () -> roundTrip(STRING_VARIABLE.getNonNull(), null));
    }

    @Test
    void valueListStringVariable() {
        assertRoundTrip(LIST_STRING_VARIABLE, List.of(TEST_STRING));
    }

    /**
     * Fails on: >=1.4.0
     */
    @Test
    void nullListStringVariable() {
        assertRoundTrip(LIST_STRING_VARIABLE, null);
    }

    @Test
    void valueListNullStringVariable() {
        final List<String> list = new ArrayList<>();
        list.add(null);
        assertThrows(NullPointerException.class, () -> roundTrip(LIST_STRING_VARIABLE, list));
    }

    /**
     * Not applicable to: <1.4.0
     */
    @Test
    void nullRequiredListStringVariable() {
        assertThrows(NullPointerException.class, () -> roundTrip(LIST_STRING_VARIABLE.getNonNull(), null));
    }
}

I believe that all the tests should pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: breakingChanges behaviour of the library in a way that clients of older version will need to adapt.Type: bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions